Posts

Showing posts from January, 2010

java - Am I referencing this array position wrong? -

hi writing method larger program keep getting error symbol cannot found. please help! public static int maxinc (char []ch) { int current = 1; int max = 1; if (ch.length == 0) { return 0; } else if (ch.length == 1) { return 1; } else { (int = 1; < ch.length; i++); { if(ch[i] >= ch[i-1]) //the error @ ch[i] , ch[i-1] { current++; if(current > max) max = current; else current = 1; } } return max; } } there semi colon in line : for (int = 1; < ch.length; i++); remove , make line below: for (int = 1; < ch.length; i++) while there semicolon happening loop happen while nothing done. became statement. below code happening second example: this sample code for (int = 1; < ch.length; i++); { if(ch[i] >= ch[i-1]) { current++; if(current > max) max = ...

c++ - Put three string variable in one array -

i put 3 string variable in 1 array besides each other in c++. how can efficiently little code possible? in fact, must conversion of string class cstring type. thanks in advance. you can using following code: string str1 = "testing"; string str2 = " string"; string str3 = " concatenation"; string output = str1 + str2 + str3; cout << output; output be: testing string concatenation hope helps.

javascript - How can I use a default value for this array? The result is not displayed until the first loop -

i have code: <span id="changetext"></span> <script type="text/javascript"> var text = ["cool", "awesome", "outstanding"]; var counter = 0; var elem = document.getelementbyid("changetext"); var refreshintervali = setinterval(change, 2000); function change() { elem.innerhtml = text[counter]; counter++; if (counter >= text.length) { clearinterval(refreshintervali); } } </script> the output correctly displays each word after 2000ms, takes 2sec display first word. how can set default value displayed until start of loop? thanks in advance :) why not this var text = ["cool", "awesome", "outstanding"]; var counter = 1; var elem = document.getelementbyid("changetext"); elem.innerhtml = text[0]; var refreshintervali = setinterval(change...

ruby - why isn't gearmand processing workers? -

Image
i on mac osx (yosemite) installed using homebrew. ➜ ~ brew list gearmand /usr/local/cellar/gearman/1.1.12/bin/gearadmin /usr/local/cellar/gearman/1.1.12/bin/gearman /usr/local/cellar/gearman/1.1.12/homebrew.mxcl.gearman.plist /usr/local/cellar/gearman/1.1.12/include/libgearman/gearman.h /usr/local/cellar/gearman/1.1.12/include/libgearman-1.0/ (39 files) /usr/local/cellar/gearman/1.1.12/lib/libgearman.8.dylib /usr/local/cellar/gearman/1.1.12/lib/pkgconfig/gearmand.pc /usr/local/cellar/gearman/1.1.12/lib/ (2 other files) /usr/local/cellar/gearman/1.1.12/sbin/gearmand /usr/local/cellar/gearman/1.1.12/share/man/ (156 files) added /usr/local/sbin path (.bash-path) gearmand on path. ➜ ~ echo $path /users/davidvezzani/.rvm/gems/ruby-1.9.3-p551/bin:/users/davidvezzani/.rvm/gems/ruby-1.9.3-p551@global/bin:/users/davidvezzani/.rvm/rubies/ruby-1.9.3-p551/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/x11/bin:/usr/local/git/bin:/users/davidvezzani/.rvm/bin:/u...

c# - How to use math operators with strings? -

this question has answer here: how can convert string int? 24 answers i need display number on label when user input between >=0 , <= 1. user input string , need numbers between decimal or double. can't compare 2 did because operators can't compare string , decimal, double, or int. private void voltagetextbox_textchanged(object sender, eventargs e) { var rtpower = powertextbox.text; powertextbox.charactercasing = charactercasing.upper; if (rtpower >= 0 && <= 1) { displaylabel4.text = "1"; } } error: operator '>=' cannot applied operands of type 'string' , 'int' error: operator '<=' cannot applied operands of type 'string' , 'int' how can make if statement work? have keep string, display in label, convert label integer re-display it?...

How to use setTimeout in PureScript v0.7 -

i want use settimeout animation in purescript this. loop n = if n > 100 return unit else print n timeout (loop n+1) 30 purescript-timers no longer work in v0.7. i don't have slightest idea how implement this. there 2 ways: use purescript-js-timers purescript-contrib. use purescript-aff ( later' ). i prefer later, , here example: import control.monad.aff aff update :: forall eff. action -> state -> effmodel state action (eff) update myaction mystate = { state: mystate, effects: [ aff.later' 1000 $ pure myotheraction ] }

c# - OData.Simple.Client Linking "Attempt to access the method failed." -

i trying link entries using odata.simple.client public async task addgenresasnyc(int userid, list<genre> genres) { await client.for<user>.key(userid).linkentryasync(x => x.genres, genres); } this method using in order it. when run it throws exception "attempt access method failed." anyone have idea?

Bash script declare -

i trying create simple bash script ask user input , echo value in declares based on number choose. declare -a bla bla[1]="bla1" bla[2]="bla2" echo "what bla like?" echo "" echo "1) bla1" echo "2) bla2" read answer echo "bla[$answer]" when run script expecting output either "bla1" or "bla2" depending if typed 1 or 2. although ouput: "bla[1]" or "bla[2] what doing wrong here? you want use bash's select command here: bla=( bla1 bla2 ) ps3="what bla like? " select b in "${bla[@]}"; [[ $b ]] && break done echo "you want: $b" notes: a regular array suffices, don't need associative array if you're using integer indices. the array expansion "${bla[@]}" required expand array constituent elements. when user enters valid response, $b variable non-null, , break statement exits select "loop...

Is there a dictionary API for Android? -

i working on android application in have display meaning of word when selected. how kindle does. understand, there no google api yet ( https://code.google.com/p/google-ajax-apis/issues/detail?id=16 ) could please let me know if there way achieve this! know how kindle dictionary works! thanks!

javascript - Add a number of days to a given date time -

i found various answers add no. of days given date. want add number of days date & time in format mm-dd-yyyy hh:mm:ss i tried , successful when had date date & time returns invalid date when console.log(startdate) html <input type="text" id="startbidding" name="startbidding" > <input type="radio" name="expiry" value="5"> <span> 5 days </span> <input type="radio" name="expiry" value="10"> <span> 10 days </span> <input type="text" id="endbidding" name="endbidding" > jquery $(document).ready(function() { $('input[type=radio][name=expiry]').change(function() { var days = this.value; var startdate=new date($("#startbidding").val()); startdate.setdate(startdate.getdate()+parseint(days)); var inputdate = (startdate.getmonth()+1)+'-'+(startda...

ios - How to set CATextLayer in video according to frame? -

i have try many think no success yet, question have 1 video on provide functionality write text on video , drag/drop text on video wand set catextlayer on video propper position set user not display on proper position please me. this code used this. catextlayer *titlelayer = [catextlayer layer];//<========code set text titlelayer.string = self.strtext; titlelayer.font = (__bridge cftyperef)(self.fonts);; titlelayer.fontsize = titlelayer.fontsize; titlelayer.position = cgpointmake (titlelayer.fontsize,titlelayer.fontsize); //?? titlelayer.shadowopacity = 0.5; titlelayer.alignmentmode = kcaalignmentcenter; titlelayer.bounds = cgrectmake(self.recttext.origin.x,self.recttext.origin.y-52, 480, 480); //you may need adjust proper display [titlelayer setbackgroundcolor:[uicolor redcolor].cgcolor]; [parentlayer addsublayer:titlelayer]; //only if added text your code seems fine, not sure if frame provided wrong or right. if have provided right frame add code, in end:- [tit...

How to get last 6 months for the current year in Jquery -

dynamically want generate last 6 months using jquery demo here var str = ""; var monthnames = [ "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" ]; ( var = 5; >= 0; i--) { var = new date(); var date = new date(now.setmonth(now.getmonth() - i)); var datex = ("0" + date.getdate()).slice(-2) + "-" + ("0" + (date.getmonth() + 1)).slice(-2) + "-" + date.getfullyear(); str += "date :"+datex+" | month : " + monthnames[date.getmonth()] + "-" + date.getfullyear()+"\n"; } above code works fine if current date month less 30th, if current date 31 above code generate duplicate month irrelevant dates. any appreciated. thanks. this last paste 6 months current month on word...

In Python, why can't you parse a file immediately after it is created using subprocess? -

i trying read 1 input file (listed below 'infile2', can file), , each line in file, make file2, , parse file2 make file3. regardless of why want code way (unless reason problem of course...), why first block of code work, , next fail? #!/usr/bin/env python import sys import subprocess #this works def createfile(): command = "echo 'here text' > createfile.txt" subprocess.popen(command,shell=true) def parse(): open("createfile.txt") infile1: line in infile1: return line if __name__ == '__main__': infile2 = sys.argv[1] open(infile2) f: line in f: createfile() open(infile2) g: print parse() outfile=open("createfile.txt",'w')   #!/usr/bin/env python import sys import subprocess def createfile(): command = "echo 'here text' > createfile.txt" subprocess.popen(command,shell=true) def parse(): ...

php - HTML Output from DB Issue -

i running ckeditor textarea wysiwyg field through htmlspecialchars() , dumping database. i fetching field in database , it's outputting html screen. reason why outputting html , not utilizing html markup? code data dump: if (isset($_post['submit'])) { $ticketbody = htmlspecialchars($_post['ticketbody']); $sql = "insert tickets (ticket_text) values(:ticketbody)"; $stmt = $conn->prepare($sql); $stmt->bindparam(':ticketbody', $ticketbody, pdo::param_str); $stmt->execute(); } looping through data foreach ($rows $row) { <?php echo $row['ticket_text']; ?> } screencast of output: http://screencast.com/t/wbuus3orw note: adding htmlspecialchars_decode echo statement works turns text white! i'm not sure why, either - http://screencast.com/t/jgjmaocdyutm strip_tags() function doesn't work either. use mysqli_real_scape_string instead of html_special_chars maintai...

c# - Lambda query in NEST elastic search to have array of filters and values -

from 2 arrays filter[] , value[] hold filter names , filter values i need generate dynamic lambda query applying array of filters , values on it. something similar this, apply array values dynamically. var searchresults = client.search<job>(s => s.type("job") .size(size) .filter(f => f.term(filter[0], value1[0]) || f.term(filter[1], value[1])) ); awaiting suitable answer !! you need create bool should filter , pass array of filtercontainer objects can generated dynamically. i've written small code snippet build nest query per requirements. var filter = new list<string> { "field1", "field2" }; var value = new list<string> { "value1", "value2" }; var fc = new list<filtercontainer>(); (int = 0; < 2 /* size of filter/value list...

validation - Spring Validator and BindingResult - How to set different HttpStatus Codes? -

dear spring community, i building project using spring. in api layer, leveraging validator interface in order custom validation , set error. @override public void validate(object obj, errors e) { signuprequest signuprequest = (signuprequest) obj; user user = userservice.getuserbyemail(signuprequest.getemail()); if (user != null) { e.rejectvalue("user", errorcodes.user_exist, "user exist"); } } now, in api signature, since using bindingresult object, in @controlleradvice have, if user provides empty value attribute of dto object, wont able @exceptionhandler(methodargumentnotvalidexception.class) . what means that, wont able throw httpstatus.bad_request empty value provided. in above case of validator, wont httpstatus.bad_request rather httpstatus.ok . problem that, how provide different httpstatus types based on errors getting validator? there way have empty value still picked @exceptionhandler(methodargumentnotvalidexce...

python - Mongoengine query set to list conversion -

as in django sql backend can convert queryset flat list by foovar.objects.all().values_list('id', flat=true) give list of ids how list of ids in mongo backend ,orm being used mongoengine in values_list function has no flat parameter. you right, there no flat parameter in values_list . mongoengine has values_list . stating: foovar.objects.all().values_list('id') returns id's of foovar model.

swing - Adding list to JCombobox in java -

i have list has added jcombobox. my code is serialportcombobox=new jcombobox<string>(); serialportcombobox.setmodel(new defaultcomboboxmodel(list.toarray())); serialportcombobox.setbounds(125, 80, 220, 25); serialporttab.add(serialportcombobox); tried didnt work. im setting list frame , using list in combobox. code is configbtn.addactionlistener(new actionlistener() { @override public void actionperformed(actionevent e) { // todo auto-generated method stub try { keypadconfig key=new keypadconfig(); key.setid(serialportlist,hashlist); key.setvisible(true); } catch(exception e1) { e1.printstacktrace(); } } }); contentpane.add(keypadconfigbtn); this used in keypadconfig public void setid(list<string> serialportlist, hashmap<string, list<string>> hashlist...

unity3d - How can pause/resume recording audio from microphone in unity engine -

in unity engine want record audio microphone pause/resume ability; want have of recorded audio in 1 audioclip @ final; , don't know how many time pause , play (it's depend user, not me) (also length of it) can ? don't have ready made solution, way should start use microphone class , use start , end function record audio. returns audio clip can save numbered file (e.g., audio_datetime_00001,audio_datetime_00002,...). once user play/pause/stop can create new audio file. later can merge them using naudio (try mark heath's solution). happy coding!!!

db2 - In what sequence will the Delete SQL execute? -

Image
refer previous posting. sql cleanup script, delete 1 table that's not in other 1 using db2 ibm (as400, db2). i executing following sql cleanup script 3am. delete p6prodpf (0 = (select count(*) p6opipf b b.opiid = a.opiid)) i have different process @ same time sql runs inserts 2 records, first record p6opipf record , inserts detail record p6prodpf . the problem. p6prodpf record missing after sql cleanup ran. remember process stores records ran same time. how understand sql go's through p6prodpf , checks if record in p6opipf if not in p6opipf delete p6prodpf . but ran visual explain in systems navigator on sql , got following result. now confused. after visual explain looks statement starts checking p6opipf . so reads: if there's record in instance of time in p6opipf , no record same key in p6prodpf delete p6prodpf . this explain problem p6prodpf gets deleted when process inserts records , sql script runs @ same time. so ...

php - How to get array of key from amazon s3 object -

i using amazon s3 v3 php sdk , trying key of object using s3->listobjects([ 'bucket' => $somebucketname]); this function working fine , getting object under $somebucketname bucket , in below form aws\result object ( [data:aws\result:private] => array ( [istruncated] => [marker] => [contents] => array ( [0] => array ( [key] => 1.png [lastmodified] => aws\api\datetimeresult object ( [date] => 2015-07-14 07:22:25.000000 [timezone_type] => 2 [timezone] => z ) [etag] => "23f423234v23v42424d23" [size] => 19980 ...

web services - How to log JAVA Webservice to a file -

i build service jax-rs (jersey 2.0) , tried implement logger writes down events errors or results requests. works fine! :) unfortunately creates file every time service called nice writes in 1 file. have @ code (it's relevant part): package webservice.feedbacks; import java.io.ioexception; // imports @path("webservice") public class deletefeedback { logger logger = logger.getlogger("feedbacklogger"); @post @path("/deletefeedback") @consumes(mediatype.application_json + ";charset=utf-8") @produces("text/plain") public string setfeedbacks(string incoming){ filehandler fh; jsonobject jsonobj = new jsonobject(incoming); try { fh = new filehandler("d:/eclipse-projekte/smartliveservice/logs/deletefeedback_log.log"); logger.addhandler(fh); simpleformatter formatter = new simpleformatter(); fh.setformatter(formatter); logger.info("----- beginn des protokolls ---...

objective c - Restrict the dragging of SKMapView to a certain city -

i trying restrict dragging of skmapview city. here have tried, had gone through doc references , open source code. seems skboundingbox that. but piece of code doesn't work. still allows user pan everywhere. skboundingbox *boundingbox = [skboundingbox boundingboxwithtopleftcoordinate:topleftcoordinate bottomrightcoordinate:bottomrightcoordinate]; while there no integrated support this, can workaround. the file here should replace 1 public sdk demo app viewing workaround (mapdisplayviewcontroller.m). the idea can bounding box information of city/country maps.json provided us. need implement following callback: - (void)mapview:(skmapview *)mapview didchangetoregion:(skcoordinateregion)region { if (self.bbox) { if ([self.bbox containslocation:region.center]) { self.previousregion = region; } else { [self.mapview animatetolocation:self.previousregion.center withduration:0.2]; } } } this implem...

Android Facebook SDK get friend list -

i want user's logged app friend list. so, need use code that: new graphrequest( accesstoken.getcurrentaccesstoken(), "/me/friends", null, httpmethod.get, new graphrequest.callback() { public void oncompleted(graphresponse response) { /* handle result */ } } ).executeasync(); the problem don't know need write oncompleted method put friend list array. after data comes oncompleted() can see structure of json response, log.d("-@-", "graph response " + response.getjsonobject()); this gives structure of json object there can data. think app needs go through facebook submission there other permissions app needs friends of person

Is there a way to store a custom expression in Firebase Rules to be reused? -

i able reuse expression in firebase rules multiple times. if have following rules: { "rules": { ".read": true, ".write": false, "secretarea1": { ".read": "root.child('users').child(auth.uid).child('role').val() === 'admin'", ".write": "root.child('users').child(auth.uid).child('role').val() === 'admin'" }, "secretarea2": { ".read": "root.child('users').child(auth.uid).child('role').val() === 'admin'", ".write": "root.child('users').child(auth.uid).child('role').val() === 'admin'" } } } is there way store root.child('users').child(auth.uid).child('role').val() === 'admin' somewhere doesn't have repeated 4 times? something like: { "rules": { ".read...

ruby on rails - Work with HTML coder -

i rails backend developer , working in team html coder , have problems information exchange. i want him generate html templates (haml, erb, whatever) , css files. has no clue on how install ruby (and rails). so, working in ugly workcycle when puts html's , css's in public, test them, , (myself) move them correct place. is there tool (for html codes) mimics rails rendering part run tool, must easy, , when server starts, can put templates app/ , test them? i see small easy installable subset of rails, deal page rendering. if coder still doesn't know how install ruby or how configure stuff works , can quite problematic . either can try cloud based ide . or , tools git raw stuff. but , can in minimum way try make whole process possible learning , installing ruby in pc .

c - __COUNTER__ with global scope -

if use __counter__ in 2 different source files, value reset zero. possible make __counter__ scope global? file: file1.c int x=__counter__; int y=__counter__; file: file2.c int a=__counter__; int b=__counter__; i have x, y, & b have unique initialized values. in case, x=a, y=b. i tried placing __counter__ in common header file. result same. file: common.h #define value __counter__ replace __counter__ value in above files.

Action to open iMessage (Swift) -

i've been searching around , can't seem find one... is possible create action within app opens imessage , populates to: field phone number? think possible postmates has feature... not sure methods call. thanks! mark what you're looking mfmessagecomposeviewcontroller . it doesn't "open imessage" creates imessage compose screen. can repopulate telephone number , put message. the user can edit message , tap "send" sending imessage.

sql server - Diagram of model not being updated when model updated from DB after table removal -

Image
i noticed when create table in db , update model, new object corresponding said table appears automagically in diagram. however, when remove table , perform same operation, diagram stays unchanged. i'm curious if there's way automate process updated diagram displayed. intended behavior, way? what'd for?

wordpress - Woocommerce - Shop Manager user delete capability -

apparently administrator can delete users. shop manager can edit users (their info , password). i'd shop manager able delete users administrators. shop manager can't delete users created. any suggestions? see add_cap function on how add capability role. here list of available capabilities. another approach , albeit easy 1 install role editor plugin, eg: https://wordpress.org/plugins/user-role-editor/ , edit 'shop manager' role , assign capabilities required.

saml - What's today's standard protocols that use by SSO(single sign on)? -

saml 2.0? openid? oauth 2.0? cas? , others? i know can sso, want find out standard protocol nowadays used sso covers 80% of market? anyone knows how find result? there no standard protocol because depends on use case e.g. microsoft enterprise uses ws-fed. java enterprise uses saml-p. native (mobile) uses oauth2 consent. if want authentication on top of this, add openid connect. and depends on sts - not every sts supports above.

python 3.x - Simulating Network flows in NetworkX -

i trying simulate network flow problem in networkx each node constrained capacity. need specify demand rates , capacity @ every node (also ensure flows don't exceed capacity). of now, have defined flows edge weights. is there way in networkx? if so, modules, should using? nice if visualize network simulation. simple code involving 4 or 5 nodes lot. thanks.

node.js - MQ monitoring and integrating with google-analytics? -

here scenario. have different environments applications hosted on. these applications access data or talk other applications hosted on different environments. we using mq message communication there no mechanism track communication activity. is possible monitor mq message google-analytcs ? if yes, idea. or there better solution? update : is there has tried https://www.npmjs.com/package/mqlight , possible integrate google-analytcs ??? the idea built mq monitoring dashboard (visualization, alerts, message details, source/destination details etc..) or integrate event google-analytics track mq rest api. i javascript developer , want built such utility consuming rest api use of angularjs , nodejs . is there mq rest api can used built such utility ???

bit manipulation - Mask and aggregate bits -

i'm trying efficiently execute following task: input value: 01101011 mask: 00110010 mask result: --10--1- aggregated: 00000101 i hope examples explains i'm trying achieve. what's best way in non-naive way? this operation called compress_right or compress , , moderately terrible implement without hardware support. non-naive code hacker's delight "7–4 compress, or generalized extract" implement function is unsigned compress(unsigned x, unsigned m) { unsigned mk, mp, mv, t; int i; x = x & m; // clear irrelevant bits. mk = ~m << 1; // count 0's right. (i = 0; < 5; i++) { mp = mk ^ (mk << 1); // parallel suffix. mp = mp ^ (mp << 2); mp = mp ^ (mp << 4); mp = mp ^ (mp << 8); mp = mp ^ (mp << 16); mv = mp & m; // bits move. m = m ^ mv | (mv >> (1 << i)); // compress m. t = x & mv...

css - Adding gap between columns in Bootstrap -

check out this site on slider have 4 columns text inside them, right? i want gaps between columns below. ███████████ ███████████ ███████████ ███████████ i saw many posts on stackoverflow how this. don't work me. any please? html: <div id="rowcopy"> <div class="col-xs-5 col-sm-3" id="box">text</div> <div class="col-xs-5 col-sm-3" id="box"><img width="100%" src="./images/datamanagement.jpg"/></div> <div class="col-xs-5 col-sm-3" id="box"><img width="100%" src="./images/storageservices.jpg"/></div> <div class="col-xs-5 col-sm-3" id="box"><img width="100%" src="./images/storageservices.jpg"/></div> </div> css: #content #rowcopy{ width: 80%; margin: 0 auto; display: block; } #content #rowcopy #box { backgr...

selenium - Scrapy xpath returning empty list in python -

i don't know doing wrong. trying extract text , store in list. in firebug , firepath when enter path shows exact correct text. when apply returns empty list. trying scrape www.insider.in/mumbai. goes links , scrape event title,address , other information. here new edited code: from scrapy.spider import basespider scrapy.selector import selector selenium import webdriver selenium.webdriver.common.keys import keys scrapy.selector import htmlxpathselector import time import requests import csv class insiderspider(basespider): name = 'insider' allowed_domains = ["insider.in"] start_urls = ["http://www.insider.in/mumbai/"] def parse(self,response): driver = webdriver.firefox() print response.url driver.get(response.url) s = selector(response) #hxs = htmlxpathselector(response) source_link = [] temp = [] title ="" price = "" venue_name...

What does this assembly l code mean? -

in program source code ,i saw following. code exactly? .code foo proc nop nop push rax push rax mov rax, 545h mov [rsp+8], rax pop rax ret foo endp end then used dll export: extern "c" void __stdcall foo(void); it pushes 2 values, modifies 1 of them, pops one. leaves 1 value ret . it unclear how better jmp 545h though.

Calling a function for each updated row in postgresql -

i have sql update statement in plpgsql function. want call pg_notify function each updated row , uncertain if solution best possibility. i not aware of position in update statement apply function. don't think possible in set part , if apply function in where part, applied each row checked , not updated rows, correct? i therefore thought use returning part purposes , designed function this: create or replace function function_name() returns void $body$ begin update table1 set = true table2 table1.b = table2.c , <more conditions> returning pg_notify('notification_name', table1.pk); end; $body$ language 'plpgsql' volatile; unfortunately gave me error saying not using or storing return value of query anywhere. therefore tried putting perform in front of query seemed syntactically incorrect. after trying different combinations perform ultimate solution this: create or replace function function_name() returns void $body...

json - calling method webService (WCF) from iOS objective C) -

i want calling method webservice parameter json ios, received error. code server side (wcf): [operationcontract] [webget(responseformat = webmessageformat.json, uritemplate = "/test/{input}")] int test(string input); i want input (parameter method , url) = typeof (json) code client side (ios-objective c) : nsstring *json = [self converttojson:myobject]; nsstring *urlcomplete = [nsstring stringwithformat:@"%@%@",@"http://test.com/service.svc/test/",json]; urlcomplete = [urlcomplete stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]; nsmutableurlrequest *request = [[nsmutableurlrequest alloc]init]; [request seturl:[nsurl urlwithstring:urlcomplete]]; [nsurlconnection sendasynchronousrequest:request queue:[nsoperationqueue mainqueue] completionhandler: ^(nsurlresponse *response, nsdata *data, nserror *connectionerror) { if (data.length > 0 && connectionerror == nil) ...

How to inspect IFaceMap of a type using SOS debugging extension in .NET -

is possible output ifacemap of type using sos debugging extension? dumpmt command gives number of interfaces type implements doesn't give command output ifacemap entries themselves !dumpmt -md 007938ec eeclass: 00791310 module: 00792e94 name: debugtest.customer mdtoken: 02000004 basesize: 0x10 componentsize: 0x0 slots in vtable: 10 number of ifaces in ifacemap: 1 !dumpheap doesn't output interfaces. i never came across such functionality in sos or sosex. closest commands saw netext (codeplex) . netext open source, if internals, read source code see how finds out interface information. one command !windex -implement <interfacename> . however, not list interfaces of type, rather opposite: types implement interface. sounds potentially interesting case. the other !wclass <methodtable> output looks similar .net decompiled code. on class definition level, can see implemented interfaces (e...

c# - ASP.NET MVC moq returns empty list -

i'm using moq framework test mvc application. i've added generic repository , unit of work class. when run test of controller fails because mock returns empty list (size 0) though i've added 2 elements. here test: [testmethod] public void index() { var repmock = new mock<ifakultetrepository<students>>(); var students = new list<students>(); students.add(new students() { bi = "10011", ime = "pera", prezime = "peric", adresa = "ulica1", grad = "grad1"}); students.add(new students() { bi = "20011", ime = "marko", prezime = "markovic", adresa = "ulica2", grad = "grad2" }); repmock.setup(x => x.getentities()).returns(students.topagedlist(1, 5)); studentscontroller controller = new studentscontroller(repmock.object); viewresult result = controller.index(...

excel - Using arrays inside functions in VBA -

i can't seem find answer question: can create user-defined function in excel vba uses array sub-procedure, , in excel use function return value? from site ( http://www.cpearson.com/excel/passingandreturningarrays.htm ) found example: sub aaatest() dim staticarray(1 3) long dim result long staticarray(1) = 10 staticarray(2) = 20 staticarray(3) = 30 result = sumarray(arr:=staticarray) debug.print result end sub function sumarray(arr() long) long ''''''''''''''''''''''''''''''''''''''''''' ' sumarray ' sums elements of arr , returns ' total. ''''''''''''''''''''''''''''''''''''''''''...

jQuery: Loop through elements and number the children -

i want number each span element containing list, beginning 1. continuous: http://jsfiddle.net/qab76/125/ the markup <li> <span class="1"><span> </li> <li> <span class="2"><span> <span class="3"><span> </li> <li> <span class="5"><span> <span class="6"><span> </li> but want be: <li> <span class="1"><span> </li> <li> <span class="1"><span> <span class="2"><span> </li> <li> <span class="1"><span> <span class="2"><span> <span class="3"><span> </li> thanks use separate each() iterations li , span elements $(document).ready(function () { $("li").each(function (i) { $(this).find("span").each(funct...

cocoa - NSBrowser image is not displaying in cell -

i'm using nsbrowser view show list of files , folder in finder type app.i'm using new item base api nsbrowser. the problem when try set image in willdisplaycell method. nothing displayed in view. code: // utility method find parent item given column. item based api eliminates need method. - (filesystemnode *)parentnodeforcolumn:(nsinteger)column { if (_rootnode == nil) { _rootnode = [[filesystemnode alloc] initwithurl:[nsurl fileurlwithpath:@"/users/kiritvaghela"]]; } filesystemnode *result = _rootnode; // walk column, finding selected row in column before , using in children array (nsinteger = 0; < column; i++) { nsinteger selectedrowincolumn = [_browser selectedrowincolumn:i]; filesystemnode *selectedchildnode = [result.children objectatindex:selectedrowincolumn]; result = selectedchildnode; } return result; } - (void)browser:(nsbrowser *)browser willdisplaycell:(nsbrowsercell *)cell atrow:...

Extracting the callback function name from an HTML element in jQuery -

i have element on page this: <input id="qty1" type="number" class="number" name="123" onchange="updatedqtyitemlistbuild('sku2010109');"> i'm trying grab actual text inside onchange call in order parse out sku value. when use jquery's attr("onchange"), reference function, not text itself. can't change page @ add elsewhere. am missing here or there way standard script? chris simply getting attribute returns string literal document.getelementbyid('qty1').getattribute('onchange'); //updatedqtyitemlistbuild('sku2010109'); what having problem with?

c# - While disposing the class instance, do i need to dispose all its IDisposable members explicitly? -

i have class has property of type sqlconnection . sqlconnection implements idisposable . have following questions: should class implement idisposable because has property of type idisposable ? if yes, need dispose property explicitly when disposing instance of class? e.g. public class helper : idisposable { // assume it's other idisposable type. sqlconnection example. public sqlconnection sqlconnection { get; set; } public void dispose() { if (sqlconnection!= null) { sqlconnection.dispose(); } } } note : know there pattern followed while implementing idisposable question specific case mentioned above. it depends . if class creates , owns idisposable must dispose (so, both answers "yes" ). if class uses idisposable must not dispose (so first answer is, usually, "no" , second answer "no" ). in case, seems helper class public class helper { // note, c...

html - JQuery - option selected not allowing change -

i have jquery dynamically created form need able edit , change in option, code below picks selected value because second line of code sets default value defined selected, on changing drop-down, no matter select keeps original value - , presume because it's been selected second line, how break on changing option text (i have no values, text). $('#msgbox4').html($('#msgbox4').html() + '<div class="table-row"><div class="table-col-l">type:</div><div class="table-col-r"><select id="type2" required="required"><option selected value="" disabled> -- select option -- </option><option>holiday</option><option>sick</option><option>working off site</option></select></div></div>') $("#type2 > option:contains('"+calevent.description+"')").attr("selected", "selected...

html - jquery `$form.find` get element inside form -

i have jquery code: if ($form.find('.required').filter(function(){ return this.value === '' }).length > 0) { } within if statement, how can each element , add class it? i tried $(this).addclass("emptyselect"); adds class form , not element perform addclass right after filter() call var emptyelements = $form.find('.required').filter(function() { return this.value === '' }); if (emptyelements.length > 0) { emptyelements.addclass("emptyselect"); } however, can connect filter statement addclass without if since filter return empty elements $form.find('.required').filter(function() { return this.value === '' }).addclass("emptyselect");

javascript - Replacing objects inside Angular's forEach() -

this question has answer here: is possible change values of array when doing foreach in javascript? 7 answers i have array of objects , foreach() , one: $scope.things = [ {x: 2}, {x: 4}, {x: 5} ]; angular.foreach($scope.things, function(thing) { //pick 1 of lines @ time //thing.x += 10; // <--- works //thing.k = thing.x + 1; // <--- works //thing = {k: thing.x + 10, o: thing.x - 1}; // <--- doesn't work // }); console.log($scope.things); and "works", "works" , "doesn't work" mean: x added 10, , final array looks {x: 12}, {x: 14}, {x: 15} k created, , final array looks {x: 2, k: 3}, {x: 4, k: 5}, {x: 5, k: 6} thing isn't replaced, , array of things looks @ beginning. my questions are: why happening? is expected behavior? how can replace each thing ? ...

mysql - Match specified integers -

i have following regex: 1|2|3|4|5|6 it's sql part, , want match 6 ids. problem regex matches integers 11, 12, 13, 14, 15, 16, 23, etc. how can form regex match 6 specific integers? in order use "shorter" queries, can use alternation character class regexp : select * table id regexp '^([1-6]|23)$' the character class [1-6] matches numbers 1 6 , , | used list other alternatives. grouping (...) makes anchors ^ (beginning of string) , $ (end of string) apply possible alternatives. if ids passed separately , regex created dynamically, use alternation: ^(23|6|5|4|3|2|1)$ however, if have small subset of ids, you'd better use or syntax list alternatives since non-regex solutions less resource-consuming.