Posts

Showing posts from March, 2015

javascript - How to format code of react native in atom -

i working on react-native app. using atom text editor development of react-native apps. i did not find shortcut format react-native code in atom. tried beautify package https://atom.io/packages/atom-beautify not working. import react, { component } 'react'; import { appregistry, image, view, text, button, stylesheet } 'react-native'; class splashscreen extends component { render() { return ( < view style = { styles.container } > < image source = { require('./img/talk_people.png') } style = { { width: 300, height: 300 } } /> < text style = { { fontsize: 22, textalign: 'center', margintop: 30

c# - Now to serialise property of my custom class type as string? -

i tried implement getobjectdata iserializable, couldn't working - serialises cdata object. classes: public class cdata : ixmlserializable, iserializable { private string m_value; //... public override string tostring() { return m_value; } public void getobjectdata(serializationinfo info, streamingcontext context) { info.addvalue("", m_value); } } public class myclass { public cdata cdata { get; set; } } code: myclass myclass = new myclass { cdata = "asd"}; string o = jsonconvert.serializeobject(myclass); // returns {"cdata":{"":"asd"}}, want {"cdata":"asd"} update. looking solution can avoid changing myclass , because have hundreds of cdata usages , looks more hack rather proper solution. custom converter looks way go, have remember use custom converter when dealing classes has cdata properties. hoping there should simpler , nicer way of do

python - Raspberry Pi3 sampler using pygame.mixer -

i'm new python , raspberry. i'm making sampler raspberry. objective "play specific wave file when specific key pressed". i specify wave files, loop , gate attributes in xml file. code working there's lag between key pressed , sound. how can improve code ? pygame problem ? need use module pyglet or wave module ? thanks in advance answer , sorry bad english. here's code : def playsample(spl, snd, bool): if spl.get_loop() == "on": if spl.get_gate() == "on": #loop on, gate on snd.play(-1) else: #loop on, gate off bool = not bool if bool: snd.play(-1) else: snd.stop() elif spl.get_gate() == "on": #loop off, gate on snd.play() else: #loop off, gate off snd.stop() snd.play() return bool def stopsample(spl, snd): if spl.ge

xpath - Robot framework select variable from dropdown -

i trying select item dropdown list in robot framework (using ride), cannot item variable name. <div class="chosen-drop"> <div class="chosen-search"> <input type="text" autocomplete="off"> </div> <ul class="chosen-results"> <li class="active-result" data-option-array-index="0">geen optie gekozen</li> <li class="active-result" data-option-array-index="2">abb</li> <li class="active-result" data-option-array-index="3">algem</li> <li class="active-result" data-option-array-index="4">aov</li> <li class="active-result" data-option-array-index="5">aw</li> <li class="active-result" data-option-array-index="8">aoz</li> </ul> </div> i can

ios - Swift 3 - Rest Api HTTP Header Values are not being sent -

i'm trying build app swift, makes rest api call authorization header. code looks this: var request = urlrequest(url: url!) request.httpmethod = "get" request.addvalue("application/json", forhttpheaderfield: "content-type") request.addvalue("application/json", forhttpheaderfield: "accept") request.addvalue("username:password", forhttpheaderfield: "authorization") request.addvalue("de", forhttpheaderfield: "content-language") urlsession.shared.datatask(with: request) { (data, response, error) in ... ... my problem http header values somehow not being sent. verified requests values being set printing out request.allhttpheaderfields , response server still holds default values headers. not authorization header other header try change. it great if can find mistake... mean, simple piece of code, i'm confused went wrong.

mahapps.metro - How to change color of MetroTabItem -

i have metrotabcontrol , items added programmatically (i'm using prism) don't know how change color of tabitem header. how can that? i'm new mahapps.metro, should start learn in customization? styles - mahapps.metro take here : mahapps styles you can override default style of metrotabitem. here video of how accomplish style inheritance in wpf. here metrotabitem style : metrotabitem.xaml i suggest learn how create custom style in mahapps (the first point).

node.js - Nginx equivalent configuration in angular2 cli -

i new angular2. have been using nginx angular1. how configure these settings in angular2-cli proxy_set_header host $host; proxy_set_header x-real-ip $remote_addr; proxy_pass http://localhost:8080/cloudface/; proxy_cookie_path /cloudface/ /; there full guide available on official documentation explain need know deploy application on production server. there part dedicated nginx configuration. i advise take profit of angular-cli handling related bundling , optimizing , aot compilation .

Lua mqtt client, (a nil value) error -

i'm trying test programs concept of internet of things. got simple mqtt lua's client. works fine after flashing devkit nodemcu v2, when restart or save again esplorer says: test.lua:2: attempt call field 'client' (a nil value) code: source: https://www.cloudmqtt.com/docs-nodemcu.html -- initiate mqtt client , set keepalive timer 120sec mqtt = mqtt.client("client_id", 120) -- "username", "password") mqtt:on("connect", function(con) print ("connected") end) mqtt:on("offline", function(con) print ("offline") end) -- on receive message mqtt:on("message", function(conn, topic, data) print(topic .. ":" ) if data ~= nil print(data) end end) mqtt:connect("ip", 1883, 0, function(conn) print("connected") -- subscribe topic qos = 0 mqtt:subscribe("/topic",0, function(conn) -- publish message data = my_message, qos = 0, retain = 0 mqtt:publish(&qu

php - can't use function return value in write context - error in line 7 -

i can't understand issue. know question repeated not able understand issue in code. <?php //review box display function sch_ninja_display_review($postcontent){ global $post; $review=$post; if(get_post_meta($review->id,'review_show',true)=="on"){ if(!empty(get_post_meta($review->id,'review_price',true))){ $price='price:'.get_post_meta($review->id,'review_currency',true).get_post_meta($review->id,'review_price',true); } line 7: if(!empty(get_post_meta($review->id,'review_price',true))){ empty() php language construct , supports variables , expressions, , no function calls arguments. you have assign result of call variable first , empty check so: $reviewprice = get_post_meta($review->id,'review_price',true); if(!empty($reviewprice)){

c# - How to First Form Timer Start from Second form -

i have tried many time access , change property of control timer code please me public partial class form1 : form { public form1() { initializecomponent(); } } public partial class form2 : form { public form2() { initializecomponent(); } private void button2_click(object sender, eventargs e) { form1 frm = new form1(); frm.timer1.enabled = true; } } and had tried on loading constructor public partial class form1 : form { public form1() { initializecomponent(); } } public partial class form2 : form { form1 mainform; public form2(form1 mainform) { initializecomponent(); this.mainform=mainform; } public form2() { initializecomponent(); } private void button2_click(object sender, eventargs e) { mainform.timer1.enabled = true; } } when use constructor on loading occurred exception error

listview - ScrollView with a list inside how to design that? Android -

Image
have issue need make layout has textviews , listview inside. can see image further down on how planning use it. the listviews doesnt need able scroll whole view has to. i've found out should not have listview inside scrollview. question how manage ? any have suggestions solve problem ? regards alex

qt - QMake: how to choose version of library to link to -

there simple computer vision application uses opencv. compiling on host system deploy nvidia jetson tk1 (no problems here, use qt creator configured kit). use sshfs mount jetson's filesystem root host /mnt/sysroot_tegra_tk1 . the problem: i've compiled opencv version 3.2 on jetson (installed board /usr/local/lib ). there still system opencv version 2.4 in /usr/local . don't know how configure qmake on host system cross compile , link new version instead of jetson's system default. my .pro file: qt += core qt -= gui config += c++11 target = markerextractionchromakey config += console config -= app_bundle unix: includepath += /usr/local/include unix: qmake_libdir = /usr/local/lib unix: libs += -lopencv_imgproc\ -lopencv_core.so\ -lopencv_video\ -lopencv_highgui\ -lopencv_gpu template = app headers += cameraworker.h sources += main.cpp \ cameraworker.cpp target.path = /home/ubuntu/al

arangodb - Foxx service logging -

following documentation, should possible log foxx service. https://docs.arangodb.com/2.8/foxx/develop/console.html (looks old version , missing in doc newer versions) in script console.info("this test"); go , how read it? i cannot find _foxxlog collections, not sure should , user should have access rights. there log page in admin interface of arango not there. the documentation reads: as log entries logged collection in database, can query them in own application. collection in database, , if @ of them, there no logging collection, anywhere. update found foxx-manager applicatoin, command-line kung-fu, , has option development not in it's guess. didn't work @ first added --server.database <mydb> command executes fine. still clueless log data is. command result activated development mode service undefined version undefined on mount point /geo is mount point of foxx service? new point should able find log data? have tried all, still nothing

search - Can Lucene's TermRangeQuery use a different sort order? -

lucene's termrangequery sorts terms according bytesref.compareto . there exists bytesref.getutf8sortedasunicodecomparator , there seems no way use termrangequery . in fact make sort order more "natural" sorting 'ä' right after 'a' or treat them identical. looking @ code of termrangequery , end in automaton class , wonder whether have write own automaton. or there api available missing?

ios - Viewcontroller is not instantiating to Home VC when pressing login button -

Image
when login app home viewcontoller not appear , gives error unexpectedly found nil while unwrapping optional. irrates me there no syntax error found. login view controller @ibaction func loginaction(_ sender: any) { let vc : uiviewcontroller = self.storyboard?.instantiateviewcontroller(withidentifier: "viewcontroller") as! viewcontroller self.present(vc, animated: true, completion: nil) } home view controller import uikit class viewcontroller: uiviewcontroller { @iboutlet weak var mainhomebutton: uibarbuttonitem! override func viewdidload() { super.viewdidload() mainhomebutton.target = swrevealviewcontroller() mainhomebutton.action = #selector(swrevealviewcontroller.revealtoggle(_:)) self.view.addgesturerecognizer(self.revealviewcontroller().pangesturerecognizer()) } } architacture check if swrevealviewcontroller not nil on viewdidload() if self.revealviewcontroller() != nil { mainhomebutton.target = self.revealviewcont

c# - Convert DataSet to List -

here c# code employee objemp = new employee(); list<employee> emplist = new list<employee>(); foreach (datarow dr in ds.tables[0].rows) { emplist.add(new employee { name = convert.tostring(dr["name"]), age = convert.toint32(dr["age"]) }); } it uses loop create list dataset.is there direct method or shorter method or 1 line code convert dataset list try this: var emplist = ds.tables[0].asenumerable().select(datarow => new employee{name = datarow.field<string>("name")}).tolist();

javascript - Chai: AssertionError: expected [Function] to be a function (when testing exceptions) -

i'm getting error assertionerror: expected [function] function when i'm trying whether async function throws error it('has invalid password', async () => { const fakedata = { email: userdata.email, password: 'something not password!.' } expect(async () => { await authservice.authenticate(fakedata) }).to.throw(errors.unauthenticatederror) }) result: assertionerror: expected [function] function @ assertion.assertthrows (node_modules/chai/lib/chai/core/assertions.js:1273:32) @ assertion.ctx.(anonymous function) (node_modules/chai/lib/chai/utils/addmethod.js:41:25) @ doasserterasyncandaddthen (node_modules/chai-as-promised/lib/chai-as-promised.js:293:29) @ assertion.<anonymous> (node_modules/chai-as-promised/lib/chai-as-promised.js:252:17) @ assertion.ctx.(anonymous function) [as throw] (node_modules/chai/lib/chai/utils/overwritemethod.js:49:33) @ context.it (dist/tests/unit/auth-service.spec.js:56:20) @ test._mocha2.defa

java - Concurrent Modification Exception : adding to an ArrayList -

the problem occurs @ element element = it.next(); and code contains line, inside of ontouchevent for (iterator<element> = melements.iterator(); it.hasnext();){ element element = it.next(); if(touchx > element.mx && touchx < element.mx + element.mbitmap.getwidth() && touchy > element.my && touchy < element.my + element.mbitmap.getheight()) { //irrelevant stuff.. if(element.cflag){ melements.add(new element("crack",getresources(), (int)touchx,(int)touchy)); element.cflag = false; } } } all of inside synchronized(melements) , melements arraylist<element> when touch element , may activate cflag , create element different properties, fall off screen , destroy in less second. it's way of creating particle effects. can call "particle" crack , string parameter in constructor. this works fine until add main elemen

Block for serial output in GNURadio/GRC -

Image
i working on project involves gnu radio/grc , not familiar software. trying output data serial port in gnu radio using block, have not found way so. i wondering if there pre-defined block can use put information serial port (usb on raspberry pi 3), or if had create own block. , if had create own block, code like. i have been able write data file using file sink make sure getting data, , wondering if fix simple changing file sink serial port sink. see picture below: http://imgur.com/a/bdamz i did research , found github repo looks need -- unfortunately, repository links no longer there. did mention using pyserial, believe meant creating own block in python. link repo below: https://github.com/jmalsbury/gr-pyserial … wondering if fix simple changing file sink serial port sink. yes! or no, it's easier: so, in fact, use file sink write e.g. /dev/ttys0 (or /dev/ttyusb0 , or whatever device name of serial port), you'd have set serial port work wa

Maybe only for italian peoples... Import SDI certificates in IIS -

all. first, "spoiler information"... threas specific italian context. my company working receive invoices italy public companies (aka "pa") have server certificate(s) import in iis. certificate needed publish web service receive invoices. can't import certificate in iis. certificate has not private key. on msdn , ssl site, found topic "merge" certificate private key. when use certutil, system asks me smartcard. wrote lot of mail sdi customer care every time answer not answer. tia roberto

java - Audio start recording has stopped - not working -

even tried possible solutions find, couldnt solve problem. want make guitar tuner. when execute,getting message; "my application has stopped". think problem here "audio.startrecording();" when remove lane dont stopped message. tried api 15,25 versions app , virtual device phone. can u me guys problem? here code: package com.xxx.myapplication; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.app.activity; import android.media.audioformat; import android.media.audiorecord; import android.media.mediarecorder; public class mainactivity extends appcompatactivity { private static final int samplerate = 44100; private audiorecord audio; private int buffersize; private double lastlevel = 0; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } protected void onresume() { super.onresume();

python - Error while installing Scrapy: path not specified -

i found out scrapy great library scraping tried install scrapy on machine, when tried pip install scrapy installed while , threw me error.. error: microsoft visual c++ 14.0 required. "microsoft visual c++ build tools": http://landinghub.visualstudio.com/visual-cpp-build-tools and error: microsoft visual c++ 14.0 required. "microsoft visual c++ build tools": http://landinghub.visualstudio.com/visual-cpp-build-tools ---------------------------------------- command "d:\pycharmprojects\environments\scrapyenv\scripts\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\user\\appdata\\local\\temp\\pip-build-arbeqlly\\twisted\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record c:\users\user\appdata\local\temp\pip-jdj93131-record\install-record.txt --single-version-externally-managed --c

Can an ASP.NET MVC controller return an Image? -

can create controller returns image asset? i route logic through controller, whenever url such following requested: www.mywebsite.com/resource/image/topbanner the controller topbanner.png , send image directly client. i've seen examples of have create view - don't want use view. want controller. is possible? use base controllers file method. public actionresult image(string id) { var dir = server.mappath("/images"); var path = path.combine(dir, id + ".jpg"); //validate path security or use other means generate path. return base.file(path, "image/jpeg"); } as note, seems efficient. did test requested image through controller ( http://localhost/mycontroller/image/myimage ) , through direct url ( http://localhost/images/myimage.jpg ) , results were: mvc: 7.6 milliseconds per photo direct: 6.7 milliseconds per photo note: average time of request. average calculated making thousands of requests on local m

asp.net - Recomended Web Api Client -

i've developed asp.net web api using owin authenticate , authorizing users. client (customer), wants web app client connect de api, but: javascript (angular, knockoutjs or jquery) + html5 out question beacuse customer not want expose code if non business logic in it. the alternative i've came up, develop mvc or webforms webapp in serversides connect web api. i'm not sure if alternative recommended. what other choices should contemplate? thanks in advance..

php - What the unit of this date calculation? -

what unit in s or mn of element? $date = date('f d y h:i:s.', filectime($filename)) $result = time() - $date; $result = 1492181252; is in second? php timestamps seconds. says in documentation of time : returns current time measured in number of seconds since unix epoch (january 1 1970 00:00:00 gmt).

javascript - Get only Common Name of User Group from Active Directory -

i try common name of user active directory javascript code: system.log(aduser.getattribute("memberof")); the result of code that: cn=groupname,ou=other,ou=orgunit,ou=mycompany,dc=mydomain,dc=int Ä° want pull cn attribute of result. when execute code result should “groupname” regex last option.

reactjs - Redux-forms list to display many and redux form to edit one record. My design issue -

i have react redux component list multiple records in list, users can click on item. state maintained in redux array of objects. when user click on item selected , state maintained record (keep track of) selected item. list can refreshed latest data, , items can deleted list. far good. edit 1 item in list have redux-forms. issue form maintains own slice of state [when see state, see 2 slices 1 list , form.] there not single source of information item being edited. on list , on form slice. if update field in form, not show updated item in list. can hack -update code, etc , make [that avoid], see design issue? how design in better way? regards! how design store, when store needs populate list (using plain react-redux) , edit 1 item in list using forms (redux-forms) without duplicating same data in store?

ios - Orientation change with Auto Layout in Interface Builder -

Image
how can constrain view such centered when in portrait, moves 1 side of screen when in landscape? have 1 view above in portrait, want them go side-by-side when orientation changes. don't want have create 2 different layouts each orientation, , i'd stay in interface builder if possible. for clarity i've created following scrawling: i'd able rotate between these layouts. refer https://www.raywenderlich.com/113768/adaptive-layout-tutorial-in-ios-9-getting-started to achieve want have play size class. use of size class ios 9 onwards different from ios 7 & 8. if targetting ios 7 follow above link in case of ios 9 same can acheived using stackview.

sdl 2 - unexpected behavior while using SDL_image for texture in Vulkan -

Image
i managed load jpg images , use them textures in vulkan, different images give different results, images works fine, others not map well. here code block related image loading , format transition:- void vulkan::createtextureimage() { sdl_surface *tempimg; sdl_rwops *rwop; rwop = sdl_rwfromfile("textures/img1.jpg", "rb"); tempimg = img_loadjpg_rw(rwop); sdl_surface *image = sdl_convertsurfaceformat(tempimg, sdl_pixelformat_abgr8888, 0); vkdevicesize imagesize = image->format->bytesperpixel * image->h * image->w; if (!image) { throw std::runtime_error("failed load texture image!"); } vkimage stagingimage; vkdevicememory staingimagememory; createimage( image->w, image->h, vk_format_r8g8b8a8_unorm, vk_image_tiling_linear, vk_image_usage_transfer_src_bit, vk_memory_property_host_visible_bit | vk_memory_property_host_coherent_bit

java - Install tomcat 8 -

Image
i have problem tomcat, can not install version 8, when select version 7 goes when choose version 8 leaves me not complete configuration: i use eclipse mars, , java 8 thank you 1.close eclipse 2.just delete following 2 files workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings org.eclipse.wst.server.core.prefs org.eclipse.jst.server.tomcat.core.prefs 3.restart eclipse

Running aggregations on case insensitive keywords elasticsearch 5.1 -

i trying run aggregations on keywords in index want lowercase keywords while indexing , searching elastic 5.1 not support normalizer. also, don't want index them text , enable fielddata. other options accomplish this? you use analyzer made of keyword tokenizer , lowercase token filter. put my_index { "settings": { "analysis": { "analyzer": { "my_keyword": { "type": "custom", "tokenizer": "keyword", "filter": ["lowercase"] } } } }, "mappings": { "my_type": { "properties": { "my_field": { "type": "text", "analyzer": "standard", "fields": { "keyword": { "type": "text", "analy

android- How to search json data using retrofit and show the results? -

i made list view , showing json data on online. want add search functionality , show filter results. this screenshot enter image description here when type listview disappears , doesn't show results. this code mainactivityrecyc public class mainactivityrecyc extends appcompatactivity { public listview listview; private view parentview; public arraylist<locations> locationslist; public dataadapter adapter; // search edittext edittext inputsearch; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main_recyc); locationslist= new arraylist<>(); parentview=findviewbyid(r.id.parentlayout); inputsearch = (edittext) findviewbyid(r.id.inputsearch); listview = (listview) findviewbyid(r.id.listview); inputsearch.addtextchangedlistener(new textwatcher() { @override public void ontextchanged(charsequence cs, int arg1, int arg2, int arg3) {

angular - How do I know what port http-server is using? -

here install http server using npm install http-server -g command prompt after installing gives relevant path not port number, how can know port number is? http://localhost:8080/index.html it's throwing error on iis 8.5. you need run command http-server in directory index.html located can explicitly give command port use http-server -p 8918 use port 8918, command without parameters defaults 8080 or 8081 if 8080 occupied if recall correctly. you can find more info on https://www.npmjs.com/package/http-server

sql - MySQl Query giving wrong result -

Image
select * yogatimetable; delete yogatimetable roomnum in (select tt.roomnum yogarooms r, yogatypes t, yogatimetable tt r.roomnum = tt.roomnum , ((r.roomcapacity * t.classprice) - (r.costperhour * tt.duration / 60)) < 200); select * yogatimetable; the goal delete classes timetable can make less $200 profit. calculate profitability of each class, multiply roomcapacity classprice , subtract cost of room. calculate cost of room multiply costperhour duration divided 60. isn't giving right result, can tell me made mistake. thanks. tables attached. to me looks have 2 problems. a cross join between t , tt exists , should resolved. you're attempting delete based on incomplete or partial key of yogatimetable. unique key of yogatimetable appears yogaid, starttime,day , roomnum. because same yoga type in same room @ same time on different day, or in same room on same day @ dif

networking - Get Device Name FROM IP Address Swift -

i trying fetch device's name on lan in swift. have played around cfhost , bonjour hasn't been helpful. wondering if there's libraries or frameworks can call such: utility.fetchhostname(ipaddress) -> string?

Neo4j Cypher query sort order -

in neo4j/sdn project have following mode: decision entity contains child decision , characteristic entities. each pair of child decision , characteristic can have value node assigned. i have created 3 child decision nodes, example childdecision1 childdecision2 childdecision3 and 1 characteristic : characterisitc1 i have assigned following values following pairs: childdecision2 + characterisitc1 = value(integer 10) childdecision3 + characterisitc1 = value(integer 25) i'm executing following cypher query(with o rder sortvalue88.value asc ): match (parentd)-[:contains]->(childd:decision)-[ru:created_by]->(u:user) id(parentd) = {decisionid} optional match (childd)<-[:set_for]->(sortvalue88:value)-[:set_on]->(sortcharacteristic88:characteristic) id(sortcharacteristic88) = 88 ru, u, childd , sortvalue88 order sortvalue88.value asc skip 0 limit 100 return ru, u, childd decision, [ (parentd)<-[:defined_by]-(entity)<-[:commented_on]-(

opendj - Generating OpenAM tokens for a user -

let's have 2 applications, appa , appb. appa has simple database authentication approach , appb uses forgerock's openam. want user in appa able sso appb. because username/password in appa different creds in opendj, i'm wanting add column user table in appa called external_user_id. use generate token hand on appb. i'm curious if there way in openam generate tokens user using username , not password. if there idea of serviceadmin account lets appa generate tokens based on username, awesome, i'm doubting exists. there in openam i'm missing? the best way tackle kind of situation write custom authentication module receive session id or "secret" appa, validate , issue new session on openam domain, , giving access appb.

laravel - Set hasOne relation to new instance of child model -

using laravel 4.2, how can set hasone relation on model instance of new model without touching database? i want following, laravel treating instance property, not child relation. class parentclass extends \eloquent { public function child() { return $this-hasone('childclass', 'child_id', 'parent_id'); } } $parent = new parentclass(); $parent->child = new childclass(); to through problem, have created trait class added models allows me set relation. doing not automatically set parent/child relation values have careful manually before save/push. trait modelsetrelationtrait { public function setrelation($key, $model) { $this->relations[$key] = $model; } } class parentclass extends \eloquent { use modelsetrelationtrait; public function child() { return $this-hasone('childclass', 'child_id', 'parent_id'); } }

asp.net mvc - Pass html datalist value to Html.Action -

i'm creating html form lists line items 1 organization need mapped on. idea take id of selected option, , pass action via html.action. code have far; <table class="table"> <tr> <th> @html.displaynamefor(model => model.newid) </th> <th> @html.displaynamefor(model => model.oldserviceid) </th> <th> @html.displaynamefor(model => model.description) </th> <th> @html.displaynamefor(model => model.avg) </th> <th> @html.displaynamefor(model => model.count) </th> <th> @html.displaynamefor(model => model.acquisitionid) </th> <th></th> </tr> @foreach (var item in model) { <tr> <td> @* i'm stuck *@ <form action=@html.action("update&q

Vuefire Firebase update issues -

i'm having som issues updating firebase vuefire. m trying use following method, yells @ me if leave field blank (which supposed happen in setup) idea why gets mad if .update blank field? error: uncaught error: firebase.update failed: first argument contains undefined in property 'businesses.somebusiness.video' updatepost(post) { postsref.child(post['.key']).update({ name: post.name, video: post.video, story: post.story, cover: post.cover, card: post.card }) }, at 1 point had above re-written so: updatepost: function (post) { const businesschildkey = post['.key']; delete post['.key']; /* set updated post value */ this.$firebaserefs.posts.child(businesschildkey).set(post) }, it worked amazingly deleting key seemed cause weird ordering issues in vue. prefer stick top method if can find way not have trow error if 1 left blank.

mysql - How to select a row inserted before another row, timestamp? -

say have: -------------------------------------- | item | value | timestamp | -------------------------------------- | apple | red | 2013-04-15 09:34:44 | | orange | orange| 2014-04-15 09:34:44 | | banana | yellow| 2015-04-15 09:34:44 | | fruit | mix | 2016-04-15 09:34:44 | | malon | red | 2017-04-15 09:34:44 | ---------------------------------------- question: select 1 row inserted before specific timestamp i tried: select * table timestamp < '2015-04-15 09:34:44' limit 1 , item not null the row want select row insert before date 2015-04-15 09:34:44 2014-04-15 09:34:44 . above query used selected rows inserted before date 2015-04-15 09:34:44 , tried limit 1 output result 2013-04-15 09:34:44 oldest one. try this: select * `table` `timestamp` < '2015-04-15 09:34:44' , not `item` null order `timestamp` desc limit 1

kubernetes - Service won't come up when using static IP on GKE -

i have allocated static ip on gcp account. then, updated application's service definition use in load balancer, so: kind: service apiversion: v1 metadata: # unique key of service instance name: my-app-service spec: ports: # accept traffic sent port 80 - name: http port: 80 targetport: 5000 selector: # loadbalance traffic across pods matching # label selector app: web # create ha proxy in cloud provider # external ip address - *only supported # cloud providers* type: loadbalancer # use static ip allocated loadbalancerip: 35.186.xxx.xxx if comment out last line , let gke allocate ephemeral public ip, service comes fine. ideas doing wrong? based on advise in answer, created ingress follows: apiversion: extensions/v1beta1 kind: ingress metadata: name: myapp annotations: kubernetes.io/ingress.global-static-ip-name: "myapp" spec: backend: servicename: my-app-service serviceport: 80 now, see ing

sna - How to compute Quadratic Assignment Procedure using R? -

i have 3 networks , want measure structural equivalence quadratic assignment procedure. have executed code got error . can 1 , suggest on right way ? rm(list=ls()) getwd() library(sna) dat=read.csv(file.choose(),header=true) dat1=read.csv(file.choose(),header=true) dat2=read.csv(file.choose(),header=true) el=as.matrix(dat) g=graph.edgelist(el,directed=false) el=as.matrix(dat1) g1=graph.edgelist(el,directed=false) el=as.matrix(dat2) g2=graph.edgelist(el,directed=false) #perform qap tests of graph correlation q.12<-qaptest(g,gcor,g1=1,g2=2) error in fun(x[[i]], ...) : as.sociomatrix.sna input must adjacency matrix/array, network, or list. > q.13<-qaptest(g,gcor,g1=1,g2=3) error in fun(x[[i]], ...) : as.sociomatrix.sna input must adjacency matrix/array, network, or list. > > #examine results > summary(q.12) error in summary(q.12) : object 'q.12' not found > plot(q.12) error in plot(q.12) :

c# 4.0 - How to replace chars inorder?? Quickly -

i've got foreach loop replaces char in string in correct order, it's slow.. the input string can have different lengths.. string lengths range 1000 - 1000000 each char takes, 1.2 milliseconds.. but it's input string slows down, anyway replace chars faster.. the charlist char replacements.. i'm replacing chars in input string value2 charlist items.. list<charitem> charlist; //charlist count = 98.. var txxt = input.tochararray(); string test = ""; foreach (var itm in txxt) { var itm2 = (from x in charlist x.value == itm select x).firstordefault(); if (itm2 != null) test = test + itm2.value2; } public class charitem { public char value { get; set; } public char value2 { get; set; } public override string tostring() { return "1." + value + "| 2." + value2; } } as statement test = test + itm2.value2; don't think stringbuilder faster.. anyway speed up, char order needs

Facebook API Product Catalog for every users -

Image
i wondering possible api push user's products on our marketplace facebook page? realize of users on our marketplace has facebook page of own, awesome if facebook allow that. this example of want achieve: user's facebook page products posted on our market place:

angularjs - typescript complains about call signature when testing $componentController -

i trying test angular 1.5 component, typescript throwing red in console. (17,27): error ts2349: cannot invoke expression type lacks call signature. type 'icomponentoptions' has no compatible call signatures. phantomjs 2.1.1 (windows 8 0.0.0) component: recipecontainer should have defined component failed am including files incorrectly? (i'm using webpack compile). am missing type definition? any appreciated, been scratching head hours now. spec file: import * angular 'angular'; import 'angular-mocks'; import { recipecontainer } './recipe-container.component'; import { recipes } '../recipe-store'; describe('component: recipecontainer', () => { let $componentcontroller: ng.icomponentoptions; beforeeach(angular.mock.module('app')); beforeeach(angular.mock.inject((_$componentcontroller_: ng.icomponentoptions) => { $componentcontroller = _$componentcontroller_; })); it(&

swift - Observing data that saved with childByAutoId -

i using childbyautoid save each message in firebase. now when observing data, want each query 10 older messages using .querystarting(atvalue: ) .queryending(atvalue: ) is possible childbyautoid ? thanks sure. that's not best practice - don't query key. query child in node. messages -y8hji98jasdjkas datestamp: "20170405" -yin99s9ks9kksok datestamp: "20170407" -y7iijs9jsk9999j datestamp: "20170409" queryordered(bychild: "datestamp").querystarting(atvalue: "20170405") .queryending(atvalue: "20170408") will retrive these 2 older child nodes -y8hji98jasdjkas datestamp: "20170405" -yin99s9ks9kksok datestamp: "20170407"

Python : search two regular expression in one command -

how search 2 regular expressions in 1 findall command? have ugly program done, learn better python way this. in following example, identify servers either (alarm1 side0 & alarm1 side1) or (problem 2). file : server 1, side 0, alarm 1 server 1, side 1, alarm 1 server 1, problem 2 server 2, alarm 2 server 3, side 0, alarm 1 server 4, side 1, alarm 1 server 5, alarm 3 expected output : server 1, alarm 1, alarm 2 server 2, alarm 2 script : #! /usr/bin/python import re import sys import os def main(): server_alarm_list=[] open('sample_data') f: text=f.read() alarm1_side0_tuple=re.findall(r'server (\d+), side 0, alarm 1', text) alarm1_side1_tuple=re.findall(r'server (\d+), side 1, alarm 1', text) alarm2_tuple=re.findall(r'server (\d+), problem 2', text) in alarm1_side0_tuple: if in alarm1_side1_tuple: server_alarm_list.append(i) in alarm2_tuple: if in server_alarm_list: print

loopbackjs - 'this' inside loopback non static method is null -

i have remote method option isstatic: false . inside remote method definition, this undefined. user.remotemethod('books', { http: {path: '/books', verb: 'get'}, isstatic: false, returns: {root: true, type: 'object'}, }) user.prototype.books = function (cb) { console.log('this ', this); } i using loopback 3.6.0. appreciated.

array of pointers of a struct in C -

i'm having bad time pointers , arrays , need help. there exercise have struct: typedef struct student_node{ unsigned number; const char *name; unsigned class; struct student_node *next; } studentnode; and have implement function: void groupstudentbyclass(studentnode *classes[], studentnode students[], size_t num_students) my problem want change number in classes , print value , can't. gives me "segmentation fault(core dumped)". don't understand why... this test code: size_t nclasses=3; studentnode *classes [nclasses]; classes[0]->number=0; printf("%u\n",classes[0]->number); btw can't use malloc , things allocate memory. @matthias has explained why getting segv. if cannot use malloc need preallocate structures. like const size_t max_student = 1024; studentnode studentpool[max_student]; int studentlast = -1; then need allocation routine studentnode* studentget() { if (++studentlast >= max_stude

javascript - vertical centering by position:absolute works only on chrome -

i try set div few elements in middle of section height set 100% of screen height. problem solution have used doesn't work on other browsers google chrome. used position:absolute, display:table, margins , top:0, bottom:0; var section = document.queryselectorall('section'); var winh = window.innerheight; header.style.height = winh+'px'; (var = 0; <= section.length; i++) { section[i].style.height = winh+'px'; } section { padding:100px 0; position:relative; background:#222; } section div { width:90%; max-width:1200px; margin:0 auto; text-align:center; position:absolute; left:0;right:0;top:0;bottom:0; display:table; } <section class="users"> <div> <div class="icon"><i class="fa fa-user" aria-hidden="true"></i></div> <div class="

SSH agent forwarding during docker build -

while building docker image through dockerfile, have clone github repo. have added public ssh keys git hub account , able clone repo docker host. while see can use docker host's ssh key mapping $ssh_auth_sock env variable @ time of docker run docker run --rm -it --name container_name \ -v $(dirname $ssh_auth_sock):$(dirname $ssh_auth_sock) \ -e ssh_auth_sock=$ssh_auth_sock my_image . how can same during docker build ?

javascript - Multiple clicks add class -

i work on create simple fullscreen menu , it's work well, there problem maybe user click more 1 (not dblclick) on button clicks , problem in video appear: youtbe video need remove class when animation completed: here code: $(document).ready(function () { $('.menu-trigger').click(function (e) { e.preventdefault(); $('.menu').toggleclass('open'); $('.menu .rectangle').removeclass('visible'); $('.menu .rectangle').delay(100).queue(function () { $(this).addclass('visible').clearqueue(); }); }); }) html, body{ height:100%; } .header{ width:100%; padding:20px; position:fixed; z-index:1000; } .header .menu-trigger{ width:40px; height:40px; background-color:#eaeaea; cursor:pointer; position:absolute; top:20px; left:20px; } .menu { width: 100%; height: 100%; position: abs

node.js - nodemon failed to start due to some error -

this error comes when run programme using global nodemon, fine when use node [nodemon] 1.11.0 [nodemon] restart @ time, enter `rs` [nodemon] watching: *.* [nodemon] starting `node server.js` events.js:160 throw er; // unhandled 'error' event ^ error: spawn cmd enoent @ exports._errnoexception (util.js:1018:11) @ process.childprocess._handle.onexit (internal/child_process.js:193:32) @ onerrornt (internal/child_process.js:367:16) @ _combinedtickcallback (internal/process/next_tick.js:80:11) @ process._tickcallback (internal/process/next_tick.js:104:9) without nodemon works correctly globally run gives error. you're supposed run nodemon in place of node . looks you're running nodemon node server.js instead run nodemon server.js

import - How to implement java library that is simply a .java file -

i'm attempting use passwordstorage class found @ following github repo: https://github.com/defuse/password-hashing/ i've found passwordstorage.java file don't know go there. under impression need .jar file import library. just copy file and license file own source code you don't need jar it.

Why am I seeing duplicate Scopes on IdentityServer4's consent screen? -

Image
i writing identityserver4 implementation , using quickstart project described here . when define apiresource (using inmemory classes now) looks identityserver creates scope same name resource. example public static ienumerable<apiresource> getapiresources() { return new list<apiresource> { new apiresource("api", "my api") }; } will create scope called "api" (this done in apiresource constructor). if add "api" allowed scope on client object (using inmemoryclients proof of concept) , request api scope in scope query string parameter in auth request javascript client invalid_scope error message. i found following this documentation can add scopes apiresource through scopes property so new apiresource { name = "api", displayname = "custom api", scopes = new list<scope> { new scope("api.read"), new scope("api.write")

javascript - Promise.map function .then() block getting null before nested promise resolves -

i'm kicking off nested promise mapping , seeing outer .then() block print null result before resolve in function called. i feel must messing syntax somehow. i've made stripped down example: const promise = require('bluebird'); const toparray = [{outerval1: 1,innerarray: [{innerval1: 1,innerval2: 2}, {innerval1: 3,innerval2: 4}]},{outerval2: 2,innerarray: [{innerval1: 5, innerval2: 6 }, {innerval1: 7,innerval2: 8 }]}] ; promisewithoutdelay = function (innerobject) { return new promise(function (resolve, reject) { settimeout(function () { console.log("promisewithdelay" ,innerobject); let returnval = {} returnval.innerval1 = innerobject.innerval1; returnval.innerval2 = innerobject.innerval2; returnval.delay = false; return resolve(returnval); }, 0); }) } promisewithdelay = function (innerobject) { return new promise(function (resolve, reject) {