Posts

Showing posts from September, 2015

elasticsearch - what is the equivalent data type for geo_point in hibernate search? -

i using elastic search hibernate search.i want make 1 property data type geo_point ,so can draw tile map using kibana.is there equivalent data type in hibernate search geo_point in elastic search? you can use spatial feature of hibernate search: import org.hibernate.search.annotations.*; @entity @indexed @spatial public class hotel { @latitude double latitude @longitude double longitude // ... } you end geo_point field named location in document. for more information: https://docs.jboss.org/hibernate/stable/search/reference/en-us/html_single/#spatial wiki

ROS vtk and kubuntu problems -

i trying compile ros-package downloaded here . follow instructions , have installed ros lunar, since running kubuntu 17.04. now, when run rosmake dvo_core i following in cmake: -- imported target "vtkrenderingpythontkwidgets" references file "/usr/lib/x86_64-linux-gnu/libvtkrenderingpythontkwidgets.so" file not exist. possible reasons include: * file deleted, renamed, or moved location. * install or uninstall procedure did not complete successfully. * installation package faulty , contained "/usr/lib/cmake/vtk-6.3/vtktargets.cmake" not files references. -- imported target "vtk" references file "/usr/bin/vtk" file not exist. possible reasons include: * file deleted, renamed, or moved location. * install or uninstall procedure did not complete successfully. * installation package faulty , contained "/usr/lib/cmake/vtk-6.3/vtktargets.cmake" not files references. and thereafter: /usr/bin/ld: /usr/lib/l

Jenkins: find build number for git commit -

each commit git repo triggers build of jenkins pipeline. i want retrieve buildnumber of old build commit hash. how can that? i know information exists because can find in ui. some background why want this: when tags commit want create release (by tagging docker image). each build push image containing build number. want find out build number corresponds commit can find image want release. if understand question correctly, first need create git hook trigger new build. part covered in answer how react new tags in git hooks? ', though if using github, bitbucket or gitlab, there may other ways of going it. then when build initiated, there build number provided variable ' build_number ' ,in jenkins. if want include git tag name, can use in script, there seems fews ways: git parameter plugin git tag message plugin typically these plugins create environment variable can consumed scripts. not providing more concrete examples, since not aware of exact

firebase - How to wait value in Ionic 2 -

i'm trying wait value may change after execute "this.bookmarlist.take(1).subscribe(..." my problem when run application, execute second if statement "if(found==false)" before execute subscribe. this code may found thing wrong or need add additions solve problem. let loader = this.loadingctrl.create({ content: "", }); let found=false; loader.present().then(()=>{ this.bookmarklist.take(1).subscribe(data=>{ data.foreach(b=>{ if(b.nid==this.appservice.id && b.url==url){ let alert = this.alertctrl.create({ title: 'already bookmarked', subtitle: 'this note image bookmarked', buttons: ['ok'] }); alert.present(); found=true; } }) }) }).then(()=>{ if(found==false){ this.afd.list('/bookmark/').push({ uemail: th

typescript - Typings for sub-folders inside a root index.d.ts -

we created typings material-ui@next , want ship them library, did last beta. here link index.d.ts . but typings not usable in current form. in development used locally , worked fine, when shipping files library typescript seems use different discovery strategy. all typings reference subfolder (e.g. declare 'material-ui/button/button' ) not found typescript. when importing components error show up: [ts] not find declaration file module 'material-ui/button/button'. '<project path>/node_modules/material-ui/button/button.js' implicitly has 'any' type. try `npm install @types/material-ui/button/button` if exists or add new declaration (.d.ts) file containing `declare module 'material-ui/button/button';` does typescript not accept declaring other imports when used inside npm_modules folder? because said, using them locally or moving them @types/material-ui make them work. also, typescript seems find index.d.ts , because impor

python - Minimize function with Scipy minimize -

trying obtain d value (integer) std_diff objective function minimal, using scipy minimize. my code: def std_diff(d): return std(diff(df['bn'].values,d)); scipy.optimize import minimize b=(3,) res = minimize(std_diff,(1,), method='slsqp', bounds = b) **df['bn'].values** out[72]: array([ 2, 2, 2, 2, 3, 2, 7, 5, 7, 11, 8, 2, 11, 7, 15, 8, 7, 12, 21, 19, 32, 35, 40, 35, 21, 19, 25, 20, 40, 80, 99], dtype=int64) error is"indexerror: many indices array " in case not use bounds : res = minimize(std_diff,(1,), method='slsqp'), error: > in _minimize_slsqp(func, x0, args, jac, bounds, constraints, maxiter, > ftol, iprint, disp, eps, callback, **unknown_options) > 368 fx = float(np.asarray(func(x))) > 369 except: > --> 370 raise valueerror("objective function must return scalar") > 371 # compute constraints > 3

highcharts - Displaying highest value in high chart (on pie chart) -

how display highest value , show untested values in pie chart? please check url clarification all helps appreciated. you can use chart.renderer() function add custom text chart. take @ example prepared you. api reference: http://api.highcharts.com/highcharts/renderer.text http://api.highcharts.com/highcharts/legend example: http://jsfiddle.net/0k86pb18/ wiki

app store - Does Apple reject the app if Bundle Display Name and iTunes app name are not identical? -

does apple reject app if bundle display name , itunes app name not identical? ex : app name abc, itunes doesn't let me use in app store it's taken else. so, i'm going change abc - country name. does make confusion user? , app rejected apple? always maintain app names in itunes connect , displayed on device should similar, not cause confusion. please refer 3.4 apple review guide. apple review guide wiki

java - How to ignore inner/nested classes with JaCoCo? -

i'm trying ignore generated classes, , classes ignored fine. if classes have inner classes, classes still included, despite parent class being excluded. configuration: <plugin> <groupid>org.jacoco</groupid> <artifactid>jacoco-maven-plugin</artifactid> <version>0.7.9</version> <executions> <execution> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>report</id> <phase>prepare-package</phase> <goals> <goal>report</goal> </goals> <configuration> <excludes> <exclude>**/*db.*</exclude> <exclude>**/*dto.*</exclude> </excludes> </configuration&

API for hotels and room rates -

i'm working on project need colllect list of hotels selected area, , room rates hotels. looked many popular ones ean, hotelscombined, bookings.com have booking requirements (for example, ean requires @ least 1 booking every 5000 requests). i'm not doing bookings in project, need gather data analysis. can point me in right direction? wiki

bash - How to read XML and write to text file using shell script? -

how read xml tags , it's value in shell script? searched , found possible when know tag name. but, want script reads tags in xml(repeated tags), contains values. in xml, tags may change. so, want script can work different xmls. <data> <employees> <employee location = "paris"> <name> andy </name> <id> 101 </id> </employee> <employee location = "germany"> <name> batman </name> <id> 202 </id> </employee> </employees> </data> i want read xml , write text file below: name : alex id: 101 location: paris name : batman id: 202 location: germany try following , let me know if helps you. awk ' /<\/data>/{ a=""; next } /<data>/{ a=1; next } /location/ && a{ gsub(/\"|>/,"",$nf); location=$nf; next } /

java - How do I locate an element whose partialTagValues are dynamic -

i error saying 'an invalid or illegal selector specified'. note:- in last findelement statement, have given cssselector ("//td[id*='verificationmsg']/p[2]) because id closest unique locator find capture data. , part of doesn't change. eg:- current id value id="m_7959323670053369637verificationmsg" number keeps changing in recurring emails "verificationmsg" part of doesn't. this in reference previous question , suggestions got package amazon; import java.awt.awtexception; import java.awt.robot; import java.awt.event.keyevent; import java.util.iterator; import java.util.set; import java.util.concurrent.timeunit; import org.openqa.selenium.by; import org.openqa.selenium.keys; import org.openqa.selenium.webdriver; import org.openqa.selenium.webelement; import org.openqa.selenium.chrome.chromedriver; import org.openqa.selenium.interactions.actions; public class verifyamazonsigninpage { public static void mai

ruby on rails - string interpolation in Get URI with httparty issue -

so using splunk rest api generate search id thorugh post , search results through request. i using httpparty, & post , request follows: def sid self.class.post( "/services/search/jobs", headers: {'content-type' => 'application/json'}, basic_auth: @auth ).parsed_response end the generated sid looks this: 1503402217.608 i make necessary request follows: def results(sid) self.class.get( "/services/search/jobs/#{sid}/results/", headers: {'content-type' => 'application/json', 'accept' => 'text/html'}, basic_auth: @auth ) end the above request gives 204 no content. if manually paste sid in code , run it, results back. for eg: "/services/search/jobs/1503402217.608/results/" so question how can interpolate above results back. edit: dyamic request looks in console: <- "get /services/search/jobs/1503402217.608/res

android - Alternate of ActivityManager.getRunningServices(int) after Oreo -

i shocked this deprecated , return caller's own services on oreo(api 26). there alternative way list of services on oreo? wiki

sbt.ResolveException: unresolved dependency: org.apache.predictionio#pio-build;0.11.0-incubrating -

hi new predictionio( v 0.11.0-incubrationg spark- 2.1.0 elasticsearch- 5.2.1 hbase - 1.2.6)and using template https://github.com/alexice/template-scala-parallel-svd-item-similarity . template compaitable min 0.9.2 version of predictionio , require apache pio conversion . replaced io.prediction org.apache.predictionio , changed version 0.11.0-incubrating in files(build.sbt,template.json,project/assembly.sbt,project/pio-build.sbt) after in template folder ran pio build --verbose , git following error : [info] [engine$] [warn] :::::::::::::::::::::::::::::::::::::::::::::: [info] [engine$] [warn] :: unresolved dependencies :: [info] [engine$] [warn] :::::::::::::::::::::::::::::::::::::::::::::: [info] [engine$] [warn] :: org.apache.predictionio#pio-build;0.10.0-incubrating: not found [info] [engine$] [warn] :::::::::::::::::::::::::::::::::::::::::::::: [info] [engine$] [warn] [info] [engine$] [warn] note: unresolved dependencies have att

javascript - Form with two submit buttons with different actions -

so have form has 3 buttons <td > <input type="submit" id="stsave" class="button button_save pointer" value=""/> <input type="submit" id="stsavereturn" class="button button_save_return pointer" value=""/> <button id="stcancel" class="button button_cancel pointer simplemodal-close"></button> </td> when click save. saves , modal stays open. great when hit cancel closes. great however can't figure out how go making when click save , return submit form , close modal. tried add onclick() event triggers before submit seems. here form deceleration looks like. <form:form method="post" action="${ctx_path}/admin/statepost" commandname="detailsdto" enctype="multipart/form-data"> you use jquery listen submit event of stsavereturn input.

android - Cursor adapter or Custom adapter for chat application -

i developing chat application along file transfer. and using custom adapter taking messages database using db-flow in list. i want know benefit of cursor adapter on custom adapter in chat application. and want show file transfer upload progress, should use notifydatasetchange() or notifyitemchanged() wiki

android - Webpage with gif not working in WebView -

i've been searching quite while cant seem crack problem. have script on webpage, simple html page javascript behind it. gets random gif giphy, , when finishes, gets one, , one... infinitely. i want show gif infinite generator in android application. i'm using webview: webview wb = (webview) findviewbyid(r.id.webgif); wb.getsettings().setjavascriptenabled(true); wb.getsettings().setdomstorageenabled(true); wb.getsettings().setloadwithoverviewmode(true); wb.getsettings().setsupportzoom(true); wb.getsettings().setdefaulttextencodingname("utf-8"); wb.setwebviewclient(new webviewclient(){ @override public boolean shouldoverrideurlloading(webview view, string url) { view.loadurl(url); return true; } @override public void onpagefinished(webview view, final string url) { } }); wb.loadurl("http://vladmarton.com/rangif/index.html"); i tried, google.com

java - JPA query works with number but not with Integer variable -

i have written code retrieving list of object postgres db. query gives me correct result if write value of id_utente_pres (for example 68) in criteria. if use integer variable called "id" result set empty. code retreive correct result set: public list<prenotazione> getprenotazioni(integer id) throws remoteexception { session session; session = sessionfactory.opensession(); criteriabuilder builder = session.getcriteriabuilder(); criteriaquery<prenotazione> criteria = builder.createquery(prenotazione.class); root<prenotazione> prenotazionefind = criteria.from(prenotazione.class); criteria.select(prenotazionefind); parameterexpression<integer> p = builder.parameter(integer.class); criteria.where(builder.equal(prenotazionefind.get("id_utente_pren"), 68)); list<prenotazione> prenotazioniutente = session.createquery(criteria).getresultlist(); session.close(); return prenotazioniutente; }

raspberry pi3 - Pi - enable dbus for development -

i new developing on linux. write applications talk on dbus learning basic concepts of interacting dbus. i'm working on new-ish raspberry pi 3; can see dbus folders on various locations on filesystem. however, when #include <dbus/bus.h> error: "unresolved include file" leads me believe library files or developer options not enabled dbus? i wanted find out how can enable dbus development? thanks in advance. 24 aug 2017 edit: believe have necessary library files i.e. (but not limited to...) /usr/lib/arm-linux-gnueabihf/libdbus-1.a /usr/include/dbus-1.0/dbus/dbus.h but how point netbeans ide them while developing on remote host (the pi)?? 28 aug 2017 edit: after installing dbus-dev libraries. removed , re-added raspberry pi local host on netbeans ide. now, when i #include <dbus/dbus.h> or #include <dbus.h> i receive error: fatal error: dbus/dbus.h: no such file or directory so, ended having add /usr/include/dbus-1.0;/usr

java - Sorted insert position -

problem statement :given sorted array , target value, return index if target found. if not, return index if inserted in order. may assume no duplicates in array. here few examples. [1,3,5,6], 5 → 2 [1,3,5,6], 2 → 1 [1,3,5,6], 7 → 4 [1,3,5,6], 0 → 0 my code : public class solution { public int searchinsert(arraylist<integer> a, int b) { int low = 0, high = a.size()-1; int mid = (low+high)/2; int retindex = mid; while(low<=high){ if(a.get(mid)<b){ low = mid+1; mid = (low+high)/2; retindex = low; } else{ high = mid-1; mid = (low+high)/2; if(high<0) retindex = 0; else retindex = high; } } return retindex; } } but there flaw in code (returning 1 less or more index on large inputs futile put here) can directly check here , unable figure out. can point out mistake? or correct code problem? edit: presenting precise input g

How to use additional dimension : direct sessions to the google studio -

in google analytics can add additional dimension named: direct sessions gives 2 values : yes , no. problem when im making reports in google studio dont have kind of dimension. maybe there possible add dimension manually? t. if have created custom dimension in ga available in google data studio (i assume mean "google studio"). currently google analytics connector provides access data available in custom reports. not provide access multi-channel funnels or real-time data. however, custom dimensions , metrics available in data studio. you can select other dimension (use search feature , name gave dimension in ga property settings). source wiki

c++ - Cppcheck into Jenkins with QT project -

Image
i have server jenkins , qt project. server runs on centos 7. installed " cppcheck " server installed " cppcheck plug-in " plugin jenkins. the script build project: cd flashclipboard; /usr/lib64/qt5/bin/qmake flashclipboard.pro; make clean; make; cppcheck --enable=all --suppress=missingincludesystem . --xml --xml-version=2 . 2> ./tmp/cppcheck.xml; post-build actions: but have error: [cppcheck] starting cppcheck analysis. [cppcheck] processing 1 files pattern 'tmp/cppcheck.xml'. [cppcheck] parsing throws exceptions. javax.xml.bind.unmarshalexception - linked exception: [org.xml.sax.saxparseexception; systemid: file:/var/lib/jenkins/workspace/flash%20clipboard/tmp/cppcheck.xml; linenumber: 1; columnnumber: 1; premature end of file.] build step 'publish cppcheck results' changed build result failure build step 'publish cppcheck results' marked build failure what mistake? sorry su

What is the correct layout to detect Aruba Beacon with AltBeacon's Android Beacon Library? -

according library, detect proprietary beacons, must add line below corresponding beacon type. need know correct proper expression "setbeaconlayout". example: beaconmanager.getbeaconparsers().add(new beaconparser(). setbeaconlayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25")); thanks help based on aruba beacon data sheet here: http://www.arubanetworks.com/assets/ds/ds_locationservices.pdf , appears beacons transmit ibeacon format. you can find beacon layout along others here: https://beaconlayout.wordpress.com/ wiki

c++ - const_cast 'this' in const method to assign 'this' to outer variable? -

have @ following code: struct foo; foo* bar; struct foo { void func() const { bar = this; } } int main() { foo().func(); } this not work bar won't accept const foo* . around this, const_cast used: struct foo { void func() const { bar = const_cast<foo*>(this); } } is safe? i'm cautious when comes using const_cast , in case seems legit me. no, potentially dangerous. func() marked const means can called const object: const foo foo; foo.func(); because this const foo* . if const_cast away const end foo* const object. means modification object through non-const pointer (or through copy of pointer, bar in case) undefined behavior since not allowed modify const object (duh). plus obvious problem you're lying consumer of class foo saying func() won't modify while you're doing opposite. const_cast never correct , seems xy-problem me. wiki

osx - Outlook add-in does not return message from dialog on MacOS -

i developing outlook add-in , displaying dialog using office api: office.context.ui.displaydialogasync(url, dialogoptions, function (result) { logindialog = result.value; logindialog.addeventhandler(microsoft.office.webextension.eventtype.dialogmessagereceived, receiveloginmessage); logindialog.addeventhandler(microsoft.office.webextension.eventtype.dialogeventreceived, logindialogclosed); event.completed(); }); on windows works both on desktop app , browsers (including chrome). however, when want run on outlook mac not return message dialog. dialog displayed, has functionality, when want send message stays open. vorlon.js throws in mainwindow: messages received cannot handlered. message:{"dialogmessage":{"messagetype":0,"messagecontent":"{ …here content... }”}} any idea if can handle this? wiki

File uploade with additional Data (Javascript, PHP) -

i want uploade file , send additional data (an array) php script. here html , javascript code: <input type="file" name="fileinput" id="fileinput"> <button class="btn btn-primary" id="btnupload">upload</button> <script> $('#btnupload').click(function(){ var formdata = new formdata(); formdata.append("macstochangeimage", selectedmacs.tostring()); //selectedmacs array want send formdata.append("userfile", $('#fileinput').files[0]); $.ajax({ url: "changeimagesfunction.php", type:'post', data: formdata, processdata: false, cententtype: false, success: function(data) { alert('success' + data); }, error:function(response){ alert(json.stringify(response)); } }); }); </script> and here ist php code: if(!empty($_files)) { $target_dir = "img/epd_uploads/"; $temporaryfile = $_files['userfile

javascript - Why don't jquery datatable get filled with newly updated data after searching? -

i filling jquery datatable (ver: 1.10.15) webapi , works when search in datatable via searchbox doesn't fill datatable updated data. why? i checked, sends search value , brings updated data server doesn't populate table newly returned data. function show() { $('#example').datatable({ // "processing": true, "serverside": true, "retrieve": true, "destroy": true, "pagination": true, // "contenttype": 'application/json; charset=utf-8', "ajax": "http://localhost:28071/users" }); } update: c# api code: namespace webapihimher.controllers { public class userscontroller : apicontroller { [httpget] public dtresult getdata([fromuri]dtparameters v) { list<string[]> s = new list<string[]>(); //list<basicoperations> s = new list<basicoperations>()

java - Explanation about Parcelable Interface -

i'm studying interface parcelable , i'm facing problems trying understand how works. on internet didn't find answers of questions: i show class: public class media implements imodel, parcelable{ private uri uri; private long _id; private boolean isondb = false; private boolean isselected = false; /*getter , setter methods ........ */ /*********************************** parcelable **********************************/ public static final parcelable.creator creator = new parcelable.creator<media>(){ @override public media createfromparcel(parcel parcel) { return new media(parcel); } @override public media[] newarray(int i) { return new media[i]; } }; @override public int describecontents() { return 0; } @override public void writetoparcel(parcel parcel, int i) { parcel.writeparcelable(uri, 1); pa

c++ - Multithreaded MD5 Hashing -

i'm trying multithread program wich take word file hash these , write another. if make without multithreading it's fast, it's able use 15-20% of cpu , has out 300.000line/s but when tryied multithreading slow down , start hash @ 17000lines/s, can please me? thanks #include <iostream> // std::cout, std::streambuf, std::streamsize #include <fstream> // std::ifstream #include <string> #include <thread> #include "md5.h" using namespace std; static const int num_threads = 10; void call_from_thread(int tid) { cout << "launched thread " << tid << std::endl; int cl = 0; int uscita = 0; int parole = 0; char* contents; ifstream istr("test.txt"); if (istr) { streambuf * pbuf = istr.rdbuf(); streamsize size = pbuf->pubseekoff(0, istr.end); pbuf->pubseekoff(0, istr.beg); // rewind contents = new char[size]; pbuf-

javascript - D3: Zooming/Panning Line Graph in SVG is not working in Canvas -

i created zooming/panning graph d3 using svg . i'm trying create same exact graph canvas . issue is, when comes zooming , panning of canvas graph, graph disappearing , cannot figure out why. created 2 jsbin's show code of both. can assist me. svg - jsbin canvas - jsbin my svg zoom code looks this: // zoom components zoom = d3.zoom() .scaleextent([1, daydiff*12]) .translateextent([[0, 0], [width, height]]) .extent([[0, 0], [width, height]]) .on("zoom", zoomed); function zoomed(){ t = d3.event.transform; xscale.domain(t.rescalex(x2).domain()); xaxis = d3.axisbottom(xscale).ticksize(0).tickformat(d3.timeformat('%b')); focus.select(".axis--x").call(xaxis); //xaxis changes usagelinepath.attr('d',line); //line path reference, regenerate } my canvas zoom code looks this: // zoom components zoom = d3.zoom() .scaleextent([1, daydiff*12]) .translateextent([[0, 0],

pandas - Python - Compare two columns of features, return values which are not common to both -

i compare 2 columns of features("a", "b") , return values not common both. rows of unequal size, , values may occur more once. i tried: a[np.logical_not(np.in1d(a,b))] but doesn't seem work if len(b) > len(a) any suggestions? iiuc looking symmetric difference : source dfs: in [41]: d1 out[41]: 0 1 b 2 c 3 x 4 d 5 l 6 z in [42]: d2 out[42]: b 0 b 1 2 d 3 c 4 y numpy solution: in [43]: np.setdiff1d(np.union1d(d1.a, d2.b), np.intersect1d(d1.a, d2.b)) out[43]: array(['l', 'x', 'y', 'z'], dtype=object) pandas solution: in [44]: pd.index.symmetric_difference(pd.index(d1.a), pd.index(d2.b)) out[44]: index(['l', 'x', 'y', 'z'], dtype='object') wiki

javascript - How to display exact value using google.visualization.Table -

i'm having trouble displaying exact values using google.visualization.table please see jsfiddle example. it seems defaults 3 decimal places despite more exact values being provided. want show entire value (e.g. 0.000001). below data used: data.addrows([ ['mike', {v: 0.01}, true], ['jim', {v: 0.001}, false], ['alice', {v: 0.0001}, true], ['bob', {v: 0.00001}, true] ]); the table display formatted value default using object notation, can provide both value ( v: ) , formatted value ( f: ) e.g. --> {v: 0.00001, f: '0.00001'} see following working snippet... google.charts.load('current', { callback: drawtable, packages:['table'] }); function drawtable() { var data = new google.visualization.datatable(); data.addcolumn('string', 'name'); data.addcolumn('number', 'salary'); data.addc

javascript - cloudinary.openUploadWidget not working? -

i trying use cloudinary's api allow users upload profile picture on app i'm developing. using 'cloudinary.openuploadwidget' in javascript. so far, good. when try , upload image, getting error: "upload failed: upload preset not found". any experience this? here image upload settings: cloudinary settings looks didn't set upload preset. can cloudinary settings page , selecting "add upload preset". wiki

MongoDb Post formatting of $lookup aggregation with limited data -

i have 2 collection coll1 , coll2. want apply $lookup on fields "_id" , "comm_field" used query: db.coll1.aggregate([ { $lookup: { from: "coll2", localfield: "_id", foreignfield: "comm_field", as: "inventory_docs" } }, { $project:{"_id" : 0, "inventory_docs" : 1} }, { $unwind:"$inventory_docs"} ]) and output as: /* 1 */ { "inventory_docs" : { "_id" : objectid("ssdfsfsdfsdfsfsdfsdfsdfsfsdf"), "comm_field" : numberlong(1111), "status" : "active" } } /* 2 */ { "inventory_docs" : { "_id" : objectid("erteterterterterterterterter"), "comm_field" : numberlong(1111), "status" : "active" } } /* 3 */ { "inventory_docs"

swift - EXC_BAD_INSTRUCTION only in iPhone 5 simulator -

Image
running code on iphone 5 simulator throws exception shown in image. running code on of other simulators fine. i can't spot made mistake in unspectacular line of code. else have problem? nsinteger (which type alias int in swift) 32-bit integer on 32-bit platforms iphone 5. result of nsinteger(nsdate().timeintervalsince1970) * 1000 is 1480106653342 (at moment) , not fit range -2^31 ... 2^31-1 of 32-bit (signed) integers. therefore swift aborts execution. (swift not "truncate" result of integer arithmetic operations done in other programming languages, unless use "overflow" operators &* .) you can use int64 64-bit computations on all platforms: int64(nsdate().timeintervalsince1970 * 1000) in case, if string needed: let lastlogin = string(int64(nsdate().timeintervalsince1970 * 1000)) wiki

php - Faking $_SERVER[‘REMOTE_ADDR’] in intranet? -

i've looked around answer question, answers situational - here's mine: if hacker on limited, local network, can fake ip in $_server[‘remote_addr’]? (and out of curiosity - how?) i understand when comes internet, variable such can wrangled whatever want. in local, wired network may not connected internet @ all, can fake address? i'm assuming mr.missionimpossible crawling along ceiling notebook , ethernet cable 1 of switches. response in scenario won't matter - running php script should limited location(s). thanks in advance! i don't know definite if can faked in general, guess can if know you're doing. intranet tcp/ip network with, in case of website, http layer on top. environment same. so if can done on public internet, can done on internal network too. wiki

c - Share data between two Kernel modules same as Netlink (not via Netlink, but somewhat same mechanism as Netlink) but kernel to kernel -

(updated question after marking duplicate) operating system: fedora 26 alpha linux kernel : 4.13.0-rc5 #1 smp tue aug 15 19:53:44 ist 2017 x86_64 x86_64 x86_64 gnu/linux is possible share data between 2 kernel modules , via netink socket able communicate kernel module user-space program? (please, request read question before mark duplicate question.) i searched on google, got results using symbols export_symbol() , extern in kernel modules. but, don't want use them. i simply, want share data between 2 kernel modules client , server chat application in c in user-space. for this, lets take scenario: there 2 kernel modules, , b. now, after insertion of module , suppose module increment i=1 i++ pass or transfer value module b, module b calculate multiplication table of incremented value (i) module a. wiki

java - Junit tets case for different values return from method every time when i execute and need to compare with enum values -

my method returns different values when ever execute example returns abc 1st execution , cde 2nd execution want assertequla values enum values plz tell me how write junit test case.enum is abc("abc"),cde("cde"); . sample junit tets case @test public void test() { assertequals(enum.abc,mymethod.getvalue()); } to asserteqauls enum, use tostring() method: @test public void test() { assertequals(enum.abc.tostring(), mymethod.getvalue()); } wiki

Simple server-side validation using php -

i have problem validation input , select fields. if inputs empty , click on submit warning "this field required" appears. but when fill clientid input , selection box empty validation fail. or invers, when select box selected , input empty. here code: <!doctype html> <html> <head> <style> .error {color: #ff0000;} </style> </head> <body> <?php $nameerr = $katalogerr = $selectkatalog = ""; $kdn = ""; if ($_server["request_method"] == "post") { if (empty($_post["kdn"])) { $nameerr = "this field required"; } else { $kdn = test_input($_post["kdn"]); // check if kdn contains letters, numbers , whitespace if (!preg_match("/^[a-za-z0-9 ]*$/", $kdn)) { $nameerr = "only letters, numbers , white space allowed"; } } if($_post["selectkatalog"] == 'default'){ $katalogerr = "th

vuejs2 - Simple high-level overview of how to handle Vuejs authentication with JWT -

just need high level overview of how architect this. have authentication js object (es6 class) instantiated once, , uses jwt. import { getroutebyname, getrouter } 'approuter' import axios 'axios' let instance = null class appauthentication { constructor (http, router, localstorage = window.localstorage) { if (!instance) { instance = this.storage = localstorage this.http = http // this.router = router // undefined this.api = http.create({baseurl: someurl, headers: {'authorization': 'bearer ' + this.token}}) this.watchroutes() } return instance } watchroutes () { this.router.beforeeach((to, from, next) => { let login = 'login' if (to.name !== login && this.isloggedout()) { return next(getroutebyname(login)) } next() }) } login (credentials) { return this.http.post(`${some_url}/login`, credentials) } finishauthentication (toke

html - centering text next to an image bootstrap navbar -

Image
i have logo within navbar , have text next it. vertically center text in middle of logo. when try adjust a.navbar-brand moves. need surround @html.actionlink code separate span or div tag , reference within css? <div class="navbar-header"> <a class="navbar-brand"> <img alt="tribal_logo" src="~/content/images/tribal_logo2.gif" /> </a> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> @html.actionlink("fishing , hunting license program", "index", "home", new { area = "" }, new {

Passing a function to Enum.map in Elixir -

i'm learning elixir , wonder if there better way pass function pointer enum.map. have code: defmodule mymodule defp greet(person) io.puts "hello " <> person end def main() people = ["manuel bartual", "el hijo de la tomasa"] enum.map(people, &greet/1) end end it works fine, wonder if there way instead of using &greet/1 more idiomatic be: def main ["manuel bartual", "el hijo de la tomasa"] |> enum.map(&greet/1) end you should not use parentheses when no arguments required in function. the pipeline operator ( |> ) 1 of idiomatic elixir features. says, take result evaluated , call following function passing result first argument. wiki

java - Uploading String to mySQL | syntax error -

i trying connect mysql database using java. seem able connect unable use stmt.executeupdate upload database. token trying upload string in console: 1b7a19bb5d924bc5b13d53c7b2a47394 connected com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception: have error in sql syntax; check manual corresponds mysql server version right syntax use near '1b7a19bb5d924bc5b13d53c7b2a47394' @ line 1 this code have in main class: string token = tokengenerator.generateqr(url, location); tokens.add(token); system.out.println(token); try { conn = drivermanager.getconnection(conn_string,username,password); system.out.println("connected"); statement stmt = (statement) conn.createstatement(); stmt.executeupdate(token); system.out.println("uploaded"); }catch (sqlexception e){ system.err.println(e); } and how create token public static string generateqr(string url, string location) throws exception { string uuid =

mp3 - using nativescript-audio is throwing can not find module error -

i want play mp3 in native script application. , followed introduction, https://www.npmjs.com/package/nativescript-audio install nativescript-audo. but when run, met error: file:///app/modules/rss_player/detail.component.js:7:35: js error error: not find module 'nativescript-audio' i used first: tns plugin add nativescript-audio then import { tnsplayer } 'nativescript-audio'; this._player = new tnsplayer(); can tell me error? do have import special module? one? the git plugin is: https://github.com/bradmartin/nativescript-audio/tree/master/demo/app thanks wiki

scala - What encoding or data type can be used to get alphanumeric string in elixir? -

my goal guess alphanumeric strings bitcoin mining match leading zeros. this, have increment encoded string , check whether string produces expected nonce . for example in scala, can use base36 binary text encoding:- bigint(somealphanumstring, 36) , increment adding bigint(1, 36) our string. what better way same in elixir? integers in elixir arbitrary precision integers, there's no need special bigint data type. can convert base-36 string , integer using string.to_integer/2 , integer.to_string/2 this: iex(1)> = string.to_integer("dogbert", 36) 29776764809 iex(2)> b = + 1 29776764810 iex(3)> integer.to_string(b, 36) "dogberu" wiki

c - Visually what happens to fork() in a For Loop -

Image
i have been trying understand fork() behavior. time in for-loop . observe following code: #include <stdio.h> void main() { int i; (i=0;i<3;i++) { fork(); // printf statement debugging purposes // getppid(): gets parent process-id // getpid(): child process-id printf("[%d] [%d] i=%d\n", getppid(), getpid(), i); } printf("[%d] [%d] hi\n", getppid(), getpid()); } here output: [6909][6936] i=0 [6909][6936] i=1 [6936][6938] i=1 [6909][6936] i=2 [6909][6936] hi [6936][6938] i=2 [6936][6938] hi [6938][6940] i=2 [6938][6940] hi [1][6937] i=0 [1][6939] i=2 [1][6939] hi [1][6937] i=1 [6937][6941] i=1 [1][6937] i=2 [1][6937] hi [6937][6941] i=2 [6937][6941] hi [6937][6942] i=2 [6937][6942] hi [1][6943] i=2 [1][6943] hi i visual person, , way me understand things diagramming. instructor said there 8 hi statements. wrote , ran code, , indeed there 8 hi statements. didn’t understand it. drew following diagr

python - Implementation of image pre-processing methods on android -

could please suggest library (or snippet) implement pre-processing python methods (e.g. numpy.expand_dims() or img_to_array ) on android api 18 (to deploy app based on tensorflow mobile)? there analogous libraries python on java (e.g. nd4j), require device or emulator runs api level 21 or higher. from keras.preprocessing.image import img_to_array import numpy np image = img_to_array(image) image = np.expand_dims(image, axis=0) image /= 255. i interactive session: in [168]: np.source(np.expand_dims) in file: /usr/local/lib/python3.5/dist-packages/numpy/lib/shape_base.py def expand_dims(a, axis): """ .... docs """ = asarray(a) shape = a.shape if axis > a.ndim or axis < -a.ndim - 1: # 2017-05-17, 1.13.0 warnings.warn("both axis > a.ndim , axis < -a.ndim - 1 " "deprecated , raise axiserror in future.", deprecationw

sql - Remove duplicate rows in MySQL -

i have table following fields: id (unique) url (unique) title company site_id now, need remove rows having same title, company , site_id. 1 way using following sql along script (php): select title, site_id, location, id, count( * ) jobs group site_id, company, title, location having count( * ) >1 after running query, can remove duplicates using server side script. but, want know if can done using sql query. a easy way add unique index on 3 columns. when write alter statement, include ignore keyword. so: alter ignore table jobs add unique index idx_name (site_id, title, company); this drop duplicate rows. added benefit, future inserts duplicates error out. always, may want take backup before running this... wiki

django channel set up routing -

i'm learning how setup websocket connection django-channel, i've got setup in routing.py from channels import route gallery import socket sock channel_routing = [ # wire websocket channels our consumers: route("websocket.connect", sock.ws_connect, path=r"^/render-status/$"), route("websocket.receive", sock.ws_receive, , path=r"^/render-status/$"), ] and following javascript // when we're using https, use wss too. var ws_scheme = window.location.protocol == "https:" ? "wss" : "ws"; var ws_path = ws_scheme + '://' + window.location.host + '/render-status/'; console.log("connecting " + ws_path) var socket = new reconnectingwebsocket(ws_path); socket.onmessage = function(message) { console.log("got message: " + message.data); var data = json.parse(message.data); // if action started, add new item table if (data.action == "started")