Posts

Showing posts from April, 2011

excel - Determine the month of a week based on in which month a certain weekday is? -

excel - Determine the month of a week based on in which month a certain weekday is? - i want user come in year a1. i want user come in week number a2. i want user come in weekday (monday, tuesday, wednesday, thursday, friday, saturday or sunday) in a3. then want a4 calculate month of entered week number weeks counted belonging month depending on if specified weekday in month or not. what formula work in a4? (if can not solve problem, can give me formula works if specified weekday can thursday, welcome well. my thought that: (weeknumber-1)*7 + weekday -> mon = 1, tue = 2.... check day of year [0..365 or 366] , compare offset jan / feb / march... depending on whether year has 29th of feb - can calculated using year. now have convert code. edit: after read page reffered to, assume have problem understanding excels date syntax http://office.microsoft.com/en-us/excel-help/date-function-hp010062283.aspx so lets break code down: happens here? =choose(mo...

C# JSON - Serializing Objects depending on conditions -

C# JSON - Serializing Objects depending on conditions - i have on list of strings represent selected users. i want serialize json in 1 of properties selected. true if user in list , false if not. right have this: viewbag.json = jsonconvert.serializeobject(new { utilizadores = db.utilizador.select(u => new { id = u.id, nome = u.nome, info = u.nummecanografico, selected = false }) }); example final result: i want this, imagina user 1 , 2 in list. , have 4 users total. utilizadores = [id:1, nome: user1, selected: true],[id:2, nome: user2, selected: true],[id:3, nome: user3, selected: false],[id:4, nome: user4, selected: false] something this. right don't see how can status here. can shed light? i interpreted question in means "you have list of selected users, json property selected true if user in list" ilist<string> selectedusers = ... //the list of selected usernames viewbag.json = jsonc...

ios - Why is my regex in Swift not compiling? How do I give it a mutable string instead? -

ios - Why is my regex in Swift not compiling? How do I give it a mutable string instead? - when utilize next code strip http:// , www. off origin of url, error. var error: nserror? = nil allow regex = nsregularexpression(pattern: "^(http(s)?://)?(www(\\d)?\\.)?", options: nil, error: &error) var stringy = "http://www.google.com/" regex.replacematchesinstring(stringy, options: nil, range: nsmakerange(0, countelements(stringy)), withtemplate: "") the error being: 'nsstring' not subtype of 'nsmutablestring' how prepare this? doing wrong? you can create stringy nsmutablestring constructing nsmutablestring(string: ...) . you'll have few other things code work though: you can't pass nil options. if don't want pass options, right value nsmatchingoptions.allzeros in xcode 6.1 gm, init method you're using nsregularexpression returns optional ( nsregularexpression? ), you'll need u...

java - Plain Json String to HashMap -

java - Plain Json String to HashMap - there quite few questions raised convert json hashmap . hope helps everybody. the next code convert direct values or array of values, hashmap . // function called recursively private static map getmap(jsonobject object, string json) throws exception { map<string, object> map = new hashmap<string, object>(); object jsonobject = null; iterator<string> keys = object.keys(); while (keys.hasnext()) { string key = keys.next(); object value = object.get(key); if (value instanceof jsonobject) { map.put(key, getmap((jsonobject) value, json)); continue; } // if value in form of array if (value instanceof jsonarray) { jsonarray array = ((jsonarray) value); list list = new arraylist(); (int = 0 ; < array.length() ; i++) { ...

How to use wget with `&` from ruby -

How to use wget with `&` from ruby - i'm trying web page info http://example.com/foo.php?arg1=1&arg2=2 . i can page using wget without problem, when phone call wget ruby script like: `wget http://example.com/foo.php?arg1=1&arg2=2` then wget connect http://example.com/foo.php?arg1=1 . in short wget ignores sec argument. i tried system method, ends same error. how can utilize & wget ruby? surround url quote prevent shell interpreter & : `wget 'http://example.com/foo.php?arg1=1&arg2=2'` # ^ ^ or escape & : `wget http://example.com/foo.php?arg1=1\\&arg2=2` # ^^^ update or can utilize shellwords::shellescape Зелёный suggested: "foo&bar".shellescape # => "foo\\&bar" require 'shellwords' `wget #{shellwords.shellescape('http://example.com/foo.php?arg1=1&arg2=2')}` or,...

java - Do action when user crosses 2km distance from current location -

java - Do action when user crosses 2km distance from current location - i want method gets lon , lat , should homecoming true when user under 2km location using lon , lat fixed..but dont know how implement can 1 give idea google has feature called geofencing. there on sample app. utilize feature caution because can drain battery. java android methods

angularjs - Ionic + Auth0 hangs when emulating on iOS -

angularjs - Ionic + Auth0 hangs when emulating on iOS - i followed @mgonto 's adding auth ionic app in 5 minutes. works great in browser when "ionic emulate ios" hangs after seek authenticate facebook (see screenshot). any suggestions? ios angularjs authentication ionic-framework

wso2 - Wso2esb - lower memory performance -

wso2 - Wso2esb - lower memory performance - i'm using wso2esb 4.7.0.i'm facing problem of memory overflow.actually if less load on scheme works fine per load increases scheme slower.upto 80 90% scheme handles somehow above can't allocate new objects.after gives timeout error or server down.i have restart system. for performance improvement have tried thrashing.it helps me littlebit not much..still scheme causes problem.is suggestion improve scheme performance? wso2 esb document contains performance tuning parameters. did go though them. please find here esb 4.7.0. if oom issue, sometime may have not increment memory foot print of esb. can increment using next parameters in wso2server script file. -xms1024m -xmx2048m -xx:maxpermsize=1024m wso2 wso2esb wso2carbon

internet explorer - Montserrat font isn't displayed on IE 10 and 11 -

internet explorer - Montserrat font isn't displayed on IE 10 and 11 - in website http://themescreators.com/ela/ using google fonts. of them work on chrome, ff.. on ie 10 , 11 on windows 7, "montserrat" font doesn't display. have not thought can issue, ie incompatible google fonts? if visit site on windows 7 see issue, "montserrat" h1, h2... aren't visible. thanks in advance! first of all, don't have defined secondary font can displayed if montserrat isn't load properly. that's reason why no font displayd. h1, h2, h3, h4, h5, h6 { font-family: montserrat; font-weight: 400; font-style: normal; color: #1c2334; } i recommend set font-family , add together more fonts cases. secondly, montserrat isn't load because bug of ie11 has been reported on google font directory on msdn forum. unfortunately hasn't been fixed yet. one solution can download google web fonts, upload them whith website , define them...

Is it possible to clear the cache of map tiles on the Google Maps for iOS SDK? -

Is it possible to clear the cache of map tiles on the Google Maps for iOS SDK? - i using latest version of google maps ios sdk. noticed sdk stores cache of map tiles in gmscachestorage directory in apps filesystem. have not found way through sdk clear cache. there known workaround emptying tiles.sqlite file holds cached data? i able delete file off file scheme clear data, not regenerate, no future caching done. thanks, no there no public api that. you can false memory warning notification , gms clear... bit (note isnt app store safe) i class-dumped sdk , found methods promising names don't seem help more notification (which doesn't help much) ios google-maps caching google-maps-sdk-ios

scip - Getting LP relaxation before SCIPsolve -

scip - Getting LP relaxation before SCIPsolve - i utilize lp relaxation of problem before calling scipsolve() , know best/simplest way of doing this. i'm creating scip_lpi populate original problem's data. thought simple way phone call scipgetlpi() (and re-create everything), when write problem file (to see it) empty problem. guess because since haven't called scipsolve() yet. tried calling scippresolve() first, problem still empty. to lp relaxation believe have phone call scipsolve @ point. 1 way see , utilize scipsolve set parameter limits/nodes 1, phone call scipsolve , solve root node. can set limits/nodes -1 , phone call scipsolve 1 time again solve if needed. note doing give lp relaxation of presolved problem, , cuts added. depending on do, may want disable presolving , cuts. scip

python - Fabric script with wrong locale when launched trough celery task -

python - Fabric script with wrong locale when launched trough celery task - i have django web application has celery tasks. 1 of tasks launches fabric script. when run fabric script manually, locale value ok: lang=en_us.utf-8 language= lc_ctype="en_us.utf-8" lc_numeric=pt_pt.utf-8 lc_time=pt_pt.utf-8 lc_collate="en_us.utf-8" lc_monetary=pt_pt.utf-8 lc_messages="en_us.utf-8" lc_paper=pt_pt.utf-8 lc_name=pt_pt.utf-8 lc_address=pt_pt.utf-8 lc_telephone=pt_pt.utf-8 lc_measurement=pt_pt.utf-8 lc_identification=pt_pt.utf-8 lc_all= when fabric script launched celery task, locale is: lang= language= lc_ctype="posix" lc_numeric="posix" lc_time="posix" lc_collate="posix" lc_monetary="posix" lc_messages="posix" lc_paper="posix" lc_name="posix" lc_address="posix" lc_telephone="posix" lc_measurement="posix" lc_identification="posix" lc_a...

c - Heap corruption with function pointer on Solaris 64-bits -

c - Heap corruption with function pointer on Solaris 64-bits - i have next c code on solaris 5.10 64-bits compiled cc 5.10 flags -m64 -kpic -x04 header.h typedef struct functions { double (* pfcomputegeneric) (mystruct *, mystruct *, double, double *, int); } functions; ... double mycompute(mystruct *, mystruct *, double, double *, int); source.c double mycompute(mystruct * px1, mystruct *px2, double d1, double *pd1, int i1) { // stuff px1 } ... mystruct *pxstruct = alloc(...); functions *pxfunctions = alloc(...); pxfunctions->pfcomputegeneric = mycompute; ... double dresult += pxfunctions->pfcomputegeneric(pxstruct, pxstruct, 0.0, null, 0); the code in source.c runs fine (nothing weird) until come in enter mycompute through function pointer pfcompute, px1 gets corrupted. don't know why. replacing phone call through pfcompute direct phone call mycompute solves issue. removing -x04 alternative solves issue. i had @ reply of thi...

c++ - Position of a vpointer in an object -

c++ - Position of a vpointer in an object - class c { public: c() : m_x(0) { } virtual ~c() { } public: static ptrdiff_t member_offset(const c &c) { const char *p = reinterpret_cast<const char*>(&c); const char *q = reinterpret_cast<const char*>(&c.m_x); homecoming q - p; } private: int m_x; }; int main(void) { c c; std::cout << ((c::member_offset(c) == 0) ? 0 : 1); std::cout << std::endl; std::system("pause"); homecoming 0; } the programme above outputs 1 . check addresses of c object , c 's field m_x . prints out 1 means addresses not equal. guess is because d'tor virtual compiler has create vtable class , set vpointer in class's object. if i'm wrong please right me. apparently, puts vpointer @ origin of object, pushing m_x field farther , giving different address. case? if standard specify vpointer 's position in object? ac...

c++ - Linux passing continuous output as command line args -

c++ - Linux passing continuous output as command line args - i have machine vision programme ( ./detectupdatehomeml ) continuously outputs name of objects found terminal using next code: circle( img, center, radius, color, 3, 8, 0 ); if (circle) { std::cout << " " << cascadename << " " << timefound() << endl; std::cout << std::flush; } int timefound() { time_t rawtime; struct tm * timeinfo; char buffer [80]; time (&rawtime); timeinfo = localtime (&rawtime); strftime (buffer,80," %y-%m-%dt%h:%m:%s",timeinfo); std:cout << (buffer); eventcount++; } i looking send input command line arguments sec programme using back-ticks capture output , send other programme so: ./acceptinput `./detectupdatehomeml` however arguments don't seem getting passed ./acceptinput . i have test programme called ./testinput prints hello world! so: std::cout << "hello w...

angular ui router - AngularJS: How to change URL parameter without using reloadOnSearch and not to reload controller using ui route? -

angular ui router - AngularJS: How to change URL parameter without using reloadOnSearch and not to reload controller using ui route? - i want alter url query parameter without reloading controller. , can't utilize reloadonsearch property, because not meet other requirements. for example: path: /score?interval i want alter interval value without using reloadonsearch , controller should not reload. can done angularjs? and, if so, how? thank in advance!! take @ next plunker. uses angular's $location service alter url without reloading controller. can utilize method update url parameters also: $location.path('/test/item/' + $scope.itemid); if want alter url parameters can shown in plunker. (preview in windowed mode see working) can utilize $location.search() shown below: $location.search('id', testid); hope helps. angularjs angular-ui-router

python - CSRF protection on AJAX authentication in Flask -

python - CSRF protection on AJAX authentication in Flask - i'd ajaxify both login , signup form on site. i've been using wtforms built-in csrf protetion, project didn't sense worth -- layer of abstraction, , hence frustration, should pretty simple. so came across this snippet on flask's security section: @app.before_request def csrf_protect(): if request.method == "post": token = session.pop('_csrf_token', none) if not token or token != request.form.get('_csrf_token'): abort(403) def generate_csrf_token(): if '_csrf_token' not in session: session['_csrf_token'] = some_random_string() homecoming session['_csrf_token'] app.jinja_env.globals['csrf_token'] = generate_csrf_token i understand thought process behind code. in fact, makes perfect sense me (i think). can't see wrong it. but doesn't work. thing i've changed code replacing pseudofunc...

java - Maven clean install freezes on "Copying artifact" for an EAR with a WAR inside it on Windows -

java - Maven clean install freezes on "Copying artifact" for an EAR with a WAR inside it on Windows - every time seek run mvn clean install on ear, copies ejb fine, war freezes while trying re-create ear. both ejb , war build fine, , build ear , ejb get's copied fine freeze , console sit down there forever. i using windows , java 8 , working fine until @ 10pm lastly night. then, freeze. now, freeze every time. i have tried deleting .m2, checking file permissions, nil seems work. could there circular reference or something? don't think there is. is there way run mvn verbose particular function? here ear pom: <?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelversion>4.0.0</model...

c++ - Why is the output of this code is 22? -

c++ - Why is the output of this code is 22? - this question has reply here: why output of code 21 , not 12? [duplicate] 2 answers #include <iostream> using namespace std; class { int *val; public: a() { val = new int; *val = 0; } a(a &a) { val = new int; *val = a.get(); } int get() { homecoming ++(*val); } }; int main() { a,b = a; cout << a.get() << b.get(); homecoming 0; } i have problem working out. getting confused on how *val gives output of 22 both object. it's simple. create a has *val set 0 . then create b via b = a , invokes re-create constuctor. re-create constructor calls a.get() . a::get() increments value pointed val 1 , returns it. a gets *val set 1 , , b gets value , sets own *val 1 . then print both using get() 1 time again increases each before returning. 2 both ge...

apache - Manipulate user's address bar with mod_rewrite -

apache - Manipulate user's address bar with mod_rewrite - i have page @ example.com/themizer.php , want appear it's located @ example.com/themizer/ (or example.com/themizer/index.php ) practical purposes. know how create alias mod_rewrite, how create appear users beingness redirected alias? example: user requests example.com/themizer.php , address in browser turns example.com/themizer/ without redirecting. possible? with server-sided configuration, can accomplish redirect. not need problem. create sure urls on site point fancy url , not internal url. otherwise generate lot of requests have redirected, instead of redirecting odd request came in in other way (e.g. through external old url or old bookmark). this: #external redirect rewritecond %{the_request} ^get\ /themizer\.php\ http rewriterule ^themizer\.php$ /themizer/ [r,l] #internal rewrite rewriterule ^themizer/?$ themizer.php [l] if must, can utilize javascript 'push' new window stat...

Not able to get $_POST assigned to a variable PHP -

Not able to get $_POST assigned to a variable PHP - i assume have stupid happening due lack of experience. on form on members.php have: $column = 0; echo "<form name =member method =post action = individual.php>"; echo "<table>"; echo "<tbody>"; while($row = $rs->fetch_assoc()) { if ($column == 0) { echo "<tr>"; } echo '<td><input type = submit name="'. $row['num'].'" value ="'. $row['name'].'" id=submit></td>'; $column++; if ($column >= 5) { echo "</tr>"; $row++; $column=0; } } echo "</tbody>"; echo "</table>"; echo "</form>"; on individual.php have print_r($_post); with result beingness array ( [16] => luke ) expected. but when seek $name...

angularjs - Access ng-repeat value in Jade -

angularjs - Access ng-repeat value in Jade - new node, angular, , jade -- looking access angular repeat value via jade. the current code tr( ng-repeat="item in $data" ) td(...) span {{item.stuff}} this creates table of item.stuff . i'm looking utilize jade's conditional statements on item . such as: case #{ item.stuff } , item undefined in scenario. angularjs jade

Android Studio GIT check-out loses module -

Android Studio GIT check-out loses module - i using android studio 0.89 fine , have added back upwards git on cloudforge. looks working can commit , force , in cloudforge can see commits , far can see there. but if check out main branch (which branch currently), imports ok, when android studio opens next error message: would remove vcs root '/.../.../..... removed module 'zipgm28oct2014'? if yes opens framework missing , asks configure , no modules visible. ever here not matter there no module able build. if no - can see module has reddish cross against , when build there not module. if go project>structure see info in sreen shot. i have gone around in circles , not getting anywhere. have tried things have found on stack overflow , else without luck. there info on gitignore, not have, not sure why should effect loss of module. if re-create whole directory on mac or on , open in android studio works perfectly! any help or pointers on doing w...

swift - Surprising optional unwrapped in if conditional -

swift - Surprising optional unwrapped in if conditional - trying wrap head around if expected behavior: while refactoring code had form: let opt:int? = 9 if allow unwrapped = opt { if unwrapped > 5 { println("yes") // prints yes } } i wanted eliminate nested if statements. using more compact form such worked expected: if (opt ?? 0) > 5 { println("yes") // prints yes } yet surprised direct comparing optional seemed disclose optional in conditional: if opt > 5 { println("yes") // prints yes } i tested other types , had same behavior. apple's documentation, checking if optional equal nil discussed, yet, did not expect evaluate wrapped value. did miss (and expected) or unsupported behavior of optionals? sure seems much easier way combine conditionals optionals. greg one of definitions of > operator is: func ><t : _comparable>(lhs: t?, rhs: t?) -> bool it seems co...

jquery - Can't display dynamic content with Ajax in my rails project -

jquery - Can't display dynamic content with Ajax in my rails project - i doing simple app , trying implement ajax when creating new task. trying render partial contain new task's info , append existing table, maintain getting next error: post http://localhost:3000/projects/4/tasks 500 (internal server error) here task create form # app/view/tasks/_create_task.html.erb <div class="row"> <div class="col-md-5"> <%=form_for [@project, @task], remote: true |f| %> <div class="form-group"> <%=f.label :task_name %> <%=f.text_field :task_name, class: "form-control"%> </div> <div class="form-group"> <%=f.label :deadline %> <%=date_select :task, :deadline, class: "form-control" %> </div> <%=f.submit "create task", class: ...

java - Wildfly 8.0.1 jboss-as:deploy just hangs -

java - Wildfly 8.0.1 jboss-as:deploy just hangs - i new wildfly , struggling utilize maven command mvn clean install jboss-as:deploy deploy 1 of quick starts jboss tutorial. i can deploy quick start jboss developer studio when seek utilize command prompt following: nothing happens after this. before changes standalone.xml <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/> <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9999}"/> i need point me in direction because seems service listening on port 9999 not responding maven's commands. java eclipse maven jboss

android - HTTPResponse handling invalid content type -

android - HTTPResponse handling invalid content type - i have below code : httpget httpget = new httpget(params[0] + params[1]); httpget.setheader("content-type", "application/json"); httpget.setheader("accept", "application/json"); httpresponse = httpclient.execute(httpget); if (httpresponse != null) { // } as can see content-type application/json. but receive content-type text/html, need check if response application/json process.we can have equalsignorecase check looking improve solution. android json http httpresponse content-type

java - Removing Objects (Account) from an ArrayList -

java - Removing Objects (Account) from an ArrayList - public boolean removeaccount (string accountnumber) { int index = 0; boolean found = false; while (index < accounts.size() && !found) { if ( accounts.get(index).getaccountnumber().equals(accountnumber)) { found = true; accounts.remove(accountnumber); } else index++; } if (found == true) { homecoming true; } else homecoming false; } when come in right business relationship number returns true, doesn't remove business relationship arraylist, help appreciated :) there two remove methods arraylist . 1 takes index, , other takes object remove itself. have supplied business relationship number, not index or business relationship itself. business relationship number not in list, business relationship is, business relationship number not removed. you have index, supply instea...

Cannot start SQL Server Agent (Version 2014 enterprise core)? -

Cannot start SQL Server Agent (Version 2014 enterprise core)? - the sql server agent log file has next information. set firewall inbound 1433. 2014-11-04 11:59:43 - ? [100] microsoft sqlserveragent version 12.0.2000.8 (x64 unicode retail build) : process id 6108 2014-11-04 11:59:43 - ? [495] sql server agent startup service business relationship ...... 2014-11-04 11:59:43 - ! [150] sql server not take connection (error: 0). waiting sql server allow connections. operation attempted was: verify connection on start. 2014-11-04 11:59:43 - ! [000] unable connect server '(local)'; sqlserveragent cannot start 2014-11-04 11:59:43 - ! [298] sqlserver error: 27, registry info corrupt or missing. create sure provider installed , registered correctly. [sqlstate 08001] 2014-11-04 11:59:43 - ! [298] sqlserver error: 27, client unable found connection [sqlstate 08001] 2014-11-04 11:59:43 - ! [165] odbc error: 0, network-related or instance-s...

c# - ISet that notifies on add and remove? -

c# - ISet<T> that notifies on add and remove? - i'd iset<t> 2 additional events itemadded , itemremoved . one alternative considered deriving myhashset<t> hashset<t> since add , remove not virtual, require utilize of new . maybe valid utilize of keyword? another alternative thought implement iset<t> , delegate private instance of hashset<t> . feels bulky solution. is there pattern or framework class gets me same result doesn't require less elegant/ideal coding? your own reply demonstrates how can wrap hashset<t> , srikanth's reply demonstrates how can derive hashset<t> . however, when derive hashset<t> have create sure new class correctly implements add , remove methods of icollection<t> interface. have modified srikanth's reply create iset<t> implementation notifications derives hashset<t> using explicit interface implementation of relevant methods of icoll...

C programming, error: called object is not a function or function pointer -

C programming, error: called object is not a function or function pointer - i trying write programme implements pop , force functions. problem is, trying pass pointer points integer top function, integer keeps changing, when seek compile line: **error: called object not function or function pointer (*t)-- #include<stdio.h> #include<stdlib.h> #define max 10 int push(int stac[], int *v, int *t) { if((*t) == max-1) { return(0); } else { (*t)++; stac[*t] = *v; homecoming *v; } } int pop(int stac[], int *t) { int poped; if((*t) == -1) { return(0); } else { poped = stac[*t] (*t)--; homecoming poped; } } int main() { int stack[max]; int value; int choice; int decision; int top; top = -1; do{ printf("enter 1 force value\n"); printf("enter 2 pop value\n"); printf("enter 3 exit\n"); scanf("%d", &choice); if(choice == 1) { printf(...

javascript - html Form not recognized in my jsp page -

javascript - html Form not recognized in my jsp page - i have jsp page included in main page..within jsp page, have given htmlform want submit() 1 time user clicks using jquery? <form id="orderbean1" name="myform" action="/auto/item" method="post"> <input id="filename" name="filename" value="" /> </form> first, suprisingly, form not recognized within page.. when give $('#orderbean1') in console not give form object whereas $('#filename') gives me filename input element. second , form not recognized not submitted... $("#vehreport").click(function(e) { e.preventdefault();(i have given stmt after submit() , still not working... $("#orderbean1").submit(); alert("formsubmnittted"); }) question - why doesn't form element recognized in page? i set jsbin here. as can see, #or...

ios - Detect Time Out Error With AFNetworking -

ios - Detect Time Out Error With AFNetworking - i utilize afnetworking retrieve info web service every thing work perfectly, want observe time out error. used code in failure block of request don't work failure:^(afhttprequestoperation *operation, nserror *error) { if ([operation.response statuscode] == 408) { //time out error here } }]; the code 408 normaly time out error since afnetworking build on top on nsulconnection/nsulrsession can nsurlerrortimedout check if error timeout error: failure:^(afhttprequestoperation *operation, nserror *error) { if (error.code == nsurlerrortimedout) { //time out error here } }]; you checking http status code, since connection timed out there not statuscode. ios objective-c timeout afnetworking

telnetlib - How to read telnet sessions with python -

telnetlib - How to read telnet sessions with python - aloha, i'm creating teamspeakbot , want write , read telnet session created teamspeak3 server import telnetlib tn = telnetlib.telnet('localhost', 10011, 10) tn.read_all() what i'm expecting: connected localhost escape character '^]'. ts3 welcome teamspeak 3 serverquery interface, type "help" li... but instead time out after 10 seconds: traceback (most recent phone call last): file "<stdin>", line 1, in <module> file "/usr/lib/python2.7/telnetlib.py", line 325, in read_all self.fill_rawq() file "/usr/lib/python2.7/telnetlib.py", line 516, in fill_rawq buf = self.sock.recv(50) socket.timeout: timed out how can read all stuff telnet connection tells me , later write stuff (like login proces , submit commands , response ...) the solution is tn.read_very_eager() my code looks this: import telnetlib, time tn = telnetli...

c# - Is it possible to write a unit test for the method that has, 1)Return type void, 2)access specifier private or protected? -

c# - Is it possible to write a unit test for the method that has, 1)Return type void, 2)access specifier private or protected? - is possible write nunit framework unit test class have method void homecoming type , access specifier protected or private in classic asp.net. allow me clear because im beginner in unit testing. update:this void function in case means, how can write unit test this? public void function(textbox txtbox, string result) { if (result.trim().tostring() == "&nbsp;") { txtbox.text = ""; } else { txtbox.text = result; } } i think you're asking 2 questions: is possible write nunit framework unit test class have method void homecoming type? possible, in way have know went fine during execution of method. example, if throws exception, test failed, otherwise considered succeeded. furthermore, can...

javascript - How can I export a string from a file and require() the exported string on another file in NODE.js? -

javascript - How can I export a string from a file and require() the exported string on another file in NODE.js? - my directory construction this: class="lang-none prettyprint-override"> collegesapp ├── node_modules │ ├── express │ ├── connect │ ├── jade │ └── passport ├── routes │ └── routes.js ├── views │ ├── index.jade │ └── signin.jade ├── app.js └── package.json class="lang-js prettyprint-override"> exports.serialized_user = serialized_user; //in app.js file *the variable serialized_user returns "alex" var serialized_user = require('../app.js').serialized_user; //in routes.js file so, when add together console.log(typeof(serialized_user)) routes.js file , run application, end seeing undefined in console instead of "string" , when add together console.log(serialized_user) routes.js file , run application, end seeing nil in console instead of "alex" . what think problem? gi...

php - Joining the parent table to its child and get the data from it -

php - Joining the parent table to its child and get the data from it - i have 2 database. parentsub , childsub parentsub |id|component_name|weight|actualweight 1 0 0 2 b 0 0 3 c 0 0 4 d 0 0 5 e 0 0 6 f 0 0 childsub |parent_id|category_name|weight|actualweight 1 aa 0 0 2 aaa 0 0 3 aaaa 0 0 4 bb 0 0 5 bbb 0 0 6 cc 0 0 7 ccc 0 0 8 dd 0 0 9 ee 0 0 10 ff 0 0 as can see above childsub have column called parent_id in situation. want column called component_name , after childs info must under in parentsub. this. how can childsub under specific co...

gzip - How to post gzipped data to CouchDB? -

gzip - How to post gzipped data to CouchDB? - as of version 1.6.0, couchdb can take gzipped json request bodies. posting bunch of json files via browser, , beingness able compress them save lot of bandwidth. how create ajax post of gzipped json docs couchdb? two steps: compress json files. send ajax request content-encoding: gzip header. for step 1 can utilize js library. few examples: js-deflate gzip-js pako for step 2, using xmlhttprequest can do xhr.setrequestheader("content-encoding", "gzip"); or using jquery, add headers: {"content-encoding": "gzip"} to ajax settings. couchdb gzip

ios - How do I tell if an NSURLSessionDataTask serves its response from a cache? -

ios - How do I tell if an NSURLSessionDataTask serves its response from a cache? - how can tell if nsurlsessiondatatask has satisfied request cache, rather going on network? (i don't think should matter, i'm creating task via default [nsurlsession sharedsession] , not setting custom nsurlcache instances.) ios nsurlsession nsurlcache

Install4j Mac OSx signing -

Install4j Mac OSx signing - i signed single bundle installer app mac (.dmg) using developer id application certificate .p12 key file. no complain install4j 5.1.12 during build , asks me password , outputs application signed. creating media file 'mac os x single bundle': collecting files: compiling launchers: compiling launcher 'mytestapp': generating vm options file vmoptions.txt. creating media file: zipping custom code & resources jar file identifying components adding jre (macosx-amd64-1.7.0_65) shrinking runtime compressing files applying lzma compression generating vm options file vmoptions.txt. signing installer moving media files media directory c:\.. installer\installer\build name of media file mytestapp.dmg. size of media file 34.4 mb when hosted application iis webserver client downloads , tries install gets error mac gate keeper application not safe , not allow install. when codesign -dv...

sql - cascading copy with merge statement causing lock issues -

sql - cascading copy with merge statement causing lock issues - sql server 2012 (sp1) 64gb ram using 50gb max server memory sp_configure 'locks' = 0 trace flags 1211 & 1224 off using read_committed set lock_timeout 0 while using merge error: the instance of sql server database engine cannot obtain lock resource @ time. rerun statement when there fewer active users. inquire database administrator check lock , memory configuration instance, or check long-running transactions. too many developers experiencing ongoing problems merge, how else can efficiently cascading re-create of rows , related rows parent/child tables. e.g. tablea has many tableb rows , tablec has many tabled rows etc... merge useful when creating new identity values, while on same row keeping old identity info next table insert, there alternatives? using single table insert output command, cannot old , new id @ same time insert tablea output inserted.[id],inserted.[col1],inser...

c# - Bind List to DataGridView -

c# - Bind List<class> to DataGridView - i need help on how bind list datagridview. tried utilize bindinglist<t> still not display records in gridview. tried using list<t> , still not work. below code used: public partial class form1 : form { public form1() { initializecomponent(); } private void form1_load(object sender, eventargs e) { toolclientcontroller ctrl = new toolclientcontroller(); ipaddresstextbox.text = ctrl.getipv4config(); portnumbertextbox.text = ctrl.getportnumber(); } private void browsebutton_click(object sender, eventargs e) { dialogresult result = openfiledialog1.showdialog(); if (result == dialogresult.ok) { toolmsgfiletextbox.text = openfiledialog1.filename; } } private void uploadbutton_click(object sender, eventargs e) { if (string.isnullorwhitespace(toolmsgfiletextbox.text)) { filetyp...

xpath - PHP DOMXPath works with double quotes fails with single quotes -

xpath - PHP DOMXPath works with double quotes fails with single quotes - i wrote little script extracts info web site using php's domxpath class. query <div class="sku" /> , execute substring-before on result. result contains text, non breaking spaces, line break , more text. i'm trying cutting before &nbsp;&nbsp;\r\n . works fine when utilize next query: $query = "substring-before(//div[@class='sku'],'\xc2\xa0\xc2\xa0\r\n')"; but fails alter quotes (which shouldn't create difference): $query = 'substring-before(//div[@class="sku"],"\xc2\xa0\xc2\xa0\r\n")'; or $query = 'substring-before(//div[@class=\'sku\'],\'\xc2\xa0\xc2\xa0\r\n\')'; how possible , how can overcome this? live illustration here: http://codepad.viper-7.com/r1rcaj the style of quotes makes difference because when string enclosed in double-quotes php interpret more es...

javascript - Count Amount of Colored Squares in Canvas -

javascript - Count Amount of Colored Squares in Canvas - here fiddle: http://jsfiddle.net/sw31uokt/ here of relevant code incrementvalue function set count overall clicks within canvas element. what able display count of each color, "you have placed 14 reddish pixels, 3 bluish pixels, 4 black pixels'. function incrementvalue() { var value = parseint(document.getelementbyid('number').value, 10); value = isnan(value) ? 0 : value; value++; document.getelementbyid('number').value = value; } $(c_canvas).click(function(evt) { var pos = getnearestsquare(getmousepos(c_canvas, evt)); if (pos != null) { context.fillstyle=(currentcolor); context.fillrect(pos.x,pos.y,19,19); incrementvalue(); } }); basically, marke said above ... in outer scope, add together 2 new vars : var palette = ["333333", "0000ff", "a0522d", "46ad42", "808080", "ffc0cb", "d73952", "...

backbone.js - My Backbone view got very big almost 1k lines and 30 events -

backbone.js - My Backbone view got very big almost 1k lines and 30 events - my view got big 1k lines , 30 events.should brake in smaller sub views? want improve readability , performance. yes should brake in smaller sub views. although not necessary improve performance improve readability. please maintain in mind views presentation , not business logic. backbone.js

finder - greyed-out folders on OSX with wrong date -

finder - greyed-out folders on OSX with wrong date - had backup fail due powerfulness hit. running on osx10.9 win server (xendata lto). widows can see folder fine, though date 1984. mac sees folder greyed-out, "get info" says folder created in 1984. microsoft technet forum sees same issue (finder issue), offers no solution. folder hidden? how unhide can delete it, can re-run backup? if windows can see folder - can access , utilize it? pull out contents using windows, create new folder / new re-create of contents , resave it. osx finder

.htaccess - asp htaccess 301 redirect -

.htaccess - asp htaccess 301 redirect - i'm trying redirect 3 pages reason, doens't seem work. site built asp <ifmodule mod_rewrite.c> # create sure directory listing disabled options +followsymlinks -indexes rewriteengine on # re-write pdfs requests not pre-pended /pdf/ i.e. in root - prepend /pdf/ - utilize negative look-ahead - if file doesn't exist 500 though sadly. rewritecond %{request_uri} ^/(?!pdf/)(.*)\.(pdf)$ rewritecond %{document_root}/pdf/$1 -f rewriterule ^(.*)$ /pdf/$1 [l] # if uri not in /images,/pdf,/css, or /js allow handler process rewritecond %{request_uri} !^(/images/|/pdf/|/css/|/js/) rewritecond %{request_filename} !handler.php rewriterule ^(.*)$ handler.php/$1 [l] # if uri in above directories file doesn't exist run through handler rewritecond %{request_uri} ^(/images/|/pdf/|/css/|/js/) rewritecond %{request_filename} !-f rewriterule ^(.*)$ handler.php/$1 [l] # ...

MySQL Error Code 1452. Altering table to add foreign key -

MySQL Error Code 1452. Altering table to add foreign key - i removed foreign key constraints add together info in, later altered tables add together foreign keys in. however, 1 particular table thats beingness altered, maintain getting 1452 error code back. data insert invoice values (323, 'head injury patient', 'surgery , bed stay', 150.00, 918), (543, 'eye injury patient', 'medicine , hourly eye drops', 50.00, 910), (859, 'leg injury patient', 'surgery , bed stay', 100.00, 915); adding foreign key alter table invoice add together foreign key(medicine_id) references medicine(medicine_id); construction of invoice create table invoice ( invoice_id int, invoice_description varchar(150), treatment varchar (150) not null, hospital_cost int not null, medicine_id int, primary key(invoice_id) ); construction of medicine create table medicine ( medicine_id int, medicine_name varchar(150), medicine_cost int not n...

php - How does Fuel CMS update the database through Simple Modules? -

php - How does Fuel CMS update the database through Simple Modules? - i have simple module called 'tradeusers' in fuel cms/codeigniter install. lists trade users on site tradeusers table in db. this means client able update info on tradeusers cms such business relationship number etc. however, want them able update password user. stored md5 salt (please no sha1 debate). the password field editable in cms not encrypt md5 when changed. there way can create fuel cms/codeigniter utilize md5 field? i know fields in form_fields function in model simple module can't see function puts info database. i don't want create advanced module of part ready. so you're looking hash plaintext password stores md5 in tradeusers record? in tradeusers model running md5 on value before saves. http://docs.getfuelcms.com/general/models#hooks php mysql codeigniter fuelcms

c# - Difference between unicast and multicast probe request -

c# - Difference between unicast and multicast probe request - i working on ws-discovery implementation project. when go through documentation ws-discovery, found that, probe message of 2 types. 1 unicast probe message , other multicast. new ws-discovery. didn't more info difference between unicast , multicast probe requests. need clarify uncertainty that, xml info unicast , multicast probe requests same? also @ receiving side, can know whether probe unicast or multicast? c# wcf ws-discovery

Android Twitter Fabric SDK conflict with Google GSON -

Android Twitter Fabric SDK conflict with Google GSON - i'm having difficulties integrating twitter fabric sdk app. followed steps of twitter tutorial , everyhting went fine when seek build project gradle, error : error:execution failed task ':app:dexdebug'. > com.android.ide.common.internal.loggederrorexception: failed run command: d:\android\android-studio\sdk\build-tools\android-4.4w\dx.bat --dex --output ... error code: 2 output: unexpected top-level exception: com.android.dex.dexexception: multiple dex files define lcom/google/gson/jsonserializer; @ com.android.dx.merge.dexmerger.readsortabletypes(dexmerger.java:594) @ com.android.dx.merge.dexmerger.getsortedtypes(dexmerger.java:552) @ com.android.dx.merge.dexmerger.mergeclassdefs(dexmerger.java:533) @ com.android.dx.merge.dexmerger.mergedexes(dexmerger.java:170) @ com.android.dx.merge.dexmerger.merge(dexmerger.java:188) @ com.android.dx.command.dexer.main.mergelibrarydexbuffers(main...

c# - Using Entity Framework, should I use RETURN or SELECT in my stored procedures? -

c# - Using Entity Framework, should I use RETURN or SELECT in my stored procedures? - i trying utilize stored procedures entity framework , encountering problem homecoming type. the homecoming type of stored procedure bit. here code (simplified) of stored procedure : create procedure [dbo].[sp_makestuff] @id int begin declare @status bit begin seek begin transaction delete mytable id = @id set @status = 1 commit end seek begin grab set @status = 0 rollback end grab homecoming @status end end i added sp_makestuff in .edmx file homecoming type bool?. then, seek execute code below using (var ctx = new myentities()) { objectresult<bool?> result = ctx.sp_makestuff(id); if (result.firstordefault().value) { // stuff } } however, raises exception of type system.data.entitycommandexecutionexc...

caching - Cache bits per row and total length -

caching - Cache bits per row and total length - if have a 32bit address , cache size(c) 8 kb , block size(b) 16 b , set associativity(a) 1 its direct mapped cache bits per line in cache? including dirty bit , validity bit. total no of lines in cache? some thought got via searching on net is offset bits = log b = 4 bits index bits = log c/b * 1024 = 9 bits tag bits = 32 - offset - index = 19 bits validity , dirty have 1, 1 bit still confused how calculate size of cache or how many lines cache have? your net search gave right answer. block size of 16 bytes -> need 4 bits specify offset within block. 8k byte cache , 16 byte lines -> 512 blocks. (8k / 16 = 512) direct mapped cache -> 512 / 1 way set associativity = 512 sets 512 sets -> need 9 bits index (512 = 2^9) with 32 bit address, if 4 bits used block offset , 9 index means remaining 19 bits needed tag. since direct map cache, no bits needed replacement policy (...

javascript - AngularJS Error with multiple controllers and Grunt -

javascript - AngularJS Error with multiple controllers and Grunt - unable multiple controllers work grunt. grunt not issue though, combining files manually not work either. trying build application grunt , single controllers 1 per file build out application on time. the controllers in individual files combined , minified grunt. works, , module looks right before minified. unminified illustration in script.js. i getting error below: error: error:unpr unknown provider 'use strict'; angular.module('ontariodarts', []); // source: app/modules/events/eventcontroller.js angular.module('ontariodarts').controller('eventctrl', function ($scope) { $scope.events = [ { 'id': 1, 'name': '12th annual frank hanlon tournament', 'date': 20150117, 'time': 1000, 'image': 'images/events/frankhanlon20150128.jpg', 'f...

Getting error while running directfb example in vaware ubuntu with 32 bit system -

Getting error while running directfb example in vaware ubuntu with 32 bit system - while running df_andi illustration getting output can ayone tell me why getting this. (*) direct/thread: started 'sighandler' (9163) [critical - other/0] <8392704>... ~~~~~~~~~~~~~~~~~~~~~~~~~~| directfb 1.7.1 |~~~~~~~~~~~~~~~~~~~~~~~~~~ (c) 2012-2013 directfb integrated media gmbh (c) 2001-2013 world wide directfb open source community (c) 2000-2004 convergence (integrated media) gmbh ---------------------------------------------------------------- (*) directfb/core: single application core. (2014-10-17 10:53) (*) direct/thread: started 'fusion dispatch' (9164) [messaging - other/0] <8392704>... (!!!) *** 1 time [joystick sends js_event_init events, create sure has been calibrated using 'jscal -c' ] *** [joystick.c:103 in joystick_handle_event()] (*) direct/thread: started 'joystick input' (9165) [input - oth...