Posts

c# - Add existing Web Api project to existing Mvc project -

i have 2 projects in solution, mvc project , web api project. best way go utilizing web api project within mvc application? options have come far: deploy both projects , use helper class interact api (javascript or server side) add reference web api project adds api functionality mvc project (not sure how integrate api project mvc project correctly, how this?) if there better alternative please share. in folder controllers have files this: namespace beerdev.controllers { public class homecontroller : controller { public actionresult index() { viewbag.title = "home"; return view(); } } } and create folder called controllersapi files this: namespace beerdev.controllersapi { public class homecontroller : apicontroller { public ihttpactionresult get() { string beers; using (streamreader sr = new streamreader(hostingenvironment.mappath("~/mo...

sql - Returning all data in one row -

in postgresql database, have multiple reference data tables. example: - gender(id:serial, name:varchar) - sexuality(id:serial, name:varchar) - location(id:serial,name:varchar) to retrieve of information in of tables doing 3 separate select statements. example: - "select name gender; - "select name sexuality; - "select name location; how can make 1 call returns 1 row this: referencedata(allgenders:varchar[], allsexualities:varchar[], alllocations:varchar[]) i able able client side --> var genders = results.row[0].allgenders; gender in genders { print(gender); } you can use array_agg aggragate function combine values multiple rows single array, e.g. select array_agg(name) gender will return genders single array. if want information 3 tables @ once, can that: select (select array_agg(name) gender), (select array_agg(name) sexuality), (select array_agg(name) location);

java - How to pass the name of the fragment to an Asynctask class? -

i have class works fine, because put name of fragment need receive information back... class call more 1 fragment need pass name parameter don't know how pass , how receive it. this async class public class asyncfragment extends asynctask<string, void, string> { subirfotos container; public asyncfragment(subirfotos f) { this.container = f; } @override protected string doinbackground(string... params) { try { thread.sleep(3000); // takes 3 seconds }catch(exception ex) {} return "dni activo "+params[0]+ " " + params[1]; } @override protected void onpreexecute() { super.onpreexecute(); container.showprogressbar(); } @override protected void onpostexecute(string result) { super.onpostexecute(result); // activity can null if thrown out android while task running! if(container!=null && container.getactivity()...

powershell - How to get the Windows install date of virtual machines in a cluster? -

i have 127 virtual machines in hyper-v cluster 6 nodes. i'm trying nice list of windows install dates each vm using powershell. have far, returns install dates of nodes. $clusternodes = get-clusternode foreach($item in $clusternodes) { gcim win32_operatingsystem | select name, installdate } how extend grabs info vms instead of nodes themselves? i don't have hyper-v host (much less cluster) @ hand, i'd try following: enumerate cluster nodes enumerate vms on each node get network adapter each vm expand ip address(es) each adapter , select one run get-wmiobject query against each selected ip address something (untested): get-clusternode -cluster clustername | foreach-object { get-vm -computer $_.name | get-vmnetworkadapter | select-object -expand ipaddresses | where-object { $_ -like '192.168.23.*' } | foreach-object { get-wmiobject -computer $_ -class win32_operatingsystem | select-object __server, name, ...

ios - Save number in Label even when restart app -

i'm trying save number tapped on button shown on label. want number tapped on button save in label when close app , add additional tapps saved number. import uikit import iad class viewcontroller: uiviewcontroller, adbannerviewdelegate { @iboutlet var taplabel: uilabel! @iboutlet var banner: adbannerview! var taps = 0 override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. banner.hidden = true banner.delegate = self self.candisplaybannerads = true } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } func bannerviewactionshouldbegin(banner: adbannerview!, willleaveapplication willleave: bool) -> bool { return true } func bannerviewdidloadad(banner: adbannerview!) { banner.hidden = false } @ibaction func button(sender: ...

javascript - parse js file for Java Application -

i'm using jsoup parse html website. there 2 option lists dynamically created multidimensional array in javascript file. since dynamically created jsoup can't parse results in html. however, data need located in js file. ideally i'd able periodically load file , persist / refresh array data file local database on android application. js file in question here , website showing lists here there way download selected aspects of file manipulate in java, dom in html? you use webview javascriptinterface or use rhino engine. latter approach described below. first download rhino (current version 1.7.7.1) copy rhino jar (e.g. rhino-1.7.7.1.jar ) lib folder libs folder in android project. add build.gradle (module: app) file dependency: dependencies { [other dependencies] compile files('libs/rhino-1.7.7.1.jar') } the following example activity loads script file, modifies script (see comments) , executes functions populate arrays. arrays retr...

regex - RE to NFA Thompson's construction steps ((c|a)b*)* -

Image
i tried convert ((c|a)b*)* nfa using thompsom's construction have understood wrong because outcome isn't 1 supposed be. glad if point mistake. thompson's construction rules: 1)every nfa has start state , accepting state. 2)no transition, except starting one, allowed enter start state. 3)no transition exits accepting state. 4)an ε-transition connects 2 states used start or accepting states res 5)a state can have @ maximum 2 incoming , 2 exiting ε-transitions 6)a state can @ maximum 1 incoming , 1 exiting transition specific character of alphanumerics used. step 1 : created nfas each character step 2 : parenthesis have priority created c|a step 3 : created b* step 4 : combined c|a , b* create (c|a)b* step 5 : , @ last created ((c|a)b*)* the difference correct solution in last nfa (the example doesn't show steps , states got renumbered in end) there no s9. s8 ε-transists s5 , s5 ε-transists s10. makes sense me if b* didn't have s9 sta...