Posts

Showing posts from May, 2013

reactjs - How to create helper file full of functions in react native? -

though there similar question failing create file multiple functions. not sure if method outdated or not rn evolving fast. how create global helper function in react native? i new react native. what want create js file full of many reusable functions , import in components , call there. what have been doing far might stupid know ask here are. i tried creating class name chandu , export this 'use strict'; import react, { component } 'react'; import { appregistry, text, textinput, view } 'react-native'; export default class chandu extends component { constructor(props){ super(props); this.papoy = { : 'aaa' }, this.hellobandu = function(){ console.log('hello bandu'); }, } hellochandu(){ console.log('hello chandu'); } } and import in required component. import chandu './chandu'; and call console.log(chandu); console.log(chandu.hellochandu); console.log(chan

python - Registering SIGINT/SIGQUIT signals in a Django application served in Docker -

i've got django application queue system (that builds releases various developers) needs completed. however, towards end of day, need shut down running builds should not terminated. achieve this, thought can catch termination signals (like sigint/sigquit/sigterm) application can wait releases complete , shut system down then. i have following signal registering system: import time, sys, signal def signal_handler(signum, frame): print('waiting releases complete') time.sleep(5) print('terminating gracefully...') sys.exit(0) sig in [signal.sigterm, signal.sigint, signal.sigquit]: signal.signal(sig, signal_handler) when run django's development server command line code snippet, registers signal , trigger handler function. problem application runs on docker nginx , uwsgi in place. when run container, registers signal when stop docker container, sigint/sigquit signal caught uwsgi, not python , signal handler not triggered. i'm rel

web services - How can I make the url configurable in the ksoap Android-studio? -

i want configurable url , , user can change running application public string namespace ="http://tempuri.org/"; public string url; // **how can make url configurable** public int timeout = 60000; public iwsdl2codeevents eventhandler; public soapprotocolversion soapversion; i try session variable , external file, , sqlite when trying call process , tell parameter method , give value url extracting database , application stops. this geturl public string geturl() { string url = null; sqlitehelper sql = new sqlitehelper(voceo.this, "servicioweb", null, 1); sqlitedatabase bd = sql.getwritabledatabase(); cursor fila = bd.rawquery(" select url direcciones idurl= 0", null); if (fila.movetofirst()) { url = fila.getstring(0); } bd.close(); return url; } and when try call him public vectorstring obtenerpuertas(list<headerproperty> headers){ soapserializationenvelope soapenvelope = new soaps

java - Cobertura shows 0% coverage for instrumented WAR in Tomcat -

we bunch of automated testing against deployed java web application (in addition unit testing) , track code coverage of these tests. app written in java , runs on tomcat. use cobertura track coverage our unit tests i’d stick cobertura. i’ve instrumented our war , able generate reports coberura.ser file show 0% coverage. here steps i’m following: build jar , war in normal process (no instrumenting). our application classes packaged jar file placed in lib director of war deploy. unpack both jar , war rebuild again time instrument classes. copy instrumented classes in unpacked jar directory. i’m doing because instrumenting not seem output class files things not have runnable code (like interfaces). build jar unpacked jar directory add new instrumented jar , cobertura.jar lib directory of unpacked war directory , build war that. add new instrumented war , coberturaflush.war tomcat webapps directory add cobertura.ser (that generated during instrumentation) tomcat bin di

android - Force main activity to show every time app is loaded -

i want main activity show every time after home screen pressed , app opened again. my layout is: main screen --> menu page --> sub menu i want able use button go sub menu menu page. however, regardless of page on when home screen pressed want show main screen when app reopened. have tried onfinish() in java class menupage. causes return button close app because previous activity finished. have researched how can detect if home button pressed finish activity way seems that's not option. know way around this? to control presses, can direct each activity or fragment go wherever on press overriding backpress event. @override public void onbackpressed() { // } to handle backpress , state fragments, advisable manage stack. providing proper navigation i use custom home button on apps when want user able go straight main activity. public void gohome() { startactivity(new intent(this, mainactivity.class)); } edit this part of original answer,

c# - Why does Resharper offer to "Remove Unreachable Code" here? -

inspecting project i've inherited resharper, first suggested wrap this: if (cellrng != null) ...around code, cellrng acted on if it's not null. after doing that, tells me "if block" code not reachable, anyway. here code in context: if (cellrng != null) { cellrng.font.bold = true; cellrng.value2 = ave.tostring(cultureinfo.invariantculture); cellrng.numberformat = "##0.00"; cellrng.horizontalalignment = xlhalign.xlhaligncenter; . . . } how can code both reference possibly null object (cellrng) , then, after check implemented, turn out null (code runs if not null considered unreachable)? in second line below, resharper offers remove code, saying, "expression null" cellrng = _xlsheet5.cells[rowidx, colcnt] range; if (cellrng != null) but how that? how range assigned cellrng seen null? the code in if block following code above tagged resharper "code heuristically unreachable" what czech!?!?!

api - Official way to fetch the number of tweets for a URL -

twitter has private endpoints one: http://urls.api.twitter.com/1/urls/count.json tweet counts can fetched here, not recommended twitter. besides, keep saying gonna shut down these endpoints in near future. the site streams api in closed beta, don't accept applications. https://dev.twitter.com/streaming/sitestreams so leaves 1 option, rest api, don't see endpoint there return number of tweets given url. what's best way data? there "official" endpoint this? or way use public stream api or rest api search endpoints , filter results? the private endpoint shut down 20 nov , there'll nothing replace it. this blog post twitter explains background: apparently it's move new "real-time, multi-tenant distributed database" system codenamed manhattan. the rest api of limited use purpose. you'd have search url, collect each page of results , add total number of tweets yourself. example request https://api.twitter.com/1.1/sea

loops - how to iterate on every second element in java -

i tried work out couldn't. i need implement class implements iterator , takes iterator constructor parameter, 1)need return every 2nd hasnext 2)need return every 2nd next element basically trying make use of given iterator received constructor, when use next element on hasnext increasing iterator 1 element. problem comes when independently access hasnext or next element , not pass test cases. solution or idea on this template , expected implementation looks below: public class alternateiterator<t> implements iterator<t> public alternateiterator(iterator<t> target) public boolean hasnext() { boolean returnvalue = false; if(iterator.hasnext()) { iterator.next(); returnvalue = iterator.hasnext(); } return returnvalue; } @override public t next() { t object = null; if(iterator.hasnext()) { object = iterator.next();

How to add MomentJS to an Aurelia application -

i've got app , i'm trying import momentjs use valueconverting. i've gone package.json file , added following jspm dependencies: "moment": "npm:moment@^2.14.1" but when try import file, doesn't find module: import moment '../moment'; i'm trying import in file that's 1 directory deep src folder. so, file in src/folder/file.ts how import moment? the thing should have import package add dependencies on package.json file , run build, correct? you shouldn't manually editing package.json file unless absolutely necessary. should use jspm install moment moment installed. adding lines package.json file doesn't accomplish anything. but you've added line package.json , , line added correct, need run jspm install code moment can pulled down , put in project. next, import moment, you'll need this: import moment 'moment'; now you'll have moment() function ready use in code.

sql server - SSAS Dimension relationship -

Image
i have 2 dimension. one manufacturer other supplier. have fact table. need query sales amount using supplier code, want see relation between supplier , manufacturer against sales amount. can done. is there possibilities can achieved without adding supplier key fact. please help!!! you cannot query sales amount using supplier code because manufacturer(int)|amount($) pair doesn't uniquely identify supplier.

haskell - Yesod accessing a persistent entity id from hamlet -

i have persistent pulling list of products database , displaying them on screen. use id database store information these products in cookie , link more detailed information pages. understand id present in persistent entity , not in actual product type? mean should store additional field random string can use in cookie or there way access id used in database? adding cookies using javascript. up until have used php , use id. i'm not sure if same in yesod because of type safety or if there best practice way this. if want id of record entity inside handler like: (entity key _) <- rundb $ getby ... a query not use id values(eg: get) return entity contains both id , values. see: http://www.yesodweb.com/book/persistent#persistent_fetching_by_unique_constraint you can see getby returns (entity personid person) wrapped in maybe works selectlist

c# - EF 6: Removing entities results in empty objects -

i have confusing situation occurring on database. reasons can't determine, whenever remove item dbset held dbcontext (called datarepository ), 3 more "empty" items of same type added. here's code teacher entity (it inherit user , , use tpt inheritance handle that). public class teacher : user { public string title { get; set; } public string email { get; set; } public virtual department department { get; set; } public virtual list<class> classes { get; set; } public virtual list<booking> bookings { get; set; } public teacher() { department = new department(); internalbookings = new list<booking>(); classes = new list<class>(); access = accessmode.teacher; title = string.empty; email = string.empty; } } similarly, department entity. public class department { public string name { get; set; } public virtual list<teacher> teachers {

php - Correct data structure Laravel -

Image
i have structure example: in example, can see possible bind multiple users, 1 book or more. problem expierincing follows: there's 1 main owner of book. users bind afterwards need have permissions, edit, delete etcetera. correct way of dealing in structure providing? need store permissions in pivot table user_book, or have seperate table? here abstract idea: the book table may contain field owner owner_id (or user_id ) in case can create one-to-one relationship book , it's owner. method relationship in book model might like: public function owner() { // book belongs 1 owner (user) return $this->belongsto('app\user', 'owner_id', 'id'); } so, $book->owner return owner/user owns book. owner_id needs set when creating book. reverse relation one-to-many in user model need create books method example: public function books() { // user has many books return $this->hasmany('app\book', 'own

How to prevent Rails controller from hanging when making a web service call -

i have rails controller i'm calling when user loads specific page. controller makes call 3rd party web service. however, when web service down, rails controller hangs. i'm not able navigate page, log out, or refresh page...all of these tasks wait web service call complete before being executed. in event web service call never completes, have restart rails app in order functional again. is there standard way of preventing happening? using faraday gem make web service calls. suppose set timeout value when making web service call. however, ideally user action of navigating page halt web service call immediately. possible? i believe happening because using rack web implementation can handle 1 request @ time. unicorn event driven. node. should think fixing first timeout. if using faraday, can req.options.timeout = 5 have timeout. then recommend using puma. if that's not option, should adjust server settings allow more 1 connection @ time. unicorn, bel

stored procedures - I want to generate random date in SQL Server -

can please tell me want generate 100 random dates table: create table dates (dt date) this code ok want put below code in loop generate 100 random dates select dateadd(second, (rand() * 60 + 1), dateadd(minute, (rand() * 60 + 1), dateadd(day, (rand() * 365 + 1), dateadd(year, -1, getdate()) or other simple code generate random date give me if can. thanks praviin here example: select top 100 dateadd(ss, cast(abs(checksum(newid())) int), '19000101') rnddate master..spt_values fiddle http://sqlfiddle.com/#!3/9eecb7/6049 for predefined range: with cte as(select row_number() over(order number) % 366 r master..spt_values) select top 100 dateadd(dd, r, '20141231') cte order newid() r contain values 1 366. adding '20141231' give values desired range.

c# - Multiple queries in async/await (Error: IEnumerable does not contain ToListAsync()) -

i share went through other similar posts suggested solutions din't work me , that's why creating separate thread.i trying join 2 results using asynchronous programming in entity framework.i have 3 methods below: the method preprocessappointment() waits on other 2 methods getappttask() , getzonetask() public async void preprocessappointment() { var task_1 = getappttask(); var task_2 = getzonetask(); await task.whenall(task_1, task_2); } the method getappttask() not give error. public async task<ienumerable<appointments>> getappttask(){ var result = db.appointments.where(d => d.appt_client_id == 15 && d.customer_id == 68009); return await result.tolistasync(); } the method getzonetask() gives following error. ienumerable <zones> not contain definition tolistasync() . public async task <ienumerable<zones>> getzonetask() {

Jquery multidimensional array not working -

i'm trying multidimensional array in jquery. var exclude_array = {}; $(this).siblings("tr[data-id='" + id + "']").each(function() { var id = $(this).attr("data-id"); var item_id = $(this).children("td:eq(3)").find("input[name='exclude']").attr("data-item_id"); exclude_array[id][] = item_id; }); i error uncaught syntaxerror: unexpected token ] , exclude_array[id][] how solve? it seems you're trying push item_id exclude_array . array[] syntax not used in javascript. instead, must use .push() . before that, make sure key defined , array. if (exclude_array[id] === undefined) exclude_array[id] = []; exclude_array[id].push(item_id);

Facebook chat bot sending same message multiple times (Python) -

i working on facebook mini-chat bot , encountering problem consists on bot receive same message on , on though has answered message. it keeps receiving same text fb , replying on , over def message_handler(request): data = json.loads(request.body.decode('utf-8')) if data , data['object'] == 'page': pageentry in data['entry']: print "nombre de message", len(pageentry['messaging']) messagingevent in pageentry['messaging']: if messagingevent.get('optin'): print "optin", messagingevent receivedauthentication(messagingevent) elif messagingevent.get('message'): print "message", messagingevent receivedmessage(messagingevent) elif messagingevent.get('delivery'): print "delivery", messaging

trash - How to use intermediate result of Reads with another Reads -

the example have validating credit card number string. validations 1) issuer should exist credit card number, , 2) issuer should accepted 1 merchant. here's work have far. ideally, use intermediate result issuer first reads in next reads. there better way? reads.filter[string](validationerror("invalid issuer")) { cardnumber => findissuer(cardnumber).isdefined // option[issuer] } andthen reads.filter[string](validationerror("issuer not accepted")) { cardnumber => // issuer, check issuer accepted merchant } it's not direct answer, might consider write logic for/yield expression: val result: either[string, issuer] = { card <- json.validate[card].aseither.leftmap(_ => "reading error") issuer <- findissuer(card.number) //returns either[string, _] _ <- isaccepted(issuer) // returns either[string,_] } yield issuer p.s. it's gateway case start using scalaz validation .

php - How to retrieve data in mysql table column? -

in mysql table, i've table name: mental_illness there's 2 enum row inside : n , p it means negative , positive and here's php code retrieve data table: if ($history->getmentalillness()) { echo html::section(3, _("mental illness : ")); echo html::para(nl2br($history->getmentalillness())); } here's question : how use if else in above php code this: if mental illness p , show positive text , if mental illness n show negative text because code show p , n instead of negative , positive text. thank you just do: if ($history->getmentalillness()) { echo html::section(3, _("mental illness : ")); if($history->getmentalillness() == 'p'){ $mental_illness = "positive"; }else{ $mental_illness = "negative"; } echo html::para(nl2br($mental_illness)); } one more thing... why need nl2br in case... there no newlines in these 2 strings...

Need Python regex for all characters between double quotes after 'returned' -

i have error message response... <httperror 404 when requesting https://www.googleapis.com/bigquery/v2/projects/di-dtbqquery-us-poc-1/queries?alt=json returned "not found: table di-dtbqquery-us-poc-1:lab_auxiliary.antoniotes">` i need text between double quotes: "not found: table ry-us-poc-1:lab_aiary.antes" what correct regex characters between double quotes after returned bit in error message? have scoured stack overflow trying find specific regex , haven't had luck. can please give me hand? try this: .*returned "(?p<error_message>.*)"

Loop through a R matrix row-wise and print elements -

this question has answer here: how combine rows single row? [closed] 2 answers got basic r for-loop matrix question: my matrix looks this: 2 4 3 1 5 7 all want print these elements row wise , not column wise. answer should 2 4 3 1 5 7 . try result column wise i.e `2 1 4 5 3 7. since m beginning r wondering if can done for-loop loops column wise , not row-wise m <- matrix(c(2, 4, 3, 1, 5, 7), 2, 3, byrow=t) as.vector(m) or c(m[1, 1:3], m[2, 1:3])

arrays - HaxeFlixel: FlxSprite animation fails at runtime with Neko target -

i have date , i'm using haxeflixel experiment assets import , automation. i'm trying accomplish frames sprite sheet , automate add.animation process. example, need first row of sheet form run animation, second 1 animation etc... i use code class examplesprite extends flxsprite { public function new(x:float=0, y:float=0, ?simplegraphic:dynamic) { super(x, y, simplegraphic); loadgraphic(assetpaths.examplesprite__png, true, 16, 16); // work //animation.add("run", [0, 1, 2, 3, 4, 5], 10, true); // has problem when run neko var animationarray:array<int> = new array(); var i:int = 0; var frames_per_row:int = cast(pixels.width / 16, int); while (i < frames_per_row) { animationarray.push(0*frames_per_row + i); i++; } animation.add("run", animationarray, 10, true); animation.play("run"); } } i want calc

javascript - Html table with fixed header and fixed column both -

i need both fixed headers , fixed columns @ same time. i want have fixed headers (first row , first column) , scrollable table displaying @ given time. a left 1 containing header column a right 1 containing header row , table imp point: when data moves horizontally: fixed header(first row move accordingly) when data moves vertically: fixed column(first column move accordingly) this allow me scroll horizontaly without have header column moving, , scroll verticaly without having header row moving (by absolute positioning within parents guess ?). ps : have searched lot, found is, fixed headers or fixed first column. want both @ time. here fiddle contains fixed column, please me in adding fixed header(first row) in it. fiddle: http://jsfiddle.net/cfr94p3w/ html code: <div class="table-container"> <div class="headcol"> <table> <thead> <th>room</th> </the

java - How do i Access GoogleApiClient in Different Activities -

how access googleapiclient in different activities?how make global can used in activities can pass through intent ? no, can't pass via intent. if needs used across activities either need make new 1 each activity or need make owned service activities query results.

OpenGL (Python) - applying an STMap (UVmap) to an image? -

i have following code loads , displays (using pyqt) image on screen: gvshader = """ attribute vec4 position; attribute vec2 texture_coordinates; varying vec2 v_texture_coordinates; void main() { v_texture_coordinates = texture_coordinates; v_texture_coordinates.y = 1.0 - v_texture_coordinates.y; gl_position = position; }""" gfshader = """ uniform sampler2d texture1; uniform sampler2d texture2; varying vec2 v_texture_coordinates; void main() { gl_fragcolor = texture2d(texture1, texture2.rg); }""" class projectiveglviewer(qtopengl.qglwidget): def __init__(self, parent=none): super(projectiveglviewer, self).__init__(parent) def initializegl(self): vshader = qtopengl.qglshader(qtopengl.

php - Android Volley Post String and Get JSONArray -

how can post string php web server , jsonarray in response using volley library in android. following code in want response. how can post string , jsonarray in response using function see code if works jsonarrayrequest(method.post,config.view_profile_url, new response.listener<jsonarray>() { @override public void onresponse(jsonarray response) { //calling method parse json array parsedata(response); } }, new response.errorlistener() { @override public void onerrorresponse(volleyerror arg0) { // todo auto-generated method stub } }){ protected map<string, string> getparams() throws authfailureerror { map<string, string> params = new hashmap<>(); params.put(&q

navigation - Counting Menu Items of the SubMenu in Typo3 -

i'm trying create nav in typo3, , need know number of items in submenu of current menu. don't see possibity in achieving this. i know {register:count_menuitems}, doesn't help. in first level of nav need number of items of second level put class of list (4 in example) wrapitemandsub = <li class="dropdown mega-menu-4"> | </li> is worth trying or not possible? thanks :) example of nav: #testmenu4 lib.testmenu4 = hmenu lib.testmenu4 { entrylevel = 0 1 = tmenu 1 { expall = 1 wrap = <ul class="nav navbar-nav"> | </ul> noblur = 1 no = 1 no { wrapitemandsub = <li> | </li> stdwrap.htmlspecialchars = 1 atagtitle.field = title } ifsub = 1 ifsub { wrapitemandsub = <li class="dropdown mega-menu-4"> | </li> wrapitemandsub.insertdata = 1 stdwrap.htmlspecialchars = 1 atagtitle.field = title atagpar

Ruby on rails Stripe - set default amount to shopping cart subtotal -

i trying connect shopping cart stripe , set amount order subtotal of cart. tried defining order_subtotal in orders model , tried pass though amount field in stripe code following error when go through check out: invalid integer: order_subtotal i cant find online explains how connect amount varies stripe using ruby language. appreciated, thanks! charges_controller.rb class chargescontroller < applicationcontroller def new end def create # amount in cents @amount = :order_subtotal customer = stripe::customer.create( :email => params[:stripeemail], :source => params[:stripetoken] ) charge = stripe::charge.create( :customer => customer.id, :amount => :order_subtotal, :description => 'rails stripe customer', :currency => 'usd' ) rescue stripe::carderror => e flash[:error] = e.message redirect_to new_charge_path

mysql - Usage of capistranodb_ignore_tables and db_ignore_data_tables option -

i use capistrano-db-tasks . how skip table while running cap production db:pull task? ideally need way download production db without 1 table ( versions ). from documentation : # if want exclude table dump set :db_ignore_tables, [] # if want exclude table data (but not table schema) dump set :db_ignore_data_tables, [] i tried following (in config/deploy.rb ): set :db_ignore_tables, [:versions] set :db_ignore_data_tables, [:versions] but seem still download whole versions table data :(. any ideas appreciated! as occurred, db_ignore_data_tables not available mysql database, , postgresql. unfortunate fact. also, db_ignore_tables option not available gem release version, should specify want use github: gem 'capistrano-db-tasks', require: false, github: 'sgruhier/capistrano-db-tasks'

Why did Elasticsearch skip from version 2.4 to version 5.0? -

according release history, elastic search switched 2.4 5.0. https://en.wikipedia.org/wiki/elasticsearch#history unable find documentation online happened between version 2 , 5 makes difficult decide whether wise upgrade. to make clear versions of different tools work together. watch keynote of elastics if want hear shay banon explaining it: https://www.elastic.co/elasticon/conf/2016/sf/opening-keynote

python - aws boto3 attributes 100% missing values -

when create datasource via python script below, @ least 1 of attributes has 100% missing values. when manually create datasource via aws ml dashboard, , apply same attribute types, none of values missing. there problem how i'm creating datasource s3? file_names = [file_name_train, file_name_testing] client = boto3.client('machinelearning') schema_file = open('../selections/aws_schema.txt', 'r') schema = schema_file.read() file_name in file_names: response = client.create_data_source_from_s3( datasourceid=file_name+date, datasourcename=file_name+date, dataspec={ 'datalocations3': 's3://'+bucket_name+'/'+file_name+file_extension, 'dataschema': schema, }, computestatistics=true )

json - JavaScript Cannot set property of undefined -

i'm novice backend developer , i've been tasked adding react features , i'm totally out of depth. following code generates exception "cannot set property '1' of undefined". first element id:1 , name:"". don't think empty string has problem though since i've tried hardcoding string , same exception. payment_code: { label: 'payment code', value: 'payment_code', choices: adminsalesstore.paymentcodes.map((payment_code) => { console.log(payment_code); console.log(payment_code['id']); console.log(payment_code['name']); displaychoices.payment_code[payment_code['id']] = payment_code['name']; return { label: payment_code['id'], value: payment_code['name'] } }), type: 'choice' }, i don't understand error because payment_code['id'] , payment_code['name']

c# - DataAnnotations: read out the Name property in code -

i have decorated following enum display dataannotation attributes: public enum requiredoptions { [display(name="optional",description ="optional")] optional, [display(name="not used",description ="not used")] notused, [display(name="required",description ="required")] required } i'd read out name value of display attribute given enum value in code. how do this? public static string displayrequiredoptionname(requiredoptions opt) { // return value of name display attribute opt } well, after doing digging in mvc source code (see src\system.web.mvc\html\selectextensions.cs, see getdisplayname()), here's got work: public static string getenumdisplayname<t>(t enuminstance) { return getdisplayname(enuminstance.gettype().getfield(enuminstance.tostring())); } private static string getdisplayname(fieldinfo field) { displa

How to create html with JavaScript? Uncaught TypeError: Cannot set property 'innerHTML' of null -

i want create date/time under weeks, in columns this: mon tuesday...... and want in row shown date/time 9 until 5 pm. this: mon tuesday 09:00 09:30 . . . . i not sure doing wrong. have 2 arrays var days = [ 'monday', 'tuesday', 'wednesday', 'thursday', 'friday' ]; var hours = [ '09:00', '09:30', '10:00', '10:30', '11:00', '11:30', '12:00', '12:30', '13:00', '13:30', '14:00', '14:30', '15:00', '15:30', '16:00', '16:30', '17:00' ]; i made days shown inline next each other javascript, can't make work time: function createtable(roomname) { var table = ''; //for loop days (var = 0; < days.length; i++) { //checking if value monday if (i === 0) { table = table + '<div class="in

asp.net - POST request hangs at "pending" -

i have room , room contains 0 or more devices . have controller, roomcontroller . here's simplified version of controller: [responsetype(typeof(room))] public ihttpactionresult postroom(newroom newroom) { ... room room = new room(); room.building_id = newroom.building_id; ...and soforth... if(newroom.devices != null) { foreach (devicenew newdevice in newroom.devices) { device device = db.devices.firstordefault(d => d.id == newdevice.id); room.devices.add(device); } } db.savechanges(); return ok(room); } the controller works. room created, attached devices . sadly, post request never returns if there devices included in request. is, in chrome dev tools, request remains "pending" forever. if there aren't devices, request returns 200 , expected. again, controller works , devices included. records created. route doesn't return ok way should. am missing somethi

python - Show variable value by hovering mouse in Spyder -

is there way show variable value during debugging hovering mouse pointer on variable (like in visual studio)? a plugin? there some work try implement in past, unfortunately not finished. so not possible in spyder @ moment (july of 2017).

c - Target somehow doesn't get created -

i have target doesn't create it's immediate dependencies do. , there's not error message. here makefile: prefix?=/home/jenia/learn-c-the-hard-way cflags=-g -wall -i${prefix}/lib/include ldflags=-l${prefix}/lib install_dir=/home/jenia/learn-c-the-hard-way/apps all: set-manipulation set-manipulation: main.o install: install -d $(install_dir)/set-manipulation install set-manipulation $(install_dir)/set-manipulation clean: rm -f *.o rm -f set-manipulation rm -rf *.dsym i end main.o file not set-manipulation file name of program. like in bigger program want create object files first , program. like all: my-amazing-prog my-amazing-prog: a.o b.o c.o d.o ... and end files: a.o, b.o, c.o, d.o, my-amazing-prog so don't understand why i'm having trouble in case create both object.o files , prgram depends on them. p.s. just in case, here directory structure: /home/jenia/learn-c-the-hard-way/lib: drwxr-xr-x 2 jenia je

Javascript: Replacing items in array with another set of items -

i have app fetch data server , keep in array. when display want display paginated decided have 50 items per page. i want implement refresh functionality can refresh current viewed page. example, if i've loaded 3 pages already, means have 150 items in array, , refresh page 2 (which means fetch items 50-99 server) want replace current items new items. basically want remove items 50-99 in current array , insert "new" 50 items current array starting @ index 50. i tried doing with: // remove items items.splice((this.currentpage*50 -50), 50) // add new freshly grabbed items instead array.prototype.splice.apply( items, [(this.currentpage*50 -1), data.data.length].concat(data.data)); but seem work kinda buggy. if have 1 page loaded works expected. deletes of 50 items , replaces them new items. however, if have 2 pages loaded , try refresh page 1 can see current items array length 99 instead of 100. tried playing can't work :/ any idea how can efficien

angularjs - Using [] square brackets as part of a parameter in $resource GET call to API in Angular is not working -

i trying trying user data ajax-localized rest api wants parameters so: /api/activity?filter[user_id]=1 i have factory set query parameters so: angular.module('app') .factory('activity',function($resource){ return $resource(ajaxinfo.api_url+'activity', { // query parameters filter: { '[user_id]': '@userid' }, }, { 'query':{ method:'get', headers: { 'x-wp-nonce': ajaxinfo.nonce }, isarray: false } }); }) i'm console.logging in template so: $scope.userone = activity.query({userid:1}); console.log($scope.userone) it's returning http:site.dev/api/activity?filter=%7b%22%5buser_id%5d%22:%22@userid%22%7d&userid=1". any idea i'm doing wrong? here's did fix this: i created factory ca

machine learning - Multiple features into one using Pipeline and featureUnion from Python Scikit-learn -

i train , predict gender of person. have 2 features 'name' , 'randint' each coming different pandas column. trying 1) combine them pipeline/featureunion. 2) adding predicted label onto original pandas data frame. though getting error former objective 1): from sklearn.feature_extraction.text import countvectorizer sklearn.linear_model import logisticregressioncv sklearn.cross_validation import train_test_split sklearn.base import transformermixin import pandas pd sklearn.feature_extraction import dictvectorizer sklearn.pipeline import make_pipeline sklearn.pipeline import featureunion import numpy np clf = make_pipeline(countvectorizer(), logisticregressioncv(cv=2)) data = { 'bruce lee': 'male', 'bruce banner': 'male', 'peter parker': 'male', 'peter poker': 'male', 'peter springsteen': 'male', 'bruce willis': 'male', 'sarah mclaughlin&

java - invalid matchers when mocking -

i want test method : public void some_method(somefactory somefactory) { a = somefactory.populatewithparameter(parameter1, parameter2, parameter3, parameter4); a.method_call(); .... } the factory goes way public class somefactory(){ // constructor public populatewithparameter(someclass1 someclass1, someclass2 someclass2, string string, int parameter){ return new a(someclass1, someclass2, string, parameter) } } and test is public void testsomemethod() throws exception { somefactory somefactory = mock(somefactory.class); when(somefactory.populatewithparameter( any(someclass1.class), any(someclass2.class), anystring(), anyint())).thenreturn(notnull()); mainactivity.some_method(somefactory); ... } i message org.mockito.exceptions.misusing.invaliduseofmatchersexception: invalid use of argument matchers! 4 matchers expected, 1 recorded: you aren't allowed use notnull()