Posts

Showing posts from January, 2011

android - Dynamic Menu item no show Icon -

i mount navigationview dynamically this: @override protected void onpostcreate(bundle savedinstancestate) { //nvdrawer mount menu menu = nvdrawer.getmenu(); (mymenuitem kmi : menus.values()) { menu.add(kmi.gettext()); menuitem mi = menu.getitem(menu.size() - 1); mi.settitle(kmi.gettext()); drawable dicon = getresources().getdrawable(getresources() .getidentifier(s tring.valueof(kmi.geticonid()), "drawable", getpackagename())); mi.seticon(dicon); } } so, debug , dicon setted, icon there appears in running app. every menus appears, none icon appears, silver rectangles. p.s: icons png images. i'm waiting. dimmy, if you're running code on android 3.0+, icons in menu not shown design. design decision google. you can read more below on android developers blog. hope helps. http://andr

EXCEL 2010 VBA copying graphs -

so confused on how excel copy/ paste works. have code copies 1 graph picture , paste's in new sheet. worksheets(redemp).chartobjects("chart 6").copypicture pasterow = pasterow + 24 worksheets("print").cells(pasterow, 2).select worksheets("print").paste if run macro manually works of time (with multiple excel files opened) if run macro via vb script , no other excel file open works of time. if run macro via vb script , excel file open code works 20% of time , 80% of time 'run time error 1004: paste paste method of worksheet class failed i did quite bit of research have not found solution yet. appreciated. code private sub changeandcopy() 'changes company in "debt redemption sheet" , copy/paste's (info , redemption tables , chart) new sheet 'create variables sheet names dim redemp, auxil, pdf string redemp = "debt redemptions profile" auxil = "aux

c++ - Qt signal argument thread safety -

suppose have signal sendimage(const qimage&) connected slot updatelabel(const qimage&) in other thread, convert qimage qpixmap place in qlabel. i'm wondering, if use function const qimage& prepareimage() argument of signal e.g. emit sendimage(prepareimage()) , , signal emitted dozens of times per seconds, thread safe or there possibility race condition occurs between prepareimage , updatelabel both accessing image @ same time crashing program? thankfully, qt protects , copy image don't shoot in foot. copying done upon signal's emission, , done inside of implementation of signal - here, copying done when object::source on call stack. given qimage implicitly shared, initial copy cheap, if main thread modifies source image, force deep copy. if modifications such source discarded, it'll more efficient replace source image new 1 instead of "modifying" it. output: data @ 0x7fff5fbffbf8 in main thread qthread(0x10250a700) 0x7fff5fb

excel vba - Scope using AdvancedSearch method for entire mailbox -

so new dasl queries, , have been scouring web trying find out how use them correctly. trying through outlook folders mail items matching parameters, , save attachment... pretty simple. i am, unfortunately having issue code, don't know how reference scope go through folders, custom folders. below code (i realize of statements wrong), appreciated. have performed due diligence these problems, can't find resources answer question, why i'm posting here. answers or references answers appreciated. sub testing() dim myolapp new outlook.application dim scope string dim filter string dim rsts results dim advancedsearch outlook.search blnsearchcomp = false 'i want search entire mail account including normal folders inbox , sent custom folders. 'but doesn't work. ideas? scope = "'fakeexample123@outlook.com'" 'filter assignment statement has been excluded set advancedsearch = myolapp.advancedsearch(scope, filter, true, "test")

arrays - Read a large CSV File and storing the content in C language -

i learning c programming , got stuck 1 code. want read , store large csv file of around 10000 rows , 5 columns, each coloumn having names time, time_diff, sn,rs, fr. i wrote code it. wanted read different columns, used strtok function read line , store in different variables. read file , print content on screen. not getting how store contents in array. i tried make array of structures , store values in these array, somehow not working. used random value of int variable i, check if works or not. can please explain how store different variables in array , how call them back. if want print sn[1000], how store it. following code: #include <stdio.h> #include <stdlib.h> #include <string.h> #define buffer_size 1024*1024 struct filedata { char *time; int time_diff; int sn; int rs; int fr; }; struct filedata data[10000]; int main () { //char buffer [buffer_size]; char *buffer; file *fp; char *token; int filesize; int

ios - How can I implement a callback before UISegmentedControl change to a new segment? -

working uisegmentedcontrol want present warning before select index. problem action uicontroleventvaluechanged called after new segment has been selected. how can implement callback before uisegmentedcontrol changes segment , decide if should change? you can sort of ' trick ' control grabbing selectedsegmentindex value , setting controls selectedsegmentindex value -1, selection being deferred. a basic example 2 segments - - (ibaction)segmentedindexdidchange:(uisegmentedcontrol*)sender { // grab segment index value , store nsinteger indextoquery = sender.selectedsegmentindex; // deselect segments while making decisions sender.selectedsegmentindex = -1; // have willchange scenario instead of didchange switch (indextoquery) { case 0: { nslog(@"seg index change 0"); //.. stuff .. make decisions .. etc. break; } case 1: { nslog(@"seg inde

python - Can numpy argsort handle ties? -

this question has answer here: how make argsort result random between equal values? 2 answers i have numpy array: foo = array([3, 1, 4, 0, 1, 0]) i want top 3 items. calling foo.argsort()[::-1][:3] returns array([2, 0, 4]) notice values foo[1] , foo[4] equal, numpy.argsort() handles tie returning index of item appears last in array; i.e. index 4. for application can't have tie breaking bias end of array, how can implement random tie break? is, half time array([2, 0, 4]) , , other half array([2, 0, 1]) . here's 1 approach: use numpy.unique both sort array , remove duplicate items. pass return_inverse argument indices sorted array give values of original array. then, can of indices of tied items finding indices of inverse array values equal index unique array item. for example: foo = array([3, 1, 4, 0, 1, 0]) foo_unique, foo_in

api - Twitter Oauth authorization code -

i building rest api. registering user, needs authenticate on twitter. normally, use authorization code provided oauth2 server seems twitter not implement type of authorization. don't want mobile app send twitter token api register user. see security flaw. i checked oauth echo ( https://dev.twitter.com/oauth/echo ) seems okay. user passes credentials api, , api checks user against twitter api. twitter returns user object. not return access token though. is way this? help. yes correct. using oauth echo use third party individual without exposing access token/key , credentials. just aware you're under different rate limit twitter's api when you're going through route. in cases it's increase in limit while it's decrease in other.

netbeans single java file not running -

i trying fetch data db. below code trying run reason when try run file, netbeans notification says application deployed still file not running. think missing silly thing cant figure out.. need help! class getdbdata { private final string jdbc_driver = "com.mysql.jdbc.driver"; private final string db_url = "jdbc:mysql://localhost:3306/test"; private final string user = "root"; private final string pass = ""; connection conn; statement stmt; resultset rs; public void getdbdata() throws sqlexception, classnotfoundexception { class.forname("com.mysql.jdbc.driver"); conn = drivermanager.getconnection(db_url, user, pass); stmt = conn.createstatement(); } public string[] getavailablemeasuremu() throws sqlexception { string sql; sql = "select * availablemeasures incentive=mu"; rs = stmt.executequery(sql); string x = null; vector data = new vector(); while (rs.next()) { data.add(

javascript - Making parts of page not scrollable and making scroll-then-fixed to work on body larger then 100% -

i'm complete noob in javascript i'm copying things internet portfolio project have semester , i'm stuck thing not working var elementposition = $('#header_nav').offset(); $(window).scroll(function () { if ($(window).scrolltop() > elementposition.top) { $('#header_nav').css('position', 'fixed').css('top', '0'); } else { $('#header_nav').css('position', 'static'); } }); when page 100% wide piece of code worked charm have different ideas webpage now, decided stretch it's 300% width of browser window. , centered header , sections in middle of 300% looks this: http://postimg.org/image/g7m9hj425/full/ i've managed disable middle mouse button scroll piece of code: $('body').mousedown(function(e){if(e.button==1)return false}); but, still can't make scroll-then-fixed thing work. thanks in advance, hope have been clear enough :) have t

bigdata - Group by time AND another dimension in R (xts matrix)? -

i trying use apply.daily/weekly/monthly functions xts in r, need have apply function work on subsets @ time. example, x=xts(data.frame(value=1:100,code=rep(1:5,20)), seq(as.date('2011-01-01'),by=1,length.out=100)) step 1: i'd roll-up week , "code", i'd have like row 1: week = week 1, code = 1, sum(all entries have code of 1 fall in week 1) row 2: week = week 1, code = 2, sum(all entries have code of 2 fall in week 1) ... row 70: week = week 10, code = 1, sum(all entries have code of 1 fall in week 10) step 2: i'd same number of rows each week, because want matrix--one row per code , 1 column per week. i'd prefer not create separate week variables first answer suggests because i'm going need cut again month, day, hour, minute, , maybe custom time duration. i'm happy bypass first step, because that's intermediate output. unfortunately in real data can't subset manually because have 10,000+ "codes"

mongodb - deserialize on each request? is this not needless db reads? -

understanding passport serialize deserialize in cobbling first node app array of guides , posts have stumbled across serialize , deserialize passport functions... i kind of understand functionality.. doesn't seem right. http://toon.io/understanding-passportjs-authentication-flow/ : passport.deserializeuser invoked on every request passport.session. enables load additional user information on every request. user object attached request req.user making accessible in our request handling. this means every single request runs db request retrieve user object? app not require db request aquire full userobject on every single request.. in fact cannot think of app require this.. thus, if register serialize function , not deserialize function.. best practice stop passport assigning entire user object/mongo doc session whilst @ same time reducing db read count per page/api request? passport.session middleware calls deserialize function, better strategy str

php - Clip Path coordinates programmatically -

Image
i've paths , clip these paths specific region (green) resulting in remaining paths (red): what best way/approach commonly manually cutting paths? choose suitable line-clipping algorithm . i've used liang–barsky one. (wiki page so-so, try find better description)

php - FOSRest bundle remove trailing s on routes -

i have issue fosrest bundle , using symfony 2. problem fosrest adds trailing s post routes. i have function in accountbundle\settings controller public function postaccountsettingsaction() { // } now when debug routes shows me post accounts/settings.{_format} my routing looks following settings_v1: type: rest resource: "........\controller\settingscontroller" prefix: /v1 name_prefix: v1_ settings_v2: type: rest resource: "........\controller\settingscontroller" prefix: /v2 name_prefix: v2_ i don’t want have accounts/settings want account/settings question: possible rid of trailing s ? i don't think it's possible configure globally. there pull request on repository of project add functionality hasn't been merged yet. you can still define own url on controller, loose automatic route generation : /** * @post("/account/settings") */ public function postacco

ios - How to add a plus button in a navigation bar when the edit button is pressed? -

i writing simple app tableview controller. view has navigation bar, , has edit button. add plus button in top left corner when content being edited , edit button has been pressed. i added button using following prewritten code: // uncomment following line display edit button in navigation bar //this view controller. self.navigationitem.rightbarbuttonitem = self.editbuttonitem() i don't know if there method called when edit button created pressed, think solve problem created add plus button in method. override setediting:animated: on view controller. it'll called everytime editing state changes. make sure call super first.

How to atomically update multiple kv entries with consul? -

let's assume have following key value pairs imported consul: curl -x put -d 'val1' http://localhost:8500/v1/kv/stuff/key1 curl -x put -d 'val2' http://localhost:8500/v1/kv/stuff/key2 curl -x put -d 'val3' http://localhost:8500/v1/kv/stuff/key3 i possible atomically update them together? the reason asking use consule configuration management , not won't depending key value pairs partially updated , in inconsistent state. it's not possible right now. there's open github issue tracks this.

hibernate - Envers RevisionEntity can not be saved with Metadata -

i have application written in play framework hibernate. want add versioning envers library. i have user class. @entity @audited(withmodifiedflag=true) public class user a controller change things user. @transactional public static result updateaccountstates(long userid) { user user = jpa.em().find(user.class, userid); integer prevstatus = user.status; form<accountstateform> form = form.form(accountstateform.class).bindfromrequest(); form.get().applyto(user); return redirect(routes.customers.account(userid)); } i want add metadata changed users data. @entity @revisionentity(userrevisionlistener.class) public class userrevisionentity extends defaultrevisionentity { @manytoone public staff staff; } public class userrevisionlistener implements revisionlistener { @override public void newrevision(object revisionentity) { userrevisionentity userentity = (userrevisionentity) revisionentity; userentity = securityutils

c# - WebApi Unit Test HttpContextHelper with Mock -

i have method i'm trying mock (moq) unit testing i'm having difficulty props read , mocking fails sealed class. method hung off controller , have infrastructure in place. first here method i'm trying test. public carresponse(common.models.car car) { string currentaccepttype = httpcontexthelper.current.request.headers["accept"]; ....removed brevity..... } i have tried inject instantiated object , work headers read can't see how set headers want?? httprequest cv = new httprequest(null, "http://localhost:24244", "/cars/_services/addnewpickup"); //so far when want add headers every property read only. cv.headers.add("qewr", "adsf"); //this fails. msdn ultimately using part of larger fake "session" testing. httpcontext.current = new httpcontext(cv, new httpresponse(null)); mocking of httprequest fails sealed class. so i'm kinda stumped on how test unit of code.

xslt 2.0 - How to store the input xml data in to map using XSLT2.0 -

i'm tring store input xml data map , how save data. input xml: <person> <value id="123"> <name>abc</name> <age>25</age> </value> <value id="456"> <name>xyz</name> <age>80</age> </value> <value id="1235"> <name>abcfg</name> <age>25</age> </value> <value id="4568"> <name>xyzd</name> <age>80</age> </value> </person> output file: xyzd|80 abcfg|25 is there way possible store data map object , print data output? given input xml, <person> <value id="123"> <name>abc</name> <age>25</age> </value> <value id="456"> <name>xyz</name> <age>80</age> </value>

python - Multiple Try/Except blocks -

i have multiple try/except blocks in program analyzing dictionary input module. use try/except (eafp) check if key in input (otherwise, want raise error). i wondering if there more general approach. instead of try: xyz = a['some_key'] except: print_error("key 'some_key' not defined") dozens of times, if there way like try: xyz = a['some_key'] xyz2 = a['some_key2'] ... except: print_error("the key(s) not included some_key, some_key2") borked_keys = set() key in list_of_keys_needed: try: xyz = a[key] except keyerror: borked_keys.add(key) #python3 variant print("the following keys missing:", ",".join(borked_keys)) #or, suggested jonrsharpe if borked_keys: raise keyerror(",".join(str(i) in borked_keys)) #python 2 variant print "the following keys missing: " + ",".join(borked_keys) #or if borked_keys: raise keyerror "

c# - cannot implicitlyconvert type<SubMenu> to SubMenu -

i'm trying select records contenttypeid this code i'm trying use public actionresult loaddata(int contenttypeid) { list<productcontent> productcontentlist = (from pc in db.productcontents pc.contenttypeid == contenttypeid select pc).tolist(); viewbag.productcontents = productcontentlist; submenu submenu = (from sm in db.submenulist sm.contenttypeid == contenttypeid select sm); submenuitem submenuitemlist = (from smi in db.submenuitems smi.contenttypeid == contenttypeid select smi); assuming db.submenulist collection of submenu , when this: from sm in db.submenulist sm.contenttypeid == contenttypeid select sm you not selecting single record (even if there 1 subm

Python, Sympy: nfloat() > switch to degrees -

i'm looking way, use sympy.nfloat calculate degrees instead of radians. is there function, turn whole result automatically degreeish calculation? so nfloat("asin(sin(5))") => 5 (5 or can tell me, how add deg() around every number in string automated? like: sin(5+7+119) => sin(deg(5)+deg(7)+deg(119))

android - Why is `PRIORITY_BALANCED_POWER_ACCURACY` consuming more battery than `PRIORITY_HIGH_ACCURACY`? -

Image
we benchmarked amount of battery spent device on requesting location every 10 minutes, solely connected wifi, under same circumstances post factory reset same starting battery levels no apps installed with priority first set priority_balanced_power_accuracy , priority_high_accuracy . and surprisingly, former used same, if not more battery latter. here graph of battery usage: could please explain behaviour? priority_high_accuracy more use gps, , priority_balanced_power_accuracy more use wifi & cell tower positioning. priority_balanced_power_accuracy (~100m "block" accuracy) priority_high_accuracy (accurate possible @ expense of battery life) use setinterval(long) , setfastestinterval(long) saving battery life. example: private static final long interval = 60 * 1000; private static final long fastest_interval = 5 * 1000; private static final long displacement = 100; private locationrequest createlocationrequest(){ l

Javascript: Is This Truly Signed Integer Division -

given following code, both a , b number s representing values within range of signed 32-bit signed integers: var quotient = ((a|0) / (b|0))|0; and assuming runtime in full compliance ecmascript 6 specifications, value of quotient always correct signed integer division of a , b integers? in other words, proper method achieve true signed integer division in javascript equivalent machine instruction? i'm no expert on floating-point numbers, wikipedia says doubles have 52 bits of precision. logically, seems 52 bits should enough reliably approximate integer division of 32-bit integers. dividing minimum , maximum 32-bit signed ints, -2147483648 / 2147483647 , produces -1.0000000004656613 , still reasonable amount of significant digits. same goes inverse, 2147483647 / -2147483648 , produces -0.9999999995343387 . an exception division zero , mentioned in comment. linked question states, integer division 0 throws sort of error, whereas floating-point coercion r

hibernate - one to one mapping using primary key join column -

i have employee , employee detail classes mapped (bi directional) using primary key join column (employee_id) @entity @table(name="employee") public class employee { @id @generatedvalue @column(name="employee_id") private long employeeid; @column(name="firstname") private string firstname; @column(name="lastname") private string lastname; @column(name="birth_date") @temporal(value = temporaltype.date ) private date birthdate; @column(name="cell_phone") private string cellphone; @onetoone(mappedby="empl", cascade=cascadetype.all) private employeedetail employeedetail; ... } @table(name="employeedetail") public class employeedetail { @id @column(name="employee_id", unique=true, nullable=false) @generatedvalue(generator="gen") @genericgenerator(name="gen", strategy="foreign", parameters=@parameter(name="property", value="empl")) pri

javascript - Display only four elements in a row in table using jsp -

i generating checkboxes in row dynamically want display 4 checkboxes in row , in next row. tried code couldn't achieve goal. please me out <c:foreach var="group" items="${actionbean.roles}" varstatus="loop"> <table> <tr> <td><s:checkbox name="category1" id="category${loop.index}" class="category" onclick="onchangecheckbox(this,id)" checked="false"></s:checkbox> <b> <s:label for="${group}" /> </b></td> </tr> <tr> <c:foreach var="item" items="${actionbean.activityroles}"> <c:if test="${not empty actionbean.activityroles && item.label == group }"> <td width="25%"><s:checkbox name="category11" value="${item.id}" class="category

ios - MVVM with ReactiveCocoa, how does ViewModel tell View to do some one time operation? -

for example, want view show toast, way i'm doing like: in view: racobserve(self.viewmodel, showtoast) subscribenext:^(nsnumber *isshow) { if (isshow.boolvalue) { self showtoast]; } } showtoast property of viewmodel, don't think way descriptive, there more standard, more elegant way achieve this? to give more descriptive, create racsubject manually send notifications using [self.toastssubject sendnext:@"toast info string of kind"] . @weakify(self) [self.viewmodel.toastssubject subscribenext:^(id _) { @strongify(self) [self showtoast]; } even better, have showtoast take single argument (such content of toast), don't need use @weakify , @strongify , instead lift signal directly using rac_liftselector . [self rac_liftselector:@selector(showtoast:) withsignals:self.viewmodel.toastssubject, nil];

Javascript load a random image -

i want create javascript function load random image when function da_image called. want image load onto canvas have set up. there clear error in code? nothing displaying. var images = [ "http://circlesfordialogue.com/wp-content/uploads/2014/12/laura-let%c2%b4s-circle-up-2014-12-08.jpg", "http://mathworld.wolfram.com/images/eps-gif/concentriccircles_1000.gif", "http://www.charlespetzold.com/blog/2012/12/beziercirclefigure3.png" ]; function da_image(){ var file = images[0]; var reader = new filereader(); reader.onload = function(){ var img = new image(); img.src = reader.result; img.onerror = function(){ reset_canvas(); o.font = '30px sans-serif' o.fillt

mysql - Impala regex to find "2", but not "255", in pipe-delimited list -

i originally asked help finding values in pipe-delimited list values must include 4 or 5 , never 2 or 3 . however, accepted solution returns value 255 itself. i have data set pipe delimited values can either 0 , 1 , 2 , 3 , 4 0r 255 , such this: | cola | ____________ | 1|1|0|255 | | 5|4|4|2 | | 5|4|4|3 | | 5|4|4|4 | | 1|0|0|0 | | 0|2|0|1|2 | | 5|5|0|5 | | 0|5 | | 5|5|255|255| | 0|3|1|2|3 | | 5|5|5|2|3|3| | 0|2|0|0|0|2| | 5|255|1|1|5| | 4|255|4 | | 2|2|3 | | 255|0 | | 5 | | 5|5|1 | i need query return rows include value of 4 or 5 , never 2 or 3 . | cola | ____________ | 5|4|4|3 | | 5|4|4|4 | | 5|5|0|5 | | 0|5 | | 5|5|255|255| | 5|255|1|1|5| | 4|255|4 | | 5 | | 5|5|1 | the closest i've come query: select clin.clin_sig clinvar clin (clin_sig not regexp '3|2[^5]' , clin_sig regexp '4|[^25]5') but it's missing following entries, wonky: 5

sql server - SELECT DISTINCT creates multiple rows -

complete sql newbie please kind. have following statement: select distinct ttmpo."operationrecordid" , ttmpo."casenotenumber" , ttmpo."datetimebooked" , tspps."startdate" , aeadm."visit date" , aeadm."visit time" , aeadm."episode number" , aeadm.[visit number] (("theatrelive"."dbo"."tblspplannedsession" tspps left outer join "theatrelive"."dbo"."tbltmplannedoperation" ttmpo on tspps."sessionrecordid" = ttmpo."sessionrecordid") left outer join "theatrelive"."dbo"."tbltmactualoperation" ttmao on ttmpo."operationrecordid" = ttmao."operationrecordid") left outer join "theatrelive"."dbo"."cavaeadmissions" aeadm on ttmao."casenotenumber"=aeadm."crn" collate database_default tspp

windows - Escaping everything in batch files -

i've got list of commands (generated nmake , obtained using event tracing) want run. obvious way put them in batch file. works fine simple commands, 1 of them turned out following: c:\windows\system32\cmd.exe /c %i in (..\..\bin\*) @for %j in ("%~ni.exe: $(srcdir)/bin/%~ni" " $(echo) generating $(@)" " $(q) copy /y /b $(stubprogram) $(@) > nul" " $(q) echo.>>$(@)" " $(q) echo.>>$(@)" " $(q) copy /b $(@)+$(srcdir:/=\)\bin\%~ni $(@) > nul" "" ) @echo.%~j>>scriptbin.mk which cmd barfed on: the following usage of path operator in batch-parameter substitution invalid: %~ni.exe: $(srcdir)/bin/%~ni" " $(echo) generating $(@)" " $(q) copy /y /b $(stubprogram) $(@) > nul" " $(q) echo.>>$(@)" " $(q) echo.>>$(@)" " $(q) copy /b $(@)+$(srcdir:/=\)\bin\%~ni $(@) > nul" "" ) @echo.%~j

Asset Pipeline simple images do not work in Rails 4.2 -

i have image: sample.png . have verified image. i put in app/assets/images . i reference in view with: image_tag "sample.png" it refuses work. created new directory public/assets/images . still doesn't work. this needlessly complex. how can see actual image in view? please note have read of asset pipeline documentation already. the url being generated is: /images/sample.png actually, image_tag "sample.png" returns link like <img alt="sample" src="/assets/sample.png"> i think running app in production mode, need compile assets bundle exec rake assets:precompile rails_env=production after command , image generate in root_path/public/assets/sample.png hope works :)

python - How to use Tornado.gen.coroutine in TCP Server? -

i write tcp server tornado. here code: #! /usr/bin/env python #coding=utf-8 tornado.tcpserver import tcpserver tornado.ioloop import ioloop tornado.gen import * class tcpconnection(object): def __init__(self,stream,address): self._stream=stream self._address=address self._stream.set_close_callback(self.on_close) self.send_messages() def send_messages(self): self.send_message(b'hello \n') print("next") self.read_message() self.send_message(b'world \n') self.read_message() def read_message(self): self._stream.read_until(b'\n',self.handle_message) def handle_message(self,data): print(data) def send_message(self,data): self._stream.write(data) def on_close(self): print("the monitored %d has left",self._address) class monitorserver(tcpserver): def handle_stream(self,stream,address): print(&q

php - Set a timeout for both connect and read in file_get_contents -

prerequisites cluster server i have server runs number of virtual "cluster nodes". basically, each 1 of them public, minimal http server, has 2 functions: 127.0.0.1:xxxxn/ping 127.0.0.1:xxxxn/api/arg/arg/arg both of functions return 200ok header followed html. ping used test if node busy or not. if node n busy, connection time out (because node busy handling request). however, if node responsive , available, ping return ping=node.free calling server i want write php program can loaded on webserver expose better interface api. following code older api version had 1 node per ip, code quite simple: <?php error_reporting(0); ini_set('display_errors', 0); echo file_get_contents("http://127.0.0.1:xxxx9/".$_request['script']."/".$_request['query']."/".$_request['sort']."/".$_request['num']); ?> this was, of course, called like http://server.org/api.php?script=

Why the layout is changed when html newsletter sent to recipient? -

my email html code, when sent via mailchimp layers destroyed , different normal. i've used table format still it's not working. i've used basic mailchimp teplate. nothing working. here attached code: <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta property="og:title" content="*|mc:subject|*" /> <title>title</title> <style type="text/css"> body{margin:0;padding:0;font-family: 'libre baskerville', serif;}.main{width:600px;margin:0 auto;display:block;overflow:hidden;}img{width:100%}.logo{background:url(img/logo.png) center center no-repeat;min-height:100px;border-bottom:3px #7a7a7a solid}.logo p{margin-top:60px}.title h1{color:#ff4013;font-size:68px;margin-top:15px;text-align: center;margin-bottom:15px}.subtitle p{color:

In python, how do I make it so that I can have two programs read from a serial port? -

i have python program processes serial data comes in , sends data out. need separate python program monitors needs use same serial port other program, , not respond monitor. any idea how can this? unless missing something, not sure how make there 2 listeners same serial port.

python - Why does sympy.diff not differentiate sympy polynomials as expected? -

i trying figure out why sympy.diff not differentiate sympy polynomials expected. normally, sympy.diff works fine if symbolic variable defined , polynomial not defined using sympy.poly . however, if function defined using sympy.poly , sympy.diff not seem compute derivative. below code sample shows mean: import sympy sy # define symbolic variables x = sy.symbol('x') y = sy.symbol('y') # define function without using sy.poly f1 = x + 1 # define function using sy.poly f2 = sy.poly(x + 1, x, domain='qq') # compute derivatives , return results df1 = sy.diff(f1,x) df2 = sy.diff(f2,x) print('f1: ',f1) print('f2: ',f2) print('df1: ',df1) print('df2: ',df2) this prints following results: f1: x + 1 f2: poly(x + 1, x, domain='qq') df1: 1 df2: derivative(poly(x + 1, x, domain='qq'), x) why sympy.diff not know how differentiate sympy.poly version of polynomial? there way differentiate sympy p

Postgresql error when running rails Server -

so, i'm learning how code pulling repository account. however, when try run rails s error: pg::connectionbad - fatal: password authentication failed user "postgres" fatal: password authentication failed user "postgres" i have clean install of postgresql , can't figure out do. in advance. ahhh... turns out i've put in wrong port number. responding 1 specified in database.yml. port 5432 , changed 3000 , worked.

Rails collection_select form adds selected value to an array -

i have rails 4 app game database. models relevant question are: game genre gamegenre (the relationship table) it has games/new form, creates new game records. within form, want sub-form allows user add genres. envision working follows: the user selects genre select input. options populated genre.all when user hits add button, id of selected genre pushed array. can add many genres want array. when user hits save on main game form, app uses add_genre function i've defined create gamegenre relationship records each of genres. this games/new.html.erb view code @ present: <div id="game-genres-form"> <%= fields_for(@game.game_genres.build) |f| %> <div><%= hidden_field_tag :game_id, @game.id %></div> <div class="form-group"> <%= f.label :genre_id, "add genre" %> <div class="input-group"> <%= f.collection_select :genre_id, genre.all, :id, :name

Laravel and CORS with barryvdh/laravel-cors -

i'm having odd problem cors in laravel i've struggled on day now. it's different other posts i've seen laravel-cors package such one: laravel angularjs cors using barryvdh/laravel-cors i've setup package according instructions, , other addition laravel i've made package jwt. what happening cors working in post requests. can use postman hit authenticate route , looks good, try request no cors headers being sent. i've tried moving different controllers 'unprotected' routes remove possibility jwt interfering doesn't change anything. here routes.php: <?php // unprotected routes route::group(['prefix' => 'api/v1', 'middleware' => 'cors'], function () { route::post('authenticate', 'authenticatecontroller@authenticate'); route::resource('trips', 'tripcontroller'); // moved unprotected test cors }); // protected routes route::group(['prefix' => 'a

Twitter-bootstrap-rails gem in windows 7 issue -

i trying use twitter-bootstrail-rails gem style devise sign in pages , custom pages. have followed screencasts , included required gem (gem 'twitter-bootstrap-rails' gem 'therubyracer', :platform => :ruby # gem 'therubyracer', '~> 0.10.2'#therubyracer gem 'libv8', '3.16.14.3' gem 'less-rails')in gem file. on windows 7. all gems installed installed when navigate http://localhost:3000/users/sign_up or page, getting error.kindly me resolve issue struck long time.. cannot load such file -- v8 (in c:/sites/konavsa/app/assets/stylesheets/bootstrap_and_overrides.css.less) extracted source (around line #6): konavsa <%= stylesheet_link_tag "application", :media => "all" %> <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> <meta name="viewport" content="width=device-width, initial-scale=1.0"> try this: gem

ios - How to get the object from a dictionary for a key that is an NSObject? -

likely there posts dealing issue, i'm not able find want... i've nsmutabledictionary keys subclass of nsobject<nscopying> . i'm finding objectforkey: not working, i'm getting nil if use same key object i've used calling setobject:forkey: . what best way handle should be? when call setobject:forkey: key copied, dictionary doesn't key object itself. that's why getting nil when call objectforkey: . you need implement -(bool)isequal:(id)anobject .

r - change labels in legend for ggplot2 -

i have time series data , want plot x vs y , color (gradient) datetime converting datetime numeric, problem takes numeric value in legend well. date x y 2012-01-01 14:25:00 461.2339 15.83793 2012-01-01 14:30:00 459.8557 15.80326 here code ggplot(test1_data,aes(x , y ,colour = as.numeric(date))) + geom_point() + scale_colour_gradientn(colours=rev(rainbow(6))) is there way edit legends show actual datetime? you need use breaks , labels . here's example. you'll need change format suit actual data. library("ggplot2") test1_data <- read.csv(text = "date,x,y 2012-01-01 14:25:00,461.2339,15.83793 2012-01-01 14:30:00,459.8557,15.80326", header = true, colclasses = c("posixct", rep("numeric", 2))) date_breaks <- diff(range(test1_data$date)) * 0:4 / 4 + min(test1_data$date) date_labels <- format(date_breaks, "%h:%m:%s") ggplo

html5 canvas - Fabric JS resize group -

Image
i have canvas few group. in group 2 text , line, wanna resize selected line using input text. have input text, , when select group in input text height, change value text field , resize group/object have problems "border" element allows me resize , rotate object. when set selectedobject.set({height: 300}); border resizing, scaledobject.item(0).set({height: 300}); line without border, when put resized border not around object, how can resize object correctly using input text? i have solution group has figure , text, did maintain text size , border width well. var canvas = new fabric.canvas("c1"); reinit() canvas.on({ 'object:scaling': function(e) { var obj = e.target, w = obj.width * obj.scalex, h = obj.height * obj.scaley, s = obj.strokewidth; console.log(obj.width, obj.scalex, h,w,s) obj._objects[0].set({ 'height'

accessibility - If spacebar opens dropdowns across all browsers, why is my onchange triggered menu considered inaccessible -

background: windows users on chrome , ie, dropdowns reload or change page no accessibility. user presses down arrow button, page reloads. means user can access first menu option. here example: http://html.cita.illinois.edu/script/onchange/onchange-example.php this covered in wcag rule: “changing setting of user interface component not automatically cause change of context unless user has been advised of behavior before using component. (level a)” except user can open dropdown , explore options without triggering onchange event. user space bar press. commonly known keyboard trick i've seen tested users aware of or able figure out quickly. in system, using dropdown pagination in long directories. eg: "you on page [1^] of 16" (with [1^] being browser default dropdown menu). designers not allow kind of visual [go] button. happens across thousands of pages, javascript fixes i've seen need account every dropdown, , impossible on our case. using space bar, use