Posts

Showing posts from January, 2014

xamarin - Detecting which item was clicked in a ListView with a DataTemplate -

i have listview simple datatemplate - image , text. list<menuitem> items = new list<menuitem> { new menuitem ("trade","menutradeiconbig.png"), new menuitem ("profile","menuprofileiconbig.png"), }; var listview = new listview (); var viewtemplate = new datatemplate(typeof(menucell)); //menucell contains grid listview.itemtemplate = viewtemplate; listview.itemssource = items; if listview filled strings, can this: listview.itemtapped += (sender, e) => { menuhandler(e.item.tostring()); //my function process item clicks }; but now, when use this, response converted tostring() "myprojectname.menuitem". how can clicked item? i figured out: listview.itemtapped += (sender, e) => { menuhandler((menuitem)e.item); }; public void menuhandler(menuitem item) { menuitem selec

c# - My scrollview is not working in windows phone 8.1 -

my scrollview not working in windows phone 8.1. here code. please me. textblock see in bind database. fetch data database , show in scrollviewer. suggest me correct code. <phone:pivotitem header="market status"> <grid> <grid.rowdefinitions> <rowdefinition height="auto"/> <rowdefinition height="auto"/> <rowdefinition height="*"/> </grid.rowdefinitions> <button x:name="btnrefresh" grid.row="0" horizontalalignment="center" verticalalignment="bottom" width="80" height="80" borderbrush="transparent" click="btnrefresh_click"> <button.background> <imagebrush imagesource="/assets/icons/refresh2.png"/> </button.backgro

java - running android studio project with google glass -

i trying run application built in android studio google glass. when run application google glass, starts application , blacks out start window again. on android studio following message: 08-07 19:04:19.842 16629-16629/? w/system.err: @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:786) 08-07 19:04:19.842 16629-16629/? w/system.err﹕ @ com.android.internal.os.zygoteinit.main(zygoteinit.java:602) 08-07 19:04:19.842 16629-16629/? w/system.err﹕ @ dalvik.system.nativestart.main(native method) 08-07 19:04:19.842 16629-16629/? i/process﹕ sending signal. pid: 16629 sig: 9 it shows; com.example.glasspitch(16629)[]dead

IIS 7.5 Detailed Error 500.0 - Internal Server Error occurred after enabling ServersideInclude with Windows 7 IIS 8 Express -

Image
i have serversideincludemodule enabled using "turn on/off windows features" control panel. on inetmgr's handlers-mapping suite, have mapped handle .html extension. however after has been done , tried browse default.html (which has <!--#include virtual="includes/navband.html"--> ) gave me above 500.0 - internal server error on url http://localhost/mydir/default.html !! if removed mapping, default page works again of course without include htmls. i have checked permission, users have read , script rights. however, same implementations work fine on windows server 2008 iis7.5 not on local workstation has iis installed on it. remarks: there file navband.html sitting inside .\includes dir. not issue.

VBA variable in SQL date query -

i'm trying query sql database lines date after date given through user input. i've run variety of errors "incorrect syntax near" when surround date "#" "arithmetic overflow error converting expression to". current code looks this: inputdate = inputbox("please enter starting date (mm/dd/yyyy)") debug.print inputdate querydate = "(dtg > " & format(inputdate, "mmddyyyy") & ")" select stationid, dtg, ceilingfeet surfaceob " & querydate & " , stationid = 'nzwd'" dtg column name date-time group in sql database. idea going wrong? i've tried every solution find on past few days without luck. thank in advance. the primary issue dates must enclosed in single-quotes. here complete working example (minus valid connection string) should explain how achieve objective. note want switch iso date format, in order year-month-day ( yyyy-mm-dd ). sub updaterecord

performance - Hive: Is there a better way to percentile rank a column? -

currently, percentile rank column in hive, using following. trying rank items in column percentile fall under, assigning value form 0 1 each item. code below assigns value 0 9, saying item char_percentile_rank of 0 in bottom 10% of items, , value of 9 in top 10% of items. there better way of doing this? select item , characteristic , case when characteristic <= char_perc[0] 0 when characteristic <= char_perc[1] 1 when characteristic <= char_perc[2] 2 when characteristic <= char_perc[3] 3 when characteristic <= char_perc[4] 4 when characteristic <= char_perc[5] 5 when characteristic <= char_perc[6] 6 when characteristic <= char_perc[7] 7 when characteristic <= char_perc[8] 8 else 9 end char_percentile_rank ( select split(item_id,'-')[0] item , split(item_id,'-')[1] characteristic , char_perc ( select collect_set(concat

memory - MemoryError in python with chunked uploading -

i writing server side chunked uploading files. got memoryerror , can`t understand doing wrong. here python code(with framework pyramid): @view_config(route_name='fileupload',renderer='../upload.mako') def upload_file(request): session = request.session if 'authorized' in session , session['authorized'] false: return httpforbidden() try: filename = request.params.get('filename') print request.params.get('chunkindex') datatmp = request.params.get('data') data64 = datatmp[13:] data = base64.b64decode(data64) f = open('/home/somedirectory/' + filename , 'ab') f.write(data) f.close() except exception e: print e return {} error traceback: 2015-07-24 17:57:36,630 error [waitress][dummy-5 340] exception when serving /upload traceback (most recent call last): file "/home/myusername/project25/local/lib/python2

Oracle 12c ojdbc7 driver causing issues with result.getString("DATE_COLUMN") -

we in process of upgrading oracle 12c , using ojdbc7(12.1.0.2.0) driver. noticed while fetching date column table using resultset.getstring("date_column"), returning daylight saving adjusted time well. please note db located in cst timezone. say e.g. if date in column inserted "2014-03-09 02:30:00" way day when daylight saving started in in 2014. here line of code used fetch value. string sql = "select date_column a_table"; resultset rs = psmt.executequery(sql); while (rs.next()) { string datestring = rs.getstring("date_column"); } here results of code snippet 2 different drivers. odjbc6(11.2.0.3.0) - 2014-03-09 02:30:00 ojdbc7(12.1.0.2.0) - 2014-03-09 03:30:00.0 if see highlighted time fields, can see fetching 3:30:00.0 instead of 2:30 ojdbc7 driver, suggests driver getting daylight savings adjusted time of local timezone of database server, in our case cst, us. i part appending fractional

How to apply different conditions for multiple min value validation in jQuery Validation Plugin? -

i want validate field using jquery validation plugin. want field have minimum value, depending on other conditions. if conditions satisfied, want minimum value required 3, otherwise want 4. how achieve it? the logic - education: { min: { param: 3, depends: function(element) { return ( /*conditions*/ ); }, param: 4, depends: function() { return ( /*otherwise*/ ); }, }, }, try setting handler check condition want , set min value accordingly element if(condition){ $('#education').rules("add",{min:3}); } else { $('#education').rules("add",{min:4}); } as example check out jsfiddle http://jsfiddle.net/5rrga/1487/

javascript - Using ui-tagging with single choice -

i'm newbie on angularjs , angular-ui , have problem module ui-select. need select single element list , if there isn't value, user can add manually, tagging system of ui-select doen't work single value , don't know why. this ui-select code: <ui-select tagging="tagstation" tagging-label="(add station)" ng-model="new.station"> <ui-select-match placeholder="choose or add">{{$select.selected.label}}</ui-select-match> <ui-select-choices repeat="station.value station in stationlist | filter: { label: $select.label }"> <div ng-bind-html="station.label | highlight: $select.search"></div> </ui-select-choices> </ui-select> and function tagging attribute: $scope.tagstation = function (newtag) { var item = { label: newtag, value: 0 }; return item; }; can me? thx ch

variables - Dynamically calling upon similar objects in javascript? -

i apologize in advance title, had no idea how word i'm trying ask (and if similar question asked before, wouldn't have known how search it). have 4 similar objects in program, , such have differentiated them so: var person1object = { foo: [], bar: [] } var person2object = { foo: [], bar: [] } var person3object = { foo: [], bar: [] } var person4object = { foo: [], bar: [] as variable counts 1 through 4 through function when button pressed, so: var count = 1; function count() { if (count < 4) { i++; } else { = 1; } } $("#button").on("click", function () { count(); }); i trying this: person+count+object.foo.push("some value"); person+count+object.bar.push("some other value"); but when that, console says (and i'm assuming rightfully so) person not defined . i have tried using array so: var personobject = [person1object, person2object, person3object, person4

javascript - Dynamically add number of options in a Dropdown list -

i have number value coming database. want display dropdown list based on count of number. example if number 5 need display 1-5 options in dropdown list. can 1 guide me on this? thanks responses. if database returns 5 , puts in variable "number" this: <form> <select id="myid"></select> </form> <script> var number=5; var optionlist = ""; (var x=1; x<=number; x++) { optionlist += "<option>"+x+"</option>"; } $("select#myid").html(optionlist); </script>

php - Symfony2 Doctrine one to one mapping -

so i'm trying make 1 one relationship in symfony2 doctrine i'm getting following error: an exception has been thrown during rendering of template ("could not resolve type of column "id" of class "intopeople\databasebundle\entity\feedbackcycle"") in intopeopledatabasebundle:feedbackcycle:index.html.twig @ line 65. i have 2 entities, feedbackcycle , cdp. in feedbackcycle have: /** * @var \intopeople\databasebundle\entity\cdp * * @orm\onetoone(targetentity="intopeople\databasebundle\entity\cdp", inversedby="feedbackcycle") * @orm\joincolumns({ * @orm\joincolumn(name="cdpid", referencedcolumnname="id") * }) */ private $cdp; /** * set cdp * * @param \intopeople\databasebundle\entity\cdp $cdp * * @return feedbackcycle */ public function setcdp(\intopeople\databasebundle\entity\cdp $cdp = null) {

c++11 - serialize temporary into boost archive -

the following not possible boost output archive: int foo(){ return 4; } ar << static_cast<unsigned int>(foo()); is there alternative without out creating local temporary x=foo() . and why underlying archive operator <<(t & t) not const reference , output archive such above work? this seems work, , think this why: ... detect such cases, output archive operators expect passed const reference arguments. it seems worth noting in example ar << foo(); not work either (i.e. doesn't have cast). #include <fstream> #include <iostream> #include <boost/serialization/serialization.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_oarchive.hpp> unsigned int foo(){ return 4; } int main() { { std::ofstream outputstream("somefile.txt"); boost::archive::text_oarchive outputarchive(outputstream); outputarchive << static_cast<const int&

javascript - How can make random images come out from the holes in Whack-a-Mole game instead of one image -

i wondering able me show me way able bring out random images holes instead of 1 image in whack mole game on javascript. following function used image come in random holes. 1 image i'd 10 different images coming out. var wormimg = new image(); var worm; wormimg.src = 'hobby.png'; wormimg.name = 'worm'; wormimg.onload = loadgfx; function showworm() { if(currentworms == totalworms) { showalert(); } else { if(lastworm != null) { lastworm.onpress = null; stage.removechild(lastworm); stage.update(); lastworm = null; } var randompos = math.floor(math.random() * 8); var worm = new bitmap (wormimg); worm.x = wormsx[randompos]; worm.y = wormsy[randompos]; stage.addchild(worm); worm.onpress = wormhit; lastworm = worm; lastworm.scaley = 0.3; lastworm.y += 42; stage.update(); tween.get(lastworm).to({scaley: 1, y: wormsy[randompos]}, 200).wait(1000).call(function(){curren

Execute keyboard shortcut with jquery -

this question has answer here: programmatically triggering ctrl+s 2 answers is possible execute keyboard shortcut jquery. shortcut ctrl + shift + i opens google chrome inspect element . tried: http://jsfiddle.net/r80nlhku/1/ you can't send arbitrary key presses window javascript ... it's security issue. mean force user literally go site (and worse, ie. control computer).

javascript - Jquery UI tabs won't disable all -

i have been pulling hair out hour trying crack this. reason can't seem disable tabs in jquery ui tabs. have read api 3 times , have found how disable them 1 @ time not @ once. have tab has information on , when user has form open want keep them on tab. once saved can go tab jumping. i have tried disable have tried disable , read api 4 time. want able $("#tabs").tabs("disable") , no longer clickable , user stuck on tab on. using jquery ui 1.11.4 , jquery 2.1.4. any idea how knock out in nice 1 line piece of code magic? you use disabled option. $(function() { $("#tabs").tabs({disabled: true}); }); <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> <div id="tabs"> <ul>

sql - How to filter order numbers by multiple columns -

i have table many rows looks this: order_id part_id description gl_code 12345 gk123 gun mount 6850 12345 null freight 4050.2 12346 blac lock 6790 12346 null freight 4050 i want make query returns order information part_id gk% number or blac number , order has freight gl_code of 4050.2 . the freight in description column , in different row part_id . i not want include blac , gk% parts not have freight , 4050.2 on order. i've been able 4050.2's or gk%'s , blac's. one way use correlated subquery makes sure there exists row same order freight code 4050.2: select * tab t (part_id = 'blac' or part_id 'gk%') , exists ( select 1 tab order_id = t.order_id , description = 'freight' , gl_code = '4050.2' -- remove quotes if number , not char value ) with sample data return: order_id part_id description gl_code 1

gcc - Take a 4-digit input and automatically the computer press Enter -

i want user inputs 4-digit number computer press enter (meaning 4 digit input taken , taken program continue itself. user has no need press enter key). program written in c. using gcc compiler. the getchar() function gets character without need press enter. you can use for loop call getchar() function many times need it. loop runs, each character inserted in number array. char number[4]; (i=0; i<4; i++) { number[i] = getchar(); getchar(); } we can use sscanf() function convert char array int! int num; sscanf(number, "%d", &num);

MySQL count row with group by dayofweek including zero result -

i've made query retrieve daily data week. hope of getting table follows: hari total finish issue ------ ------ ------ -------- 1 0 0 0 2 0 0 0 3 1 0 1 4 1 1 0 5 0 0 0 6 0 0 0 7 0 0 0 this query: select dayofweek(`waktu`) hari, coalesce( (count(*) ), 0) total, count(if(`jarak`<70,1,null)) finish, count(if(`jarak`>70,1,null)) issue `presensi` weekofyear(`waktu`)=weekofyear(now()) group hari; but, query not show 0 result. how show day of week including day emty data? i have solve problem. create dummy table list of day(idea @drew-pierce). query: select h.`id`, coalesce(d.total,0) total, coalesce(d.finish,0) finish, coalesce(d.issue,0) issue hari_dummy h left join ( select dayofweek(p.waktu) hari, count(p.waktu) total, count(if(p.`jarak` < 70, 1, null)) finish,

ssh - Vagrant ansible git clone permission error -

i using vagrant ansible provision. when doing git clone ansible getting following error: failed: [default] => {"cmd": "/usr/bin/git ls-remote '' -h refs/heads/head", "failed": true, "rc": 128} stderr: permission denied (publickey). fatal: not read remote repository. please make sure have correct access rights , repository exists. msg: permission denied (publickey). fatal: not read remote repository. please make sure have correct access rights , repository exists. fatal: hosts have failed -- aborting but when ever trying clone vagrant box manually works fine. have searched net , have got ssh forwarding set true in vagrant , ~/.ssh/config looks following allows forwarding host machine. host * forwardagent yes my ansible yml file follows: --- - hosts: sudo: true tasks: - name: clone project git: repo=<git ssh link> accept_hostkey=yes clone=yes dest=/home/

javascript - CSS selectors for two different div's -

i wondering if possible style div if other div contains specific class?! know can done jquery wondering if can done css aswell. let's have <div class="stickywrap sticky"></div> <div class="checkout "></div> is possible style checkout when stickwrap contains class sticky ? i tried like: .stickywrap[class*="sticky"] + .checkout{ background-color: #1f6053; } that obvious doesn't work. just chain classnames in selector. .stickywrap.sticky + .checkout { background:red; } <div class="stickywrap">not sticky</div> <div class="checkout ">checkout</div> <div class="stickywrap sticky">sticky</div> <div class="checkout ">checkout</div> note: think selector wanted was: .stickywrap[class$="sticky"] + .checkout{ background-color: #1f6053; } this find parent elements have both .stick

javascript - Invoking function of a returned object from function prints undefined -

var unique = function(){ var n=0; return function(){ return { inc : function(){ n++; console.log(n); } }; }; }; console.log(unique()().inc()); the code above prints 1 , undefined reason undefined gets printed ? because asked log value returned inc , , doesn't return anything. if don't want print anything, console.log(unique()().inc()); should be unique()().inc(); if expect new value of n printed, inc : function(){ n++; console.log(n); } should be inc : function(){ n++; console.log(n); return n; }

java - Measuring loading time of Excel -

i searching solution on 1 week. maybe have solution problem: i want measure time need open excel file excel. first solution start measurement line of code: processbuilder command = new processbuilder("cmd", "/c", <excel_path>, <file-location>); command.start(); long start = system.currenttimemillis(); and check ram-usage via process explorer. if excel finish loading ram usage still same , stop measurement. see fuzzy , not solution. as second solution open socketserver in java , wait until excel call workbook_open()- method after finishing loading file. within method send socket connection java server (i give host , port parameter excel) , measure time. this efficient in company not allowed auto run scripts if don’t stored in trusted zone. cannot change policy’s not solution. have idea how measure loading time of excel-file in excel? not no solution track loading

objective c - IOS Framework from C library give linking issues -

i'am finalising open source c coded cometd library, thought idea open osx/ios users, myself. in order ease work osx/ios developers wanted switch static c library xcode ios framework. followed advices found on net, , generated static ios compatible library xcode before wrapping in ios framework. i made sure "architectures" "standard armv7 armv64" , "base sdk" put "latest ios" compiled, warnings popped out library generated , gave me product.a . the problem can't include in other ios project. put library , headers in ios project found sea of error telling me : ignoring file * * *.a, file built archive not architecture being linked (i386): * * *.a undefined symbols architecture i386: ... barely c functions ... but has compiled compatible ios static library ? why yelling @ me i386 architecture ? mind blowing ! i fetched interweb no real answer found. so question is, possible make such thing (c library inside ios f

c++ - Design pattern suggestion for storing the client information in map in server application -

my application server, , client give request processing. client contact me(server) multiple times handling same request . map<clientid,clientinformation> usually, i'll store information received client in stl map processing client request next time. once client satisfied in servings, clear entry in map respective client id. this sample clientinformation class: class clientinformation { int notrequiredfornexttime; // information not required processing client request next time int requiredfornexttime; // information required processing client request next time int requiredfornexttime; // information required processing client request next time int notrequiredfornexttime; // information not required processing client request next time int notrequiredfornexttime; // information not required processing client request next time userdefinedclass class1; }; class userdefinedclass { int requiredfornexttime; int notrequiredfornexttime; } in above class, re

android - At what point does the fragment in a container change after i call the commit method? -

i trying edit data in fragment activity. have called fragment manager replace fragment in container new fragment, when try cast fragment in container new type, error: java.lang.classcastexception: com.mycompany.myapp.fragment2 cannot cast com.mycompany.myapp.fragment1. here code in activity public void respond(transaction.type type, string title, double amount, string description) { add_edit_transaction fragment = new add_edit_transaction(); fm.begintransaction().replace(r.id.maincontent,fragment).commit(); toast.maketext(this, "replaced!", toast.length_short).show(); add_edit_transaction frag= (add_edit_transaction)fm.findfragmentbyid(r.id.maincontent); } the commit not happen immediately; scheduled work on main thread done next time thread ready. if need transaction happen can force calling fragmentmanager.executependingtransactions()

c++ - make_shared in a try catch - scoping issue -

i need allocate memory, in try/catch, introduces new scope, in variable not available once i'm out of try-scope. what's best way solve this? try { auto = std::make_unique<someclass>; } catch (std::bad_alloc) { ... } // ... lots of code don't want include in try/catch-scope. something.callsomemethod(); how go solving this? there specific reason why doing shouldn't work. if code wrote worked way wrote it, calling callsomemethod() on null object. right way benjamin lindley said, put code in try block. way variable in-scope method call happen if there not bad alloc threw exception.

Cant create animation in android studio: resource identifier not found -

i created simple xml animation under res/anim/rotate180.xml <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <rotate android:duration="500" android:fromdegrees="0" android:pivotx="50%" android:pivoty="50%" android:todegrees="180" android:toyscale="0.0" /> </set> but cant run project: agpbi: {"kind":"error","text":"no resource identifier found attribute \u0027fromdegrees\u0027 in package \u0027android\u0027","sourcepath":"\\src\\main\\res\\anim\\rotate180.xml","position":{"startline":3},"original":""} agpbi: {"kind":"error","text":"no resource identifier found attribute \u0027pivotx\u0027 in package \u0027android\u0027",&q

git - repository not found in local server -

i learn basic operations git , have problem. have apache server localhost:8080. have repositories: 'c:\apache\localhost\www\machine2.git'. 'c:\programs\gitrepositories\video2'. i wrote ' http://localhost:8080/machine2.git/ ' in browser, , browser me fine answer catalog of files. in git bash of 'machine2.git' wrote: # rustam@rustam_pc /c/apache/localhost/www/machine2.git $ git --bare init # initialized empty git repository in c://apache/localhost/www/machine2.git # rustam@rustam_pc /c/programs/gitrepositories/video2 $ git init $ git add . $ git commit -m "initial" # [master (root-commit) ed08a791 initial # 1 file changed, 1 insertion(+) # create mode 100644 readme $ git remote add origin http://localhost:8080/machine2.git/ $ git push origin master # fatal: repository 'http://localhost:8080/machine2.git/' not found i have no idea. please, help! answer. open properties of machine2 , set common access all. copy

android - Use a button in the action bar with an intent to start a new activity -

i've got buttons in action bar so: <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <!-- search, should appear action button --> <item android:id="@+id/action_search" android:icon="@drawable/ic_action_search" android:title="@string/action_search" app:showasaction="ifroom" android:onclick="doublebet"/> <!-- settings, should in overflow --> <item android:id="@+id/action_settings" android:title="@string/action_settings" app:showasaction="never" /> i've added onclick action_search, launch new activity. here java launch activity. public void doublebet(view view){ intent intent = new intent(this, displaymessageactivity.class); string x = "hello"; intent.putextra("key", x); //optional parameters startactivity(intent);

javascript - creating a jquery custom lightbox setup. -

i'm creating custom jquery lightbox. the problem i'm having setup function doesn't work wanted to, wanted when image click want setup() function run , update variables (prev_img, next_img, count, current_img_src). when #next , #prev click want run setup function , update. <ul id="items"> <li class="shrink"><img src="foo1.jpg" alt="foo1"/></li> <li class="shrink"><img src="foo2.jpg" alt="foo2"/></li> <li class="shrink"><img src="foo3.jpg" alt="foo3"/></li> <li class="shrink"><img src="bar1.jpg" alt="bar1"/></li> <li class="shrink"><img src="bar2.jpg" alt="bar2"/></li> <li class="shrink"><img src="bar3.jpg" alt="bar3"/><

c# - Error: System.Windows.Controls.UIElementCollection' does not contain a definition for 'OfType' -

i want delete ellipses wpf canvas. used method : public void clearcircle() { var circles = cvssurface.children.oftype<ellipse>().tolist(); foreach (var c in circles) { cvssurface.children.remove(c); } } but, error on .oftype : 'system.windows.controls.uielementcollection' not contain definition 'oftype' , no extension method 'oftype' accepting first argument of type 'system.windows.controls.uielementcollection' found. do need include something? i'm using .net 4.5 do need include something?.... yes, need include system.linq namespace explained here .

Does Excel round up a number automatically? -

the value in cell a2 20.64907652 , have put formula in b2 =a2 value in b2 20.65 , cannot increase decimals. =round(a2,10) way? thanks. for number comparisons like show explicit "rounding" you're doing directly in comprison, so: =if(abs(a1-b2)<.02,"close enough","not equal")

java - EOFException in objectinputstream readobject -

i want make server client application. set , error. want app wait till more data. java.io.eofexception @ java.io.objectinputstream$blockdatainputstream.peekbyte(unknown source) @ java.io.objectinputstream.readobject0(unknown source) @ java.io.objectinputstream.readobject(unknown source) on line: listener.received(inputstream.readobject(), id.id); server code: isrunning = true; thread input = new thread(new runnable(){ @override public void run() { try{ serversocket server = new serversocket(localport); while(isrunning){ socket socket = server.accept(); objectoutputstream outputstream = new objectoutputstream(socket.getoutputstream()); objectinputstream inputstream = new objectinputstream(socket.getinputstream()); object obj = inputstream.readobject(); if(obj instanceof id){ id id = (id)

JSON as JavaScript object - security risks -

are there security risks while using following or json escaped safely? <script> var _configuration = %variable_expand_contains_json% </script> if control content, not. if @ time user can input part of - yes, there tons of risks

Python datetime.strptime issue -

i trying parse date time string datetime type, here code: import datetime print datetime.datetime.strptime('01/01/2002 00:00:00', "%d/%m/%y %h:%m:%s") however, i've got error: valueerror: time data '01/01/2002 00:00:00' not match format '%d/%m/%y %h:%m:%s' may know how fix this? many thanks. your year format incorrect. should capital y : >>> print datetime.datetime.strptime('01/01/2002 00:00:00', "%d/%m/%y %h:%m:%s") 2002-01-01 00:00:00 i'm sure you've seen it, documentation possible values here

scala - How to determine if an expression passed to a macro will always result in the same value? -

let's suppose i've defined macro below. types expression of type t , returns object of type mytype[t] (the actual types involved don't matter). object mymacro { def macroimpl[t : context.weaktypetag, u : context.weaktypetag](context : scala.reflect.macros.blackbox.context) (expression : context.expr[t]) : context.expr[u] = } object myobj { def callmacro[t](expression : t) : mytype[t] = macro mymacro.macroimpl[t, mytype[t]] } in macro, i'd determine if expression passed constant or not. mean, want know if expression, once evaluated @ runtime, ever subsequently evaluate different value. if constant, can apply optimizations useful. i know expression constant if is: a literal expression. a 'this' expression. a reference val or parameter. a member invocation object expression constant, , member being invoked val or lazy val. for example, expressions passed in first 5 calls callmacro below should considered constant: class myclass { val

android - Why is everything related to nutrition obfuscated in google fit? -

i'm using android studio , have google play services rev.25 installed. playing around fitness api. documentation claims there should datatype.type_nutrition see instead following zzyw = new datatype("com.google.nutrition.meal", new field[]{field.zzzi, field.field_calories, field.zzzj, field.zzzk, field.zzzl, field.zzzm, field.zzzn, field.zzzo, field.zzzp, field.zzzq, field.zzzr, field.zzzs, field.zzzt, field.zzzu, field.zzzv, field.zzzw, field.zzzx, field.zzzy}); the nutrition stuff in both datatype , field seems obfuscated reason. puzzles me when use obfuscated values , deploy app phone works... assumed there wrong copy of sdk phone seems have api obfuscated well... also strange type should com.google.nutrition there no such thing in (decompiled) datatype. i'm pretty sure i'm doing wrong no clue is... ok.. funny... had post question here realize problem was... maybe someone... the problem declared requirement play services 7.0.0 nutriti

osx - Javascript -> Download CSV file encoded in ISO-8859-1 / Latin1 / Windows-1252 -

i have hacked small tool extract shipping data amazon csv order data. works far. here simple version js bin: http://output.jsbin.com/jarako for printing stamps/shipping labels, need file uploading deutsche post , other parcel services. used small function savetextasfile found on stackoverflow. far. no wrong displayed special characters (äöüß...) in output textarea or downloaded files. all these german post / parcel services sites accept latin1 / iso-8859-1 encoded files upload. downloaded file utf-8. if upload it, special characters (äöüß...) go wrong. how can change this? still searched lot. have tried i.e.: setting charset of tool iso-8859-1: <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> but result is: have wrong special characters still in output textarea , in downloaded file. if upload post site, still more wrong characters. if check encoding in coda editor still says downloaded file utf-8. the savetextasfile

Retain Android Activity State When Go To Detail From List ActivityList.java--->ActivityDetail.java -->Back to ActivityList.java -

i facing strange issue. have 1 list binding on activitylist.java page use of 1 adapter. in adapter on click of viewbutton calling activitydetail.java . when press button , comes activitylist.java variables , activity state lost. want retain same when come activitydetail.java. activitylist.java---> _lstcity; i getting city list database , assigning _lstcity. when came activitydetail.java want use same variable don't need go database again n again. a big in advance. you can save data dont wanna loss on onsaveinstancestate method respore on onrestoreinstancestate . and yes, better post code.

linux - php cron job not running -

this question has answer here: cronjob not execute script works fine standalone 2 answers root@xx:/var/www/test# php /usr/bin/php root@xx:/var/www/test# ls -la total 16 drwxrwxrwx 2 root root 4096 nov 14 09:37 . drwxrwxrwx 6 root root 4096 nov 13 15:51 .. -rwxrwxrwx 1 root root 153 nov 14 09:35 test.php this test.php file: <?php $my_file = 'file.txt'; $handle = fopen($my_file, 'w') or die('cannot open file: '.$my_file); //implicitly creates file and output of crontab -l : #this ok * * * * * touch /tmp/hello #this creates empty php_result.log * * * * * /usr/bin/php /var/www/test/test.php > /tmp/php_result.log root@xx:/var/www/test# php -v php 5.4.34-0+deb7u1 (cli) (built: oct 20 2014 08:50:30) the cron job not run, , problem php. if run file manually, works well. php test.php related question: why crontab not exe

c# - The name '__o' does not exist in the current context -

Image
i installed visual studio 2015 , opened asp .net project working on. i'm receiving many errors (all same) below: error cs0103 name '__o' not exist in current context well don't have variables named __o , code works charm (error invalid) bothers me i'm not able see when code has error goes somewhere in list , should check whole list. i found out if choose build only instead of build + intellisense errors (that related intellisense) go away. update 1: reason the reason happening codes this: <% if (true) { %> <%=1%> <% } %> <%=2%> in order provide intellisense in <%= %> blocks @ design time, asp.net generates assignment temporary __o variable , language (vb or c#) provide intellisense variable. done when page compiler sees first <%= ... %> block. here, block inside if, after if closes, variable goes out of scope. end generating this: if (true) { object @__o; @__o = 1; } @__o = 2;

java - exporting data into double array -

i want add retrieved data database array, retrieval data null. mistake? please me. for (user u : userlists) { (resource r : resourcelists) { string ratingquery = "select rank ratings userindex='" + u.getindex() + "' , resourceindex='" + r.getindex() + "'"; try { ratingcon = connectionmanager.getconnection(); stmt = ratingcon.preparestatement(ratingquery); rs = stmt.executequery(); while (rs.next()) { rate = rs.getdouble("rank"); ratings[u.getindex()][r.getindex()] = rate; //it seems here problem } } catch (exception e) { system.out.println("log in failed: exception has occurred! &qu

osx - Run a string through PHP? -

how go processing string through system php? i've tried doing firing nstask , feeding arguments /usr/bin/php results of php cli, isn't quite same thing — one, line breaks aren't quite right. what i'd take string , run through php, , store result in string . kind of webserver. is possible? update have tried both -f , -r options of php cli, neither 1 of them gives me output i’m looking for. i suspect php cli not correct approach here. i able turn string containing php code string containing how code parsed web server php support.

javascript - Fill Jquery datatables dynamically -

i have used jquery datatables plugin.at first , content of table hardcoded did modfications in order fill table dynamically fetched data , works fine search function within table stoped working , value of entries number stays unchanged ( 0 ) . here's link datatable: https://www.datatables.net/download/index datatables ve api dynamically add rows... check fnadddata (doc https://datatables.net/api ). if force new rows in table disappear example if use yourtable.fndraw() because real table settings not altered. use fnadddata or fncleartable manage data. if use api search continue work fine think.

AngularJS: ui-router: Do not output link of current state? -

is possible to check state in view , don't output link current (active) state? currently trying: <a ng-if="!$state.includes('dashboard.common')" ui-sref="dashboard.common" >dashboard</a> <span ng-if="$state.includes('dashboard.common')">dashboard</span> of course, decorate ui-sref-active , don't want have link @ all. any ideas? the answer provided here and final version is: angular.module('ui') .directive('uilink', function($state) { 'use strict'; return { restrict: 'e', transclude: true, template: [ '<a ui-sref="{{uisref}}" ng-if="!iscurrent()" ng-transclude></a>', '<span ng-if="iscurrent()" ng-transclude></span>' ].join(''), link: function(scope, element, attrs) { scope.uisref = attrs.sref; scope.iscu

android - My Latitude and Longitude are not changing values when I move locations -

i trying show latitude , longitude move around, stays @ 1 value , not change. can tell me wrong code? have updated manifest file i'm not sure why it's not working properly. make calls in writetofile method in main activity. package com.explorer.extractor; import android.app.service; import android.content.context; import android.content.intent; import android.location.location; import android.location.locationlistener; import android.location.locationmanager; import android.os.bundle; import android.os.ibinder; import android.util.log; public class gpstracker extends service implements locationlistener { private final context mcontext; //flag gps status boolean isgpsenabled = false; //flag network status boolean isnetworkenabled = false; boolean cangetlocation = false; location location; //location double latitude; //latitude double longitude; //longitude //the minimum distance change updates in meters private static fina

python - NameError: name 'argv' is not defined -

i trying make google api call , getting error beginning of code found here: import os import argparse import sys apiclient import sample_tools oauth2client import client # declare command-line flags. argparser = argparse.argumentparser(add_help=false) argparser.add_argument( 'profile_id', type=int, help='the id of profile campaigns for') # authenticate , construct service. service, flags = sample_tools.init( argv[1:], 'dfareporting', 'v2.1', __doc__, os.path.abspath(os.path.dirname("__file__")), parents=[argparser], scope=['https://www.googleapis.com/auth/dfareporting', 'https://www.googleapis.com/auth/dfatrafficking']) if __name__ == '__main__': main(sys.argv) however, sample_tools.init function not returning service , flags object. think have isolated argv argument a nameerror: name 'argv' not defined any appreciated!!! you missing sys : sys.argv[1:]

Qt Creator - cannot find -lGL -

i've started (today) use qt c++ in order build guis systems. i'm using ide (qt creator) on ubuntu 14.04 , following tutorial, comes packaged installation, creating qt widget application - program search text file word. when try build , run error cannot find -lgl . what's problem, should work out box if come ide no? just type sudo apt-get install libglu1-mesa-dev that should solve this

Lazy importing in python tool suite -

context: making command line tool suite launched git , of it's tools. commands run meke toolname --args based on " why lazy import not default in python? " sounds case 1 of few useful places lazy importing. parse command line tool user run, import tool , pass along remaining arguments it's main function. question: idea? there reasons should import front instead? or perhaps there better way structure whole suite entry point? i pretty sure lazy imports better here. figure sanity check smart folks way prevent unforeseen complications or bad design practices. thanks. assuming have fair number of non-trivial tools in suite, yes makes sense lazy imports. real benefit you'd targeting have more recursive imports of libraries tools depend on rather tools themselves, still makes worthwhile. that said, why don't test out , see? can use timeit watch execution time , without lazy imports, , can @ this question discussion watching memory usage -- h

php - How to use phpMyAdmin with mysqlnd -

when run php code full error reporting : warning: mysqli::mysqli(): headers , client library minor version mismatch. i found out should switch mysqlnd uninstalling mysqli discussed here: headers , client library minor version mismatch after migration see phpmyadmin not working anymore. had uninstall php-mysqlnd package , install php-mysql again. so question is: "does phpmyadmin able work mysqlnd?" after asking same question in centos forum, got solution this: https://www.centos.org/forums/viewtopic.php?f=47&t=53726 the trick not issue "yum remove php-mysql" , "yum install php-mysqlnd" in separate commands, instead 1 must issue following: # yum shell > remove php-mysql > install php-mysqlnd > run > quit the above prevents phpmyadmin remove automatically, , upgrade happen smoothly without breaking phpmyadmin package.

Excel VBA AciveListObject -

i have sheet using excel tables (listobjects) called "tables" , seems cannot name of object changed. have event call class , need set property of active listobject. is there away can similar activelistobject.name ? know can use activesheet.listobjects("tablename") isn't going work being have 5 tables on sheet. please reply ideas. if want refer listobject contains active cell, can use: dim olist listobject set olist = activecell.listobject if not olist nothing ' whatever end if