Posts

Showing posts from July, 2012

swift - SKLightNode's shadow doesn't hide sprites -

Image
i'm working sklightnode , have sprites on screen. want sprites cast shadow depending on light's position, want sprites lit directly light shown , sprites behind sprites hidden. i have code : let light = sklightnode() override func didmove(to view: skview) { light.categorybitmask = 1 light.falloff = 1.0 light.shadowcolor = skcolor.black light.zposition = 2 addchild(light) // add light _ in 0...10 { let object = skspritenode(imagenamed: "stone") object.position = cgpoint(x: cgfloat.random(min: playablerect.minx, max: playablerect.maxx), y: cgfloat.random(min: playablerect.miny, max: playablerect.maxy)) object.shadowcastbitmask = 1 object.zposition = 2 addchild(object) // add 10 wall sprites } } this results in : as can see, problem sprites in shadow aren't hidden. when change walls' zposition 1 (lower light's zposition), have : here hidden, still not good. i

C++ vs Java speed(Loops with Arithmetic) -

the following small programs compute sum of numbers 1 1 billion we're written in c++ , java closely write them. understanding c++ "faster" language, java version of code completes in ~.5 seconds vs ~3 seconds c++. c++ (gcc compiler): int main(){ long long x = 0; (long i=0;i<1000000001;i++){ x=x+i; } cout << x << endl; return 0; } java: public class main { public static void main(string[] args) { long x=0; (long i=0;i<1000000001;i++){ x=x+i; } system.out.println(x); } } how 1 optimize c++ code fast java version? possible? if compile optimizations, c++ version considerably faster. java: javac main.java $ time java main 500000000500000000 real 0m0.727s user 0m0.724s sys 0m0.004s c++: clang -o3 main.cpp -o cpp $ time ./cpp 500000000500000000 real 0m0.003s user 0m0.000s sys 0m0.000s my clang version: $ clang --version cla

javascript - How to write 500.000 words in one line with node.js fs module without lines to be break? -

i want write format 1 {"index": {"_id": 0}} 2 { "age_groups" : ["-kmqn3sh7_ ........100000 words in sinle line 3 {"index": {"_id": 1}} 4 { "age_groups" : ["-kmqn3sh7_ ........100000 words in sinle line 5 {"index": {"_id": 2}} 6 { "age_groups" : ["-kmqn3sh7_ ........100000 words in sinle line 7 {"index": {"_id": 3}} 8 { "age_groups" : ["-kmqn3sh7_ ........100000 words in sinle line but format after write file {"index": {"_id": 0}} { "age_groups" : ["-kmqn3sh7_p73cwzrsmd","-kmqn6aze7lroyh_ccpp","-"-kmqnklhhro0annagybq"], "needs": ["-km5n7vj_x5j2yj9ag6c","-km5ncklpde8c4nfq6kg"], "categories": ["-kmctr9mdf_cvwts3b74","-kmcter6woj-xm1jpns4"], "tags": , "title": "bepanthol

java - Can we use webdriver and ngDriver in same script? -

i testing 1 website selenium webdriver using java , newly introduced few angularjs page in website. thought of integrating protractor in existing test framework. script identifying objects using webdriver not able identify using ngdriver inside same method. tried caste before trying identify object using protractor: ngwebdriver ngdriver; ngdriver = new ngwebdriver(wdriver); ngdriver.findelements(ngby.model(transferrx.transfer.patientfirstname)).size(); can please might issue?

ios - How to set the app icon on info.plist? -

i have 3 schemes , each scheme have xcconfig file. i'd setup variable set appicon each environment. example, in hom.xcconfig set: icon = appicon-hom and in others xcconfig files set: icon = appicon in info.plist set in key icon file variable ${icon} not working. how configure app icon without create target?

c++ - Overriding a virtual method in a base class with conditional type traits in derived template class -

can explain why code below gives error "error c2259: 'propertyvalue': cannot instantiate abstract class" in visual studio 2015 c++? is compiler not able identify conditionally specified function converttodevice() in derived class propertyvalue has same signature? many thanks, john #include <type_traits> #include <typeinfo> class basepropertyvalue { public: virtual int converttodevice(void** ptrdobject) = 0; }; template<typename t> class propertyvalue : public basepropertyvalue { public: t value; propertyvalue(t val) { value = val; } template<class q = t> typename std::enable_if<!std::is_pointer<q>::value, int>::type converttodevice(void** ptrdobject) { return 1; } template<class q = t> typename std::enable_if<std::is_pointer<q>::value, int>::type converttodevice(void** ptrdobject) { return 2; } }; void main() {

Double Taxation when using a RelativeLayout on Android -

in order understand double taxation on android, wrote following code pretty simple. there relativelayout 3 textview s. <?xml version="1.0" encoding="utf-8"?> <ru.maksim.sample_app.myrelativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="ru.maksim.sample_app.mainactivity"> <ru.maksim.sample_app.mytextview android:id="@+id/text1" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#fca" android:tag="text1" android:text="text 1" /> <ru.maksim.sample_app.mytextview android:id="@+id/text2" android:layout_width="wrap_content" an

c - Copying data from a __user pointer -

i have access data pointer in struct iw_point variable on linux based embedded board. pointer contained in struct of type __user . when try access location, program keeps segfaulting. when looked @ memory location pointed pointer, noticed location not lie in address space of process has read location(obtained reading /proc/pid/maps ): 00400000-0048c000 r-xp 00000000 1f:04 83 /root/aravind/smapp 0049b000-0049c000 rw-p 0008b000 1f:04 83 /root/aravind/smapp the location returned pointer e80000 not lie in range returned above. does mean location lies outside address space of program triggering pointer return in first place(the pointer returned ioctl call)? the siocgiwscan ioctl uses space hand in iwr.u.data.pointer = p; iwr.u.data.length = bufsz; with request return scanned network information because ioctl not able allocate return area in user space. check initialized pointer , data length (4k buffer space recommended). in case didn't, might

python - how to access custom prop_cycle colors? -

Image
i've defined custom color cycler in text file, , invoking via plt.style.context() . cycle i've defined has 12 colors. when annotating plot, if try access custom cycler colors using color strings, 'c0' through 'c9' work 'c10' throws valueerror: invalid rgba argument: 'c10' . 12 values in there. contents of style file style.yaml : axes.prop_cycle : cycler('color', ['332288', 'cc6677', 'ddcc77', '117733', '88ccee', 'aa4499', '44aa99', '999933', '882255', '661100', '6699cc', 'aa4466']) test script: import numpy np import matplotlib.pyplot plt data = np.c_[np.zeros(13), np.arange(13)].t labels = list('abcdefghijklm') plt.style.context('style.yaml'): # prove colors loading correctly: cycle = plt.rcparams['axes.prop_cycle'].by_key()['color'] print('{} colors: {}'.format(len(cycle), c

linux - Apache HTTPS URL Rewrite -

i've started playing linux , apache , got stuck on this. i have rewrite rule working fine: rewriteengine on redirectmatch ^/$ /myserver/ rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /myserver/ [r] how can redirect https applying these same rules? thanks! on apache wiki: rewritecond %{https} !=on # checks make sure connection not https rewriterule ^/?(.*) https://%{server_name}/$1 [r,l] # rule redirect users original location, same location using https. # i.e. http://www.example.com/foo/ https://www.example.com/foo/ # leading slash made optional work either in httpd.conf # or .htaccess context if understand question correctly, can implement in specific example. note recommended use redirect inside non-secure virtualhost secure virtualhost.

python - Encode a sqlalchemy text query -

i trying execute statement without success because get: "unicodeencodeerror: 'ascii' codec can't encode character '\xc9' in position 276: ordinal not in range(128)" my code is: import sqlalchemy sa sqlalchemy.sql import text engine = sa.create_engine("my connection (cannot show it)") conn = engine.connect() q = text("select * stores cadena = 'Élias'") result = conn.execute(q).fetchall() print(result) as see, conditional of sql query has "É" cannot encoded. what can solve this? if write .encode('utf-8') @ end of text, says attributeerror: 'textclause' object has no attribute 'encode' thanks in advance!

cygwin - Error "undefined reference to `WinMain' "in Eclispse C++ on Windows in Blank C++ Project -

i getting error when compiling hello world code in eclipse in new executable blank c++ project, when choose new executable hello world c++ project there no error /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../lib/libcygwin.a(libcmain.o): in function main': /usr/src/debug/cygwin-2.8.2-1/winsup/cygwin/lib/libcmain.c:37: undefined reference to winmain' /usr/src/debug/cygwin-2.8.2-1/winsup/cygwin/lib/libcmain.c:37:(.text.startup+0x7f): relocation truncated fit: r_x86_64_pc32 against undefined symbol `winmain' collect2: error: ld returned 1 exit status

reactjs - Testing tooltip of char.js component React.js with Enzime -

Image
i have react components <lines /> , inside of have <line /> component react-chartjs-2 the line component has option custom tooltip , there call function actions want this.setcustomtoooltip i'm trying testing tooltip how this?, don't know how simulate tooltip, tooltip appears in hover event of graphic lines. idea one. just have code , using chai , enzyme it('should execute tooltip', () => { let setcustomtooltipspy = sinon.spy(lines.prototype, 'setcustomtootip'); const wrapper = shallow(<lines />, { lifecycleexperimental: true }); expect(setcustomtooltipspy.calledonce).to.equal(true); setcustomtooltipspy.restore(); });

amazon web services - setSegment unexpected error TypeError: segment.resolveLambdaTraceData is not a function -

i trying change trace-id tell me if i'm taking wrong approach. i'm thinking of create segment, , add parent-id trace_id want 1 trace can follow trace. reason i'm trying because asynchronous parts of aws such kinesis streams not supported in aws x-ray. const segment = new awsxray.segment('1-11111111-111111111111111111111111', '1-11111111-111111111111111111111111', '1-11111111-111111111111111111111111') console.log(segment) awsxray.setsegment(segment) however, error: typeerror: segment.resolvelambdatracedata not function any ideas why i'm getting error, or how can connect 2 events happened before , after kinesis stream connecting trace_ids? when x-ray sdk used in lambda, lambda creates it's own segment (and sends out of band of lambda function code) , sdk creates "facade" on context placeholder given parent id , id of segment lambda created (exposed via process.env._x_amzn_trace_id). sdk creates subsegments attach

android - Cannot find InstrumentationTests with different testBuildType -

i defined different build type 'fake' in gradle file. specified configuration used tests using testbuildtype 'fake' . result following: unit tests working well instrumentation tests not work. instead i'm getting following error no tests found , output in console saying: started running tests test running failed: instrumentation run failed due 'process crashed.' empty test suite. i didn't change folder structure tests. unit tests still in directory test , instrumentation tests in androidtest . switching build variant doesn't help. if remote testbuildtype , instrumentation tests visible in case , using debug build type. what can reason of issue?

c++ - Issue with std::atomic and custom structs -

can't seem (see code) reason. looked @ documentation, there doesn't seem reason not work... struct vector { float x, y, z; }; std::atomic<vector> name = {0}; it says can't initialize initializer list, , when go use in code, says has no members. name.x = 4.f; name.y = 2.f * name.x; name.z = 0.1f; an instance of std::atomic<vector> isn't instance of vector . doesn't have x , y , or z members. have (conceptually, internally) instance of vector . can't access . operator because break atomicity, is, like, point of std::atomic . (this why can't use initializer list.) to access vector stuff, use load() , store() : //atomically load snapshot of name auto name_snapshot = name.load(); //name_snapshot vector instance name_snapshot.x = 4.f; name_snapshot.y = 2.f * name_snapshot.x; name_snapshot.z = 0.1f; //now atomically store it: name.store(name_snapshot);

C language: How to pass a variable arguments list of void* to a function -

i trying pass variable arguments list of void* elements function in c. how do this? how calculate number of items in list? how loop through var-args list , pass each void* item function takes void* item parameter? this have done, not working. void addvalues(list* data, void* args, ...) { int len = sizeof (args) / sizeof (*args); for(int i=0;i<len;i++){ processitem(args[0]); } } void processitem(void* item){ } how calculate number of items in list? you can't. must provided or derivable. how loop through var-args list , pass each void item function takes void* item parameter?* as documented in variadic functions , #include <stdarg.h> void addvalues(int count, ...) { va_list args; va_start(args, count); for(int i=count; i--; ) processitem(va_arg(args, void*)); va_end(args); } example usage: void* p1 = ...; void* p2 = ...; void* p3 = ...; void* p4 = ...; addvalues(4, p1, p2, p3, p4); it depends o

tensorflow - What's difference between Summation and Concatenation at neural network like CNN? -

what's difference between summation , concatenation @ neural network cnns? for example googlenet's inception module used concatenation, resnet's residual learning used summation. please teach me. concatenation means concatenate 2 blobs, after concat have bigger blob contains previous blobs in continuous memory. example: blob1: 1 2 3 blob2: 4 5 6 blob_res: 1 2 3 4 5 6 summation means element-wise summation, blob1 , blob2 must have exact same shape, , resultant blob has same shape elements a1+b1, a2+b2, ai+bi, ... an+bn. example above, blob_res: (1+4) 5 (2+5) 7 (3+6) 9

ruby - Understanding rails delegate method -

i'm trying learn delegate method rails provides out of box. here i'm trying do. so, have accounts have_many tasks . i'm trying task count accounts , here how i'm doing it: def total_tasks tasks.count end pretty standard thing. i'm trying move method delegate method. i've tried it's not working delegate :count, to: :task, prefix: "total" that didn't work , didn't expect do. there way can this? delegate :count, to: :tasks, prefix: "total" this meta programming creates method: def total_count tasks.send(:count) end this not fit delegate though should using size instead of count latter causes db query if association has been eager loaded. def tasks_total tasks.size # prevents n+1 query issue. end why want create method beyond me though 1 more character type.

c# - How to incorporate criteria in Where method? -

Image
i want ask condition in search command. i'm calling web service (api) during searching , want put statement in code there's error. private async task callapi(string searchtext = null) { long lastupdatedtime = 0; long.tryparse(appsettings.complaintlastupdatedtick, out lastupdatedtime); var currenttick = datetime.utcnow.ticks; var time = new timespan(currenttick - lastupdatedtime); if (time.totalseconds > 1) { int stafffk = convert.toint32(staffid); var result = await mdataprovider.getcomplaintlist(lastupdatedtime, mcts.token, stafffk); if (result.issuccess) { // save last updated time appsettings.complaintlastupdatedtick = result.data.updated.tostring(); // store data database if ((result.data.items != null) && (resul

python - Argparse optional args override positional -

i'm trying figure out way have argparse positional arguments mutually exclusive optional argument. for example: ./adder 20 32 output: 52 ./adder --interactive adder> right now, if try '--interactive', tells me i'm missing positional arguments. example code: parser = argparse.argumentparser() parser.add_argument('a', metavar='first') parser.add_argument('b', metavar='second') parser.add_argument('--interactive') parser.parse_args() i wondering if there elegant way (preferably using argparse functionality) '--interactive' disables requirement of using 2 positional arguments. usually positional arguments can not omitted. can try nargs='*' alternative. parser = argparse.argumentparser() parser.add_argument('ab', nargs='*', type='int') parser.add_argument('--interactive', action='store_true') args = parser.parse_args() use list args.ab store posit

node.js - Using "croppie" on front-end / What do I exactly need to do on back-end to actually crop the image? -

how crop , compress (resize snippet size) image on back-end? i'm using croppie on front-end: https://foliotek.github.io/croppie/ i'm lost, small guidance helpful. thanks! why want crop pic on back-end? operation should have done in browser. when use result({ type, size, format, quality, circle }) function, can data of cropped pic . if type base64 , can save data file after base64_decode it.

xamarin.forms - Error with request headers add -

i working on xamarin forms app , want data webapi. when type request.headers.add got squiggy line on add message "webheadercollection not contain definition add accepting first argument of type webheadercollection found. missing using directive or assembly reference" httpwebrequest request = (httpwebrequest)webrequest.create(string.format(constants.lndefaultarticles, category)); request.method = "get"; request.accept = "application/json"; request.headers.add("authorization", string.format("bearer {0}", accesstoken)); how can resolve this?

How to route messages based on message Timestamp using spring integration -

my use case follows: 1. read message queue 2. if message timestamp older 60 mins want processing 3. else other processing my integration graph follows: <jms:message-driven-channel-adapter connection-factory="jmsconnectionfactory" destination-name="${mq.queues}" channel="mqchannel" id="aomqinbound" /> <channel id="mqchannel" /> <si-xml:xpath-router input-channel="mqchannel" default-output-channel="lessthanorequalto60mins"> <si-xml:xpath-expression expression="timestamp > 60 mins" /> <si-xml:mapping value="true" channel="greaterthan60mins" /> </si-xml:xpath-router> but not sure how provide message timestamp greater 60mins in expression attribute. please in regard. let me know, if there better way this.

r - Subsetting a vector into an another vector -

i have 2 input vectors shown below. need match ranges , need store them in separate vectors. works this: values in iv2 between first 2 values of iv1 stored in ov1, values in iv2 between second , third values of iv2 , on. note: values in input vectors in ascending order. thoughts please? input: iv1 <- c(100, 200, 300, 400, 435) iv2 <- c(60, 120, 140, 160, 180, 230, 250, 255, 265, 270, 295, 340, 355, 401, 422, 424, 430) output: ov1: 120, 140, 160, 180 ov2: 230, 250, 255, 265, 270, 295 ov3: 340, 355 ov4: 401, 422, 424, 430 as @ronakshah suggested, efficient way in case may this: split(iv2, cut(iv2, breaks = iv1,labels = paste0('ov',1:4))) output: $ov1 [1] 120 140 160 180 $ov2 [1] 230 250 255 265 270 295 $ov3 [1] 340 355 $ov4 [1] 401 422 424 430

How to align text HTML5 CSS -

i mother noob coding sorry if dumb question. have looked thru tutorials , can't seem able align text properly. want align next image (near bottom). so started doing bottom: 0 aligns near top. there text near top, , seems adjust near that. https://jsfiddle.net/xo1sje8m/ .h01 { position: absolute; text-align: center; width: 100%; left: 0; bottom: 0; } <h2 class="h01">helllo every1</h2> not sure going wrong. here screenshot of aligns ( screenshot ). if want position image, use move distance element above it margin-top: 200px; using vertical-align on image tells nearby text align according image.

plugins - Cordova windows 10 mobile app text scaling will change application font size issue -

i have created window 10 mobile application using cordova. have signed build windows 10 mobile app. app behaving when text scale minimum. whenever go settings->ease of access -> more options -> text scaling, , change text scaling, device text font size getting changed. due device text scaling settings, application font size getting change , app distorted view. there solution or plugin available disable device text scaling windows 10 mobile app? it's working fine windows 8 phone. creating issue in windows 10 mobile app.

asp.net - Show map on webform C# -

var root = jsonconvert.deserializeobject<rootobject>(text); double latitude = root.data.location.latitude; double longitude = root.data.location.longitude; //http://maps.googleapis.com/maps/api/geocode/xml?address=1600+amphitheatre+parkway,+mountain+view,+ca&sensor=true_or_false var geocoder = new geocoder("aizasyapk_c2q882jgkbhj_tskv_xxxxx"); var address = geocoder.reversegeocode(new latlng(latitude, longitude)); i getting location correctly , need show on map after , if redirect google map not refresh automatically, pleaase guide showing map using address .. check link may useful https://forums.asp.net/t/1670688.aspx?google+maps+in+c+web+application

spring boot - storm run springboot development topology has error -

i use springboot develop topology,but when package jar,and run bin/storm jar extlib/se-storm-0.0.1-snapshot.jar cn.ennwifi.storm.application it error. used 3 method package, has error. first,i used maven-assembly-plugin,the detail is: <plugin> <artifactid>maven-assembly-plugin</artifactid> <version>2.4</version> <configuration> <descriptorrefs> <descriptorref>jar-with-dependencies</descriptorref> </descriptorrefs> <archive> <manifest> <addclasspath>true</addclasspath> <mainclass>cn.ennwifi.storm.application</mainclass> </manifest> </archive> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal&g

android - Refactor my viewholder class in kotlin -

i have recycler list holds many different types of item views. quite easy use databinding without necessary declare layout , assignment in viewholder, end many biloplate code create different viewholders databinding, there way rid of them? class viewholder1 private constructor( val binding: viewholder1layoutbinding ): recyclerview.viewholder(binding.root) { companion object { fun create(parent: viewgroup): recyclerview.viewholder { val inflater = layoutinflater.from(parent.context) val binding = viewholder1layoutbinding.inflate(inflater, parent, false) return viewholder1(binding) } } fun bind(viewmodel: viewholder1viewmodel) { binding.viewmodel = viewmodel binding.executependingbindings() } } kotlin supports view binding no need other stuffs binding view. follow steps , able access view id defined in xml layout. in app level gradle add following apply plugin: 'kotlin-android

javascript - How to ensure the selected file count to be either zero or one using javasript -

in application have edit button in gridview user click edit button , when clicks edit button data related particular edited row gets binded corresponding textboxes , fileupload controls @ case user may select file or may not select file if selected count of files should not greater 1 or 0 how can below fileupload contol,update button , edit image code <asp:fileupload id="filuploadmp3" runat="server" width="224px" multiple="multiple" onchange="javascript:return checkwavextension();" /> <asp:button id="btnupdate" runat="server" onclick="btnupdate_click" text="update" width="62px" onclientclick="return validatestuff();" /> <asp:imagebutton id="btn1" runat="server" text="edit" commandname="mybutton" width="20px" imageurl="~/images/page_white_edit.png" tooltip="edit" /> to allo

How to Json Decode in PHP using Services_JSON package of pear(PHP Catchable fatal error: Object of class stdClass could not be converted to string ) -

i want encode/decode array using json . have php 5.1.6 , using pear's ( http://pear.php.net/pepr/pepr-proposal-show.php?id=198 ) package. using can encode , unable decode tried read doc , didn't understand anything.here code: <?php include("/home/gpreeti/php/json.php"); $json = new services_json(); $marks = array( "mohammad" => array ( "physics" => 35, "maths" => 30, "chemistry" => 39 ), "qadir" => array ( "physics" => 30, "maths" => 32, "chemistry" => 29 ), "zara" => array ( "physics" => 31, "maths" => 22, "chemistry" => 39 ) ); $marks=$json->encode($marks); print"$marks\n"; $

How to make read only row in spreadsheet using Google Apps Script? -

i have form response sheet, , wanted make row in read only mode. how can achieve using google apps script or alternate methods available same. thank you! two ways solve this: apps script you want use protection class of spreadsheet ( documentation ). allows access built-in cell protection mechanisms. here's example form documentation making range read-only: // protect range a1:b10, remove other users list of editors. var ss = spreadsheetapp.getactive(); var range = ss.getrange('a1:b10'); var protection = range.protect().setdescription('sample protected range'); // ensure current user editor before removing others. // otherwise, if user's edit permission comes group, // script throw exception upon removing group. protection.removeeditors(protection.geteditors()); if (protection.candomainedit()) { protection.setdomainedit(false); } // range not editable anyone. // add editors list if necessary. protection.addeditor(ses

split - Python Callback Syntax Error -

Image
let me start off code . note, variables present in code defined. call(['youtube-upload', '--title='song + " ~ ["+movie_name +"]", '--description="hi there!\ndon\'t forget enjoy :)"', '--category="song"', '--default-language="en"', '--playlist "'+xx+'"', song2file(song)+'.mp4'], shell=false) error(syntax error): please help missing '+' between '--title=' , song. call(['youtube-upload', '--title='+ song + " ~ ["+movie_name +"]", '--description="hi there!\ndon\'t forget enjoy :)"', '--category="song"', '--default-language="en"', '--playlist "'+xx+'"', song2file(song)+'.mp4'], shell=false)

class - C++ reference to distance is ambiguous -

this question has answer here: issue “using namespace std;” 3 answers why “using namespace std” considered bad practice? 32 answers #include<iostream> using namespace std; class distance {private: int feet1 ,inches1,feet2,inches2,sum1,sum2; public: void getdata() { cout<<"give value of distance in inches , feet"; cin>>feet1>>inches1>>feet2>>inches2; } void add() {sum1= feet1+feet2; sum2=inches1+inches2; } void display() { cout<<sum1<<sum2; } }; int main() { distance x; x.add; x.display; return 0; } i tried write program add distance in feet , inches shows reference distance ambiguous. can me out?

linux - Debian Jessie VM on Hyper-V needs two restarts before hyperv_daemons start -

i'm trying create debian (jessie) vm on hyper-v using packer, preseed file late_command install hyperv_daemons, described here: https://wiki.xdroop.com/space/debian/jessie/hyper-v+integration the problem that, when vm reboots after install, daemons not seem running, hyper-v can't see vm's ip address, can't ssh it, deletes after timeout. if manually turn vm off , on again [sic] when restarts, hyper-v magically able access ip address , packer build completes. the relevant preseed command is: d-i preseed/late_command string \ echo '#!/bin/bash' > /target/usr/bin/hv_get_dhcp_info ; \ echo 'if_file="/etc/network/interfaces"' >> /target/usr/bin/hv_get_dhcp_info ; \ echo 'dhcp=$(grep "$1 inet dhcp" $if_file 2>/dev/null)' >> /target/usr/bin/hv_get_dhcp_info ; \ echo 'if [ "$dhcp" != "" ];' >> /target/usr/bin/hv_get_dhcp_info ; \ echo 'then' >> /target/usr/bi

python 3.x - AttributeError: 'cv2.FileStorage' object has no attribute 'getNode' -

i building project based on python3.4 , opencv3.0 in pycharmce2017 on ubuntu14.04 machine. when running code below, import cv2 if __name__ == "__main__": savepath = "/home/s/desktop/imgcov/" filename = savepath + "depth.xml" fs = cv2.filestorage(filename, cv2.file_storage_read) matrix = fs.getnode("data") i error: attributeerror: 'cv2.filestorage' object has no attribute 'getnode' how can fix this? tips appreciated.

leaflet - creating lealetjs map in an invisible div -

i adding leafletjs map in remarkjs slideshow. map works fine if slide containing map div visible on initial load of web page. however, if slide map div not visible slide map div invisible, leaflet map doesn't work tiles not loaded in div. i'd load map divs in slideshow, no matter slide may on, , have them show when slide containing maps comes up. update: suggested answer seem should answer question, still stuck , not sure if on right track. below more details. since adding many maps slideshow, using class name map divs. // css .map { width: 100vh; height: 100vh; } // html <div class="map" data-lat="47" data-lon="106"></div> <div class="map" data-lat="0" data-lon="0"></div> <!-- possibly on different slide --> <div class="map" data-lat="30" data-lon="28"></div> // js var maps = []; // storing map elements var mapdivs = document.getele

Javascript Closures - Unable to save copy of "count' within an IIFE function -

so have global var called count changes 0 4 in between 2 function declarations (see myfuncs array). i want create closure , save copy of count of 0 1st function , 4 in 2nd function. somehow, though i'm using iife (immediately invoked function expressions) create new lexical scope , saving copy of count (as j), still both pointing count = 4 , when functions executed, first , second function both print out "my value: 4" twice when expected: "my value: 0" "my value: 4" var myfuncs = {}; var count = 0; myfuncs[0] = function(){ (function(){ var j = count; //create closure on count value , save inside iife scope console.log("my value: " + j); //expecting j 0 })(); } count = 4; //update value inbetween 2 function declarations //same above j here should 4 myfuncs[1] = function(){ (function(){ var j = count; //create closure on count value , save inside iife scope console.log("my value:

how to bind the smart table cell with server data in angularjs -

i have ng2-smart-table in angular project. want bind data server smart-table. not work. here code component.ts import { component } '@angular/core'; import { ng2smarttablemodule, serverdatasource } 'ng2-smart-table'; import { http } '@angular/http'; @component({ selector: 'new', template: '<ng2-smart-table [settings]="settings" [source]="source"></ng2-smart-table>', }) export class newcomponent { settings={ columns: { id: { title: 'id', }, albumid: { title: 'number', }, title: { title: 'direction', }, url: { title: 'cost', }, }, }; source: serverdatasource; constructor(http: http) { this.source = new serverdatasource(http, { endpoint: 'http://ec2-35-164-0-168.us-west-2.compute.amazonaws.com/panasonic_dubai/_searc

How to get Web page title in Serenity BDD? what are some other options to varify the Web page? -

i'm verifying web page open through test case. options verify page opened. if still need after week: title use getpages().getdriver().gettitle(); or just getdriver().gettitle(); as how check whether page open – can skip step , wait element. if want wait page, could, example, use class level page object ( @defaulturl ), @at annotations.

database - All my microservices have their own db's, should I create common microservice to handle connections? -

i have number of microservices maintain own databases (mongodb, elastic, mysql) , each of microservices have set-up new connection constantly. i considering wise if created microservice, handle these connections microservices, before start up. example: api gateway microservice gets request search, calls search microservice, before search starts, calls database setup miscroservice , returns established connection it, based on microservice called (in case - search microservice). would better, if found out connection needed inside api gateway? or should leave logic separately in each microservice. you break microservices encapsulation assuming type of persistence each microservice using. each microservice should free use whatever persistence type wants or change when wants transparently, without notifying or requesting permission other microservices this.

request - Python 2/3: Get name and extension of file at URL -

when download file: https://drive.google.com/uc?export=download&id=0b4ifintpkesatwzxwjeyd1fsrg8 chrome knows named testzip2.zip , downloads download folder name. how can name in python (in way works in both python 2.7 , 3.x)? my previous approach: response = urlopen(url) header = response.headers['content-disposition'] original_file_name = next(x x in header.split(';') if x.startswith('filename')).split('=')[-1].lstrip('"\'').rstrip('"\'') seems not work reliably - , randomly fails keyerror: 'content-disposition' , or attributeerror: 'nonetype' object has no attribute 'split' you can use import re ... content_disposition = response.headers.get('content-disposition') match = re.findall(r'filename="([\w\d\.]+)"', content_disposition) filename = match[0] however in python 3, there handy method on httpmessage object filename. filename = re

checkbox - How to connect dynamic checboxes with dropdown list in jQuery -

you click checkbox, same selected on select list/drop-down list , reverse. select on select list , checkbox checked, 1 in time selection. <html> <head> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> </head> <body> <form> <h3>select color</h3> <div id="checkboxes"> <label for="red"> <input type="checkbox" id="red" value="0" onclick="selcolor(0);" >red</label> <label for="blue"> <input type="checkbox" id="blue" value="1" onclick="selcolor(1);" checked>blue</label> <label for="green"> <input type="checkbox" id="green" value="2" onclick="selcolor(2);" />green</label> &l

javascript - TypeError: Cannot read property 'http' of undefined -

this question has answer here: how access correct `this` inside callback? 5 answers im trying put in rest api, keep getting typeerror. import { component, oninit, inject, injectable } '@angular/core'; import { authservice } "../core/auth.service"; import { httpclient, httperrorresponse } '@angular/common/http'; import * firebase 'firebase/app'; //firebase sdk @injectable() export class loginservice implements oninit { constructor(public auth: authservice, private http: httpclient) { } ngoninit() { } lastlogin() { firebase.auth().currentuser.getidtoken(true).then(function(idtoken) { // send token backend via https //console.log(idtoken); const req = this.http.put('https://dev-api.byrd.news/v1/login', { user_token: idtoken }) .subscribe( res => { con

enterprise architect - Can we add a comment column next to the Change column in Audit View of EA? -

is there provision store user entered comment during modification “model” can shown in “audit view” along “original” , “change” columns of ea. can add comment column next change column in audit view of ea, user entered comment can stored. please suggest ea api same. you can not that. might modify underlying database , add columns existing tables (or add private tables). break xmi export these columns not ex-/imported , you're on own maintain this. alternative use tagged values in general cases. here doubt it's feasible. own table foreign key referring audit choice. however, merely sound you're trying re-build check-in mechanism. fwiw: in practice found mechanism counter-productive people tend comment either nothing or trivialities. hinders more helps. you can not modify standard dialogs (e.g. fo shown audit view). means have write add-in create own dialog. the table contains audit t_snapshot .

Duck Spyder as a launcher which is installed through Anaconda on Ubuntu17.4 -

after installing anaconda(3 or higher) includes spyder. isn't known independent application. problem kind of having spyder ubuntu doesn't allow duck or add spyder shortcut on desktop or add favorite. therefore, every time need run spyder, have run through command line: $ spyder not best , fast way run it. on other hand, have spyder , based on it's official website not recommended have double installed: https://pythonhosted.org/spyder/installation.html so need way allows me have shortcut spyder on desktop or favorites list or on duck. after searching lot, here has worked me: copy launcher /usr/share/applications/. right click , go properties, change command line spyder path: ~/anaconda/bin/spyder note: can spyder path typing: $ spyder change rest of info description , icon well. changing icon: after having app copied app , has got new name, description , ... want change icon well. need double click on app icon, ask choose icon. have 2 ways, first

scientific computing - Solve linear system of equations with free variables MATLAB -

this 3*5 matrix , there 2 free variables. don't know if best way solve in matlab. doesn't work , output empty sym: 0-by-1 clear x_1 x_2 x_3 x_4 x_5 syms x_1 x_2 x_3 x_4 x_5 eqn1 = x_1+0*x_2+3*x_3+2*x_4-4*x_5==4 ; eqn2 = 2*x_1+x_2+6*x_3+5*x_4+0*x_5==7 ; eqn3 = -x_1+x_2-3*x_3-x_4+x_5==-5 ; tic ; res = solve([eqn1,eqn2,eqn3]) ; toc ; you don't need symbolic math toolbox simple system of linear equations. you're better off using mldivide , common enough has shorthand \ . for system ax = b , x vector of x values, a matrix of coefficients, , b product (right hand side of system), can solve x = a\b; so a = [1 0 3 2 -4; 2 1 6 5 0; -1 1 -3 -1 1]; b = [4; 7; -5]; x = a\b >> ans = [0; 0; 2; -1; 0]; you can manually check result ( x3=2, x4=-1, x1=x2=x5=0 ) works.

python - Error while setting the current working directory using win32com os.chdir() -

i trying open excel sheet in directory. using win32com this. this, set directory excel sheet , tried opening excel sheet. , error. sheet, however, opens fine, when supply full path open() function. i corrected code (below working code). # import statements win32com.client import dispatch import os # test_path_02 works # test_path_02 = 'c:\\users\\shardul.kumar\\pythoncode\\testdir\\' test_path_01 = r'c:\users\shardul.kumar\pythoncode\testdir\\' # set current working directory os.chdir(test_path_01) print (os.getcwd()) xlapp = dispatch('excel.application') # name of excel sheet file_list = os.listdir(test_path_01) item in file_list: print item file_path = (test_path_01 + file_list[0]) print (file_path) # supplying file_path works fine # xlwb = xlapp.workbooks.open(file_path) # below statement gives error; supplied file name xlwb = xlapp.workbooks.open(file_list[0]) xlapp.visible = true but question is: why open() function not work if full path

php - DWL with INNER JOIN doesn't work when LIMIT applied -

i'm trying create simple pagination using bootpag.js in order fetch data i've created pdo script inner join because need , display user team names table need apply limit set page selection. this troublesome code, session_start(); include_once("../iconnect/handshake.php"); include_once ("../functions/usercheck.php"); if (isset($_request["page"])){ $page_number = filter_var($_post["page"], filter_sanitize_number_int, filter_flag_strip_high); if(!is_numeric($page_number)){die('invalid page number!');} //incase of invalid page number }else{ $page_number = 1; } $perpage = 3; //get current starting point of records $position = (($page_number-1) * $perpage); //data base join team names teams data base $getusers = "select userlogin.*, teams.teamname userlogin inner join teams on teams.tid = userlogin.uteam order uid desc limit :place, :item_per_page"; $getusersquery = $dbconnect -> prepare($getusers)