Posts

Showing posts from January, 2012

c - Doxygen: How to redefine void -

i use library redefine void type (among others): #define xx_void void so when run doxygen on code like /** * @brief function description */ xx_void foo(xx_void) { /*...*/ } i warning file.c:10: warning: return type of member foo not documented how can tell doxygen xx_void void there no return value ? you can try macro_expansion tag: macro_expansion if macro_expansion tag set yes , doxygen expand macro names in source code. if set no , conditional compilation performed. macro expansion can done in controlled way setting expand_only_predef yes . the default value is: no . this tag requires tag enable_preprocessing set yes . with macro_expansion set yes result after doxygen preprocessing becomes: void foo(void) { /* ... */ }

dataframe - r apply function pads spaces to match character lengths -

i using apply generate strings data frame. for example: df2 <- data.frame(a=c(1:3), b=c(9:11)) apply(df2, 1, function(row) paste0("hello", row['a'])) apply(df2, 1, function(row) paste0("hello", row['b'])) works expect , generates [1] "hello1" "hello2" "hello3" [1] "hello9" "hello10" "hello11" however, if have df <- data.frame(a=c(1:3), b=c(9:11), c=c("1", "2", "3")) apply(df, 1, function(row) paste0("hello", row['a'])) apply(df, 1, function(row) paste0("hello", row['b'])) the output is [1] "hello1" "hello2" "hello3" [1] "hello 9" "hello10" "hello11" can 1 please explain why padded space make strings same length in second case? can work around problem using gsub, have better understanding of why happens this happening because apply ...

php - #1064 - You have an error in your SQL syntax;heck the manual that corresponds to your MySQL server version for the right syntax to use near -

the below query , when run in db shows error #1064 - have error in sql syntax; insert into`expense`(request,date,employee,load,truck,amount,purpose,mode,remark) values ('$request','$date','$employee','$load','$truck','$amount','$purpose','$mode','$remark') can sumbdy help!! date & load reserved keywords. use ticks - insert `expense` (`request`,`date`,`employee`,`load`,`truck`,`amount`,`purpose`,`mode`,`remark`) values ('$request','$date','$employee','$load','$truck','$amount','$purpose','$mode','$remark')

unity3d - IL2CPP : linking error for iOS build NeatPlug - Flurry Analytics plugin (universal) -

we using neatplug's flurry analytics plugin our unity game. going fine till updated unity version 5.1.1p1. doing made ios build (linking) fail in xcode (using il2cpp scripting backend, universal architecture targeted). here error : ld: warning: ignoring file /.../libraries/plugins/ios/libflurry-analytics-plugin-simulator.a, missing required architecture arm64 in file /.../libraries/plugins/ios/libflurry-analytics-plugin-simulator.a (2 slices) ld: warning: ignoring file /.../libraries/plugins/ios/libsmart-iap-plugin-simulator.a, missing required architecture arm64 in file /.../libraries/plugins/ios/libsmart-iap-plugin-simulator.a (2 slices) undefined symbols architecture arm64: "_secitemupdate", referenced from: -[flurrykeychainwrapper updatevaluedata:forkey:] in libflurry.a(libflurry.a-arm64-master.o) "_ksecvaluedata", referenced from: -[flurrykeychainwrapper setdata:forkey:] in libflurry.a(libflurry.a-arm64...

python - Pycharm: Auto generate `:type param:` field in docstring -

when create function parameters, pycharm offers me create docstring :param param_name: field, pretty good. need add :type param_name: . so : def foo(bar, xyz): return bar + xyz with generate docstring option have (even insert 'type' , 'rtype' documentation stub enable) : def foo(bar, xyz): """ :param bar: :param xyz: """ return bar + xyz and i that : def foo(bar, xyz): """ :param bar: :type bar: :param xyz: :type xyz: """ return bar + xyz per the documentation : if configured , documentation comment stubs can generated type , rtype tags. following link: ... in smart keys page, select check box insert 'type' , 'rtype' documentation comment stub . once have done this, put cursor in parameter name in definition, activate smart keys feature ( alt + enter , default) , select specify ...

python - Global vs local variable efficiency in multiple function call -

first caveat understand premature optimization bad. second caveat i'm new python. i'm reading in many million data chunks. each chunk consists of 64 bits , held in numpy array. in order bit operations on numpy.uint64 type desired bit shift quantity must of same type:numpy.uint64. this can accomplished either casting number or making variable. number1 = numpy.uint64(80000) shift_amount = numpy.uint64(8) #option 1 number1 >> numpy.uint64(8) #option2 number1 >> shift_amount looping 10000 times , checking how long took. option2 wins out i'm assuming because overhead of creating numpy integer done once. my current program calls function each chunk of data processes raw bits. function called millions of times , appends few different lists. assuming same idea , using globally defined values shift/bit operations 2 more loop conditions tested. def using_global(number1): global shift_amount number1 >> shift_amount def using_local(number1): ...

reactjs - Is it OK to use React.render() multiple times in the DOM? -

i want use react add components multiple times throughout dom. this fiddle shows i'm looking do, , doesn't throw errors. here's code: html: <div id="container"> <!-- element's contents replaced first component. --> </div> <div id="second-container"> <!-- element's contents replaced second component. --> </div> js: var hello = react.createclass({ render: function() { return <div>hello {this.props.name}</div>; } }); react.render(<hello name="world" />, document.getelementbyid('container')); react.render(<hello name="second world" />, document.getelementbyid('second-container')); i've seen this question , i'm afraid doing above, i'll risking having react components interfere each other. answer question suggests using server-side rendering isn't option me i'm using django server-side. on ot...

How to convert hex string to octal string in java -

i converting string hexadecimal string , want convert octal string i doing follows string s="i found reason 2 days ago bussy update you.the problem udhl missing. should have added 06 @ beginning. works fine.for reason thought kannel adds (not difficult...), know doesn't..."; string hex = string.format("%040x", new biginteger(1, s.getbytes("utf-8"))); output is 4920666f756e642074686520726561736f6e203220646179732061676f20692077617320746f6f20627573737920746f2075706461746520796f752e5468652070726f626c656d20776173207468617420746865205544484c20776173206d697373696e672e20492073686f756c6420686176652061646465642030362061742074686520626567696e6e696e672e2020697420616c6c20776f726b732066696e652e466f7220736f6d6520726561736f6e20492074686f75676874206b616e6e656c2061646473207468697320627920697473656c6620286e6f74207665727920646966666963756c742e2e2e292c20627574206e6f772049206b6e6f7720697420646f65736e27742e2e2e i need convert hex octal string. tried this...

rstudio - I can't knit HTML on R Markdown. Can anyone please assist? -

the error is: processing file: 1.rmd error in loadnamespace(i, c(lib.loc, .libpaths()), versioncheck = vi[[i]]) : there no package called 'stringi' calls: <anonymous> ... trycatch -> trycatchlist -> trycatchone -> <anonymous> execution halted i've tried installing stringi package , loading using library function. still error. i use r studio version 0.99.441 on on mac os x 10.6.8. i had same problem on windows computer here how fixed it: go windows folder r packages stored in when r installs package states folder. copy , pasted address windows explorer. (mine ended r\win-library\3.2 ) delete folder stringi (which deleting package stringi ) re-install stringi using install.packages('stringi') this should work.

javascript - how to upload and post file to node express server -

i have traditional html email form sending post request file user can upload. want able flash success message once email sent, , in order need either use ajax or make post request using express - , not rely on traditional html form submission. how send file (not filepath string) server? i'm assigning input element id , and grabbing value. grabs string of file path file, , not send actual file. client <form enctype="multipart/form-data"> <input type="text" name="name" class="form-control" id="name"> <!--code below uploads file --> <input type="file" style="visibility:hidden; width: 1px;" id='${multipartfilepath}' class="res" name='userfile' onchange="$(this).parent().find('span').html($(this).val().replace('c:\\fakepath\\', ''))" /> <!-- chrome security returns 'c:\fakepath...

android - how to set style for custom component? -

i have 2 modules: app - layout.xml - styles.xml - attrs.xml core - customcomponent.java in module core there custom component, called customcomponent, use in app module , want set custom style, this layout.xml <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:customns="http://schemas.android.com/apk/res-auto" ... <com.example.customcomponent android:id="@+id/chart" android:layout_width="fill_parent" android:layout_height="fill_parent" customns:chart_style="@style/mycustomstyle"/> </linearlayout styles.xml <style name="mycustomstyle"> <item name="android:textcolor">#efefef</item> <item name="android:background">#ffffff</item> <item name="android:text">...

java - How do I convert this simple scriptlet to JSTL? -

i have following scriptlet i'm trying convert jstl <% string req = request.getparameter("loginfailed"); if(req != null) { if(req.equals("true")) {%> <h4 id="loginerrormessage">invalid email address or password.</h4> <%} } %> this scriptlet works fine, i'm trying convert jstl new to. best attempt @ recreating logic using jstl. <c:set var="req" value="${request.getparameter(\"loginfailed\")}"/> <c:if test="${ req!=null }"> <c:if test="${ req.equals(\"true\") }"> <h4 id="loginerrormessage">invalid email address or password.</h4> </c:if> </c:if> when replace scriptlet jstl have written above, nothing crashes no longer see "invalid email address or password." when have seen using scriptlet. i'm not sure i'm doing wrong here. is scope i...

python - Proper way to run mutiple scrapy spiders -

i tried running multiple spiders in same process using the new scrapy documentation buti getting: attributeerror: 'crawlerprocess' object has no attribute 'crawl' i found this post same problem tried using code 0.24 documentation , got: runspider: error: unable load 'price_comparator.py': no module named testspiders.spiders.followall for 1.0 imported: from scrapy.crawler import crawlerprocess and 0.24 imported: from twisted.internet import reactor scrapy.crawler import crawler scrapy import log testspiders.spiders.followall import followallspider scrapy.utils.project import get_project_settings based on 0.24 doc, seems code runs 1 spider through multiple domains, doesn't seem same 1.0 doc's code does, ran both anyway. have code run both spiders inside of file spiders defined problem. there internal issue new version of code or there dependency or code i'm missing program? have file code both docs below (i didn't run both versio...

php - Creating a level of numbers for a pass scoring system -

i have set of values json_decode , number being row 'pass_levels' , letter being row 'pass_level_name'. 90 -> a, 80 -> b, 70 -> c i have score if above or below number want show letter. if score 85 shows b. problem have code below if score above of numbers shows c regardless. i know if > 90 echo variables not set , amount of variables change. change , variables might be: a -> 95, b -> 90, c -> 80, d -> 70, e -> 60, f -> 50. in circumstances scored below lowest number fail. $score = $row['score']; $levels = json_decode($row['pass_levels']); $levels_name = json_decode($row['pass_level_name']); foreach(array_combine($levels, $levels_name) $level => $level_name){ } if($score >= $level){ echo $score.'% '.$level_name; } else { echo "fail"; } i hope i've explained enough me. thanks

angularjs - grunt serve VS opening index.html in browser -

i'm using yeoman , angular-fullstack generator bootstrap angular app. when grunt serve or grunt serve:dist works expected. now question is, when open index.html file directly in browser, isn't supposed work equally? so have hard time understanding whats tasks grunt executing here make work. or maybe missing else. the console tells me: get file:///app/8d57a97f.app.css net::err_file_not_found file:///app/47ab0f3e.vendor.js net::err_file_not_found file:///app/01b9b8a8.app.js net::err_file_not_found the generated index.html looks this: <!doctype html> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <base href="/"> <title></title> <meta name="description" content=""> <meta name="viewport" content="width=device-width"> <link rel="stylesheet" href="app...

How to solve ruby formatting error in rubocop? -

the error - inspecting 1 file c offenses: hellotk.rb:7:17: c: not use semicolons terminate expressions. pack { padx 15; pady 15; side 'left'; } ^ 1 file inspected, 1 offense detected the file - #!/usr/bin/ruby require 'tk' root = tkroot.new { title 'hello, world!' } tklabel.new(root) text 'hello, world!' pack { padx 15; pady 15; side 'left'; } end tkbutton.new text 'quit' command 'exit' pack('fill' => 'x') end tk.mainloop what appropriate formatting eliminate ';' rubocop stops warning me writing file wrong? want eliminate offense in correct manner. it wants put expressions on new lines, rather separating them semicolon pack { padx 15 pady 15 side left } or pack padx 15 pady 15 side left end

php - Everything on live server slightly bigger than localhost -

i have looked around surprised not find on issue. making website built on php, using vagrant vm, , lamp box called scotch box. happy how have looking in environment. then have hosted on digital ocean, configured lamp box. problem (text, boxes, pictures, etc) showing bigger on live version. using foundation our css framework, , breakpoints set happening @ clear different window sizes. as example, in picture below, both windows break away mobile bar , desktop bar, happening @ clear different widths. 1 server considers px different other. font sizes different same upon inspection. http://imgur.com/szw0v2s i looked on project ran similar setup (vagrant , do) , same thing happening. there didnt cause groudnbreaking issues didnt notice. wondering if can think of cause this. i'm thinking maybe technologies out of date not sure check for.

python - MemoryError while trying to using itertools.permutations, how use less memory? -

i'm loading text document containing random strings , i'm trying print every possible permutation of characters in string. if notepad contains example: 123 abc i want output be 123,132,213,231,312,321 abc,acb,bac,bca,cab,cba the text file contains pretty large strings can see why getting memoryerror. my first attempt used this: import sys import itertools import math def organize(to_print): number_list = [] upper_list = [] lower_list = [] x in range(0,len(to_print)): if str(to_print[x]).isdigit() true: number_list.append(to_print[x]) elif to_print[x].isupper() true: upper_list.append(to_print[x]) else: lower_list.append(to_print[x]) master_list = number_list + upper_list + lower_list return master_list number = open(*file_dir*, 'r').readlines() factorial = math.factorial(len(number)) complete_series = '' x in range(0,factorial): complete_string = '...

ruby on rails - Cannot update status of table specific instance because rollback is taking place -

i have table subscription column status. in subscriptions controller have method accept_player supposed update subscription.status "confirmed!" def accept_player @subscription = subscription.find(params[:subscription_id_accept_player]) @subscription.status = "confirmed!" @subscription.save authorize @subscription redirect_to tournament_subscriptions_path(@subscription.tournament) end unfortunately every time try trigger method, rollback seem take place: started post "/accept_player/39" ::1 @ 2015-07-08 22:01:21 +0100 activerecord::schemamigration load (12.4ms) select "schema_migrations".* "schema_migrations" /users/davidgeismar/code/davidgeismar/tennis-match/app/controllers/subscriptions_controller.rb:141: warning: duplicated key @ line 155 ignored: "cardtype" processing subscriptionscontroller#accept_player html parameters: {"utf8"=>"✓", "authenticity...

ruby - Joining two arrays together to make json in rails -

i pretty ruby nuby i'm sure doing awful here. i'd join 2 arrays can pass controller json created. way can reasons of d3 library im using , requirements. to have following in controller: def self.including_relationships result=[] result['nodes']=user.pluck(:name,:group) result['links']=relationship.select('follower_id source, followed_id target, value').map{|x| [x.source, x.target, x.value]} result end the controller: def data @users = user.including_relationships respond_to |format| #format.html # index.html.erb format.json { render json: @users } end end i end result, when passed through controller like: { "nodes":[ {"name":"myriel","group":1}, {"name":"napoleon","group":1}, {"name":"child2","group":10}, {"name":"brujon","group":4}, {...

python - SVM - Scikit-learn -

i have vector of scores (data) x 3 variables (s1,s2,s3) .shape of x (n_sample,3) , vector class (target) y (2 class : 0 or 1). i build weigthed score combing them s=s1*w1+s2*w2+s3*w3 . need test different value w1 , w2 , , w3 , using svm (or svr). but i'm getting lost parameters. should use gamma vector of weigth? , possible have 1 variable x , have la (n_sample, 1) how initialize it? if have suggestion using else scikit-learn it's fine me.

Clear 2nd Dependent Drop Down Excel -

i figured out how make dependent drop down. finally. my problem when change first drop down, second 1 still has options first option. drop down 1: fruit vegetables fruits drop down info: apples bananas vegetables drop down info: carrots cucumbers if choose fruit, can choose apples. however, if choose vegetables, apples still option until change it. is there solution purge second drop down every time change made on first one? i found: dependent drop down list in excel auto update i'm confused on how make work situation. drop down in a10 , secondary a20. next plan learn vba. in second drop down, can use formulas. if fruit choices in 1 column, , vegetable choices in another, can following... assuming drop down 1 in a10, list of fruits c1:c10, list of vegetables d1:d10: for second drop down in cell a20, go data validation -> list. instead of choosing list of either fruits, or vegetables, "=if(a10="fruit",c1:c10,d1:d10)". ...

java - Transform a BigDecimal with a negative scale to a positive scale -

i getting bigdecimal values in scientific notation, i.e., 1e+3 , has scale of -3 . how convert 1000 scale 0 ? see can use toplainstring() , there direct way of achieving this? if understand correctly, d = d.setscale(0) work: bigdecimal d = bigdecimal.valueof(1e3).setscale(-3); system.out.println(d.unscaledvalue()); d = d.setscale(0); system.out.println(d.unscaledvalue()); output is: 1 1000 note bigdecimal immutable, have reassign it.

From a vector to a shorter vector of averages in Matlab -

let have vector x in matlab of size 1000. want produce vector y of length 10 each component contains average of 100 records vector x . my attempt quite simple for i=1:10 y(i) = mean(x((1:100)+(i-1)*100)); end i wonder if there build in command or more elegant solution this. you can use reshape -function generate 2d-array , calculate mean on correct dimension. this works replacement loop: y = mean(reshape(x,[100,10]),1); note: not matter if x column-vector or row-vector.

JMeter - Why is my variable being re-evaluated midway through my test? -

Image
i posted question in more complicated way, i've reproduced issue more i'm extensively editing post. i have simple test plan exercise api. the first thing create session simple http post . extract session id response using json path extractor plugin: this reads newly created session's id variable called id_json , , subsequent put requests use session id in path, i.e. /api/sessions/${id_json}/account . this works well, have noticed intermittently, id_json have default value not_found . samples fail , when @ request, can see trying hit /api/sessions/not_found/account instead of valid id. what's confusing me right happen after requests have referenced ${id_json} , generated valid path. seems should impossible, unless value of id_json being dynamically checked or looked repeatedly - otherwise how coming different value 1 request next? it seems if sample fails, reason, subsequent requests in same thread iteration fail id_json having default value not_...

javascript - Sort-arrow in datatable appears more than once if destroy is set to true -

i need reinitialize datatable on every click of submit button. set destroy : true achieve this. every time datatable re-initializes, number of sort-arrows appear each column increases one. how can prevent happening? here javascript code. every time user clicks on submit, processformdata called, calls initializedatatable after validation of form fields. var firstname = ""; var lastname = ""; var country = ""; $(document).ready(function() { $('#userdetails').datatable(); }); function processformdata() { firstname = document.userdetailstable.firstname.value; lastname = document.userdetailstable.lastname.value; country = document.userdetailstable.country.value; if (document.userdetailstable.firstname.value == "" || document.userdetailstable.lastname.value == "" || document.userdetailstable.country.value == "") { bootbox.alert("please fill in fields!")...

qemu - automation of processes by python -

Image
i'm trying write python script start process , operations atferward. commands want automate script circled red in picture. problem after performing first command, qemu environment run , other commands should executed on qemu environment. want know how can these commands script in python? because know can first command not know how can commands when going qemu environment. could me how can process? first thing came mind pexpect , quick search on google turned blog post automatically-testing-vms-using-pexpect-and-qemu seems pretty along lines of doing: import pexpect image = "fedora-20.img" user = "root" password = "changeme" # define qemu cmd run # important bit redirect serial stdio cmd = "qemu-kvm" cmd += " -m 1024 -serial stdio -net user -net nic" cmd += " -snapshot -hda %s" % image cmd += " -watchdog-action poweroff" # spawn qemu process , log stdout child = pexpect.spawn(cmd) child.lo...

arrays - AS3 - Best method for dynamically creating a series of text fields? -

i (successfully) creating column of boxes via loop, meat of is: for(var i=0; < max_rows + 1; i++){ for(var o=0; o < max_cols + 1; o++){ var currenttile:memberbox = new memberbox(); currenttile.x = i*150; currenttile.y = o*25; currenttile.name = "b"+o; memberbox.addchild(currenttile); }} now need add textfield each box, later populated data array. tried adding each textfield array in loop , calling array, textfields still have same name last 1 called works... here have - need, adds text last box created. var txtarray:array = new array(); for(var i=0; < max_rows + 1; i++){ for(var o=0; o < max_cols + 1; o++){ var currenttile:memberbox = new memberbox(); currenttile.x = i*150; currenttile.y = o*25; currenttile.name = "b"+o; memberbox.addchild(currenttile); currenttile.addchild(memberboxtext); memberboxtext.width = 150; memberb...

javascript - jquery pagination handling visible and non visible pages -

i using jquery pagination. pulling 100s of records database , jquery pagination on front end. all other functionality working fine except visible pages. want show 10 or less pages @ time other pages should show on click of next or previous. please @ image there 15 records coming database , showing 1 record on per page working fine, 15 pages showing same time. image: https://www.dropbox.com/s/8od2z5wzoj8l4u6/pager.png?dl=0 here code function previous(){ new_page = parseint($('#current_page').val()) - 1; //if there item before current active link run function if($('.active_page').prev('.page_link').length==true){ go_to_page(new_page); } } function next(){ new_page = parseint($('#current_page').val()) + 1; //if there item after current active link run function if($('.active_page').next('.page_link').length==true){ go_to_page(new_page); } } function go_to_page(page_num){ //get number of items shown per page var sh...

javascript - AngularJS - how to get coordinates of each item in ng-repeat? -

i have items (div) in ng-repeat, each item has 200px height. how can position relative window. if distance top window lower 100px - should hide element. without seeing code can't how grab element, need use element.offsettop distance top , element.offsetleft distance left. you can check against 100px limit.

surveyor respondent pattern in nanomsg in python -

i trying write surveyor respondent pattern. throws error: nanomsg.nanomsgapierror: operation cannot performed in state from nanomsg import * s1 = socket(surveyor) s1.bind('ipc://bob') s1.send(b'hello nanomsg') print(s1.recv()) s1.close() nanomsg import * s2 = socket(respondent) s2.connect('ipc://bob') print(s2.recv()) s2.send(b'hello') s2.close() how can implement pattern in python? its bug, can circumvented inserting "time.sleep(0.1)", after bind or connect statement. from nanomsg import * import time s1 = socket(surveyor) s1.bind('ipc://bob.ipc') time.sleep(0.1) s1.send(b'hello nanomsg') print(s1.recv()) s1.close()

How to handle running cucumber features within Ruby method -

i using afterconfiguration hook run setup config before tests start, issue faced when run methods 1 of them run set of feature files using backticks in ruby method, in turn seems re initialze cucumber , repeat process, stuck in loop afterconfiguration environmentsetup::testusers.create_test_users end module environmentsetup class testusers def self.create_test_users # other logic here `cucumber "#{path_to_feature}"` # use backticks run cucumber scripts in subshell end end end so when executed goes beginning , runs other logic again is there way run once, or ignore afterconfiguration on second loop? declare global variable? i have tried afterconfiguration if defined? $a == nil environmentsetup::redisusers.check_redis_users environmentsetup::testusers.create_test_users end end module environmentsetup class testusers def self.create_test_users # other logic here $a = true `cucumber "#{path_to_feature}...

.net - delete contents of multiple selected cells datagridview in C++/CLI -

i'm trying delete string contents of selected cells when click on button in windows form. button event hook calls following function: code: void deletehighlightedrows(datagridview^ dgv) { if (dgv->selectedcells->count > 0) { (int = 0; < dgv->selectedcells->count; i++) { dgv->selectedcells[i]->value = ""; } } } this function called whenever button clicked, whenever there multiple rows selected, count of selected rows zero. any help/pointers appreciated!

How to send reply to mail in php -

i have created script send email users link on it. want when user click on click email should revert send confirmation user has accept invitation. able send mail client how can reply them? if want confirmation have clicked link , accepted invitation need make link point server , include users id in url. example: click <a href="http://myserver.com/accept_invitation.php?userid=34">here<a/> accept invitation. the create accept_invitation.php script on server , access user id using $_get['userid']. want want accepted invite, store in database or send email inform have accepted.

jquery - Open browser window using javascript? -

this question has answer here: how programmatically create new browser sessions in ie every time user accessed application url in new browser window 1 answer to open new ie browser window, i'm using below code. window.open ("http://jsc.simfatic-solutions.com","mywindow"); but how can open new ie window new session ? sessions handled via cookies, , there no way programatically make browser start new cookiejar window. you need provide other session tracking mechanism. 1 way via url parameter (e.g. ?session_id=123455 ). has security implications (because session ids can leak through link sharing , referers) php has native support it. you better off using regular session , have sub-session within it. store data in $_session['subsession'][0] , pass numerical id through query string.

python - How to deal with strings where encoding is unclear -

i know there quite lot on web , on stackoverflow python , character encoding, haven't found answer i'm looking for. @ risk of creating duplicate, i'm going ask anyway. it's script gets dictionary, keys unicode. values strings unknown encoding. keys wouldn't matter much, keys simple unlike values. values can (and do) contain large variety of encodings. there dictionaries, values in ascii others utf-16be yet others cp1250. that totally messes further processing, consists printing or concatenating (yes, simple). the work-around came with, makes python print statements work is: for key in data.keys(): # hope did not chose funky encoding try: print key+":"+data[key] # triggers unicodedecodeerror on many encodings current_data = data[key] except unicodedecodeerror: # trying cope funky encoding current_data = data[key].decode(chardet.detect(data[key])['encoding']) # doing on each value, because d...

javascript - Ionic - Check 2 radio buttons (different lists) by default -

Image
i taking first steps in ionic, , trying create app. in example , have 2 radio button lists (with options 1, 2, 3 , options 4, 5, 6): i both radio buttons 2 , 4 checked default. why radio button 4 checked? what missing? code below. from model html: <ion-view view-title="radio button demo"> <ion-header-bar align-title="left" class="bar-positive"> <h1 class="title">chosen option: {{item}}, {{item2}}</h1> </ion-header-bar> <ion-content> <ion-list> <ion-radio ng-repeat="i in items" ng-value="i.id" ng-model="item.itemval" >{{i.name}}</ion-radio> </ion-list> <ion-list> <ion-radio ng-repeat="i in items2" ng-value="i.id" ng-model="item2.itemval" >{{i.name}}</ion-radio> </ion-list> </ion-content> </ion-view> from controller javascript file: .controller("mai...

ruby - Click an alphabet key in watir -

i want open link in new tab. using watir, watir-webdriver , chrome. need press ctrl + t. how do ? this not - browser.element.send_keys [:control, 't'] exception - c:/blah/selenium-webdriver-2.33.0/lib/selenium/webdriver/common/keyboard.rb:48:i‌​n assert_modifier': "t" not modifier key, expected 1 of [:control, :shift, :a c:/blah/selenium-webdriver-2.33.0/lib/selenium/webdriver/common/keyboard.rb:25:i‌​n press'.... this kind of duplicate. selenium , watir solutions identical: how open new tab using selenium webdriver java? from 2nd answer: browser.element.send_keys(:control, 't')

java - Realm select by property of property -

i have 2 realmmodels class shop{ private string name; private item item; } class item{ private int itemid; private string itemname; } i want find shop has item itemid = 1 . any ideas? you can query across references (links) in realm. below should work: realm.where(shop.class).equalto("item.itemid", 1).findfirst()

java - Eclipse Plugin: Directly call method in another plugin? -

i've been tasked create plugin simulates clicking on button within eclipse gui, command line; such as: eclipsec -consolelog -console -nosplash -application org.doo.headless.headless i able plugin working hello world, , using eclipse methods etc print system.out.println . difficulty arises in calling methods in 3rd party plugins. in eclipse pde project, i've added 3rd party plugin "dependencies", , imported it; references 3rd party plugin's function generateall ok, , project can exported without problem running plugin command line returns java.lang.noclassdeffounderror swdb2c/ui/common/generateall which class definition of method want call. is there better way invoke function of plugin? possible without exporting 3rd party plugin? ideally deploy plugin right alongside 3rd party plugin trying automate. edit: manifest files 3rd party proj: (some stuff removed) manifest-version: 1.0 bundle-manifestversion: 2 bundle-name: swdb2c module ide plu...

node.js - Syncing JSON-files with MongoDB collection -

i'm new mongodb, i've managed use mongoimport load external json-files collection. question if there's way synchronize mongo database collection folder of json-files? i'm looking rsync, mongodb. is there such solution? best practice syncing data mongo database? watch folder nodejs , sync mongodb when add/remove , modify json file

Laravel 5.1 failed queued jobs fails on failed() method, prevents queue failure event handler from being called -

i testing queue functions in laravel 5.1. can make jobs queue in db table, called jobs, , can them run successfully. created queue failure table called failed_jobs. test it, inside jobs table manipulate payload data make fail run queue worker daemon so, put job in failed_jobs table after 1 failed attempt: php artisan queue:work --daemon --tries=1 --queue=myqueue when job fails put failed_jobs table expected. fyi have set things laravel 5.1 docs recommend: http://laravel.com/docs/5.1/queues#dealing-with-failed-jobs i have tried registering queue failure event in appserviceprovider's boot() method outlined in docs: queue::failing(function ($connection, $job, $data) { log::error('job failed!'); }); i have tried failed() method inside actual job scripts so: /** * handle job failure. * * @return void */ public function failed() { log::error('failed!'); } eith...

windows - Passing parameters to a batch file that end in a numeral -

i have requirement pass arguments string 1 batch file execution @ command line. have batch file takes arguments (i.e. command "tail") , creates batch file executes arguments. consider file batch1.bat: echo %*>batch2.bat call batch2.bat if run with batch1.bat echo b c we get a b c which fine. if run with batch1.bat echo 1 2 3 we get 1 2 i guess because last argument 3 gets interpreted batch operator following > redirection character. know simple fix add space, in echo %* >batch2.bat but there occasions when command line cannot have trailing space, like: batch1 set noenv= will give environment variable value of 1 space character, instead of deleting environment variable. so how do this? - requirement have batch file faithfully executes command tail (which might include items in quotes, numerals) move redirect front of statement. >batch2.bat echo %*

Powershell- Wait for x seconds on read host -

how wait x seconds on read host in powershell? i'm trying achieve xis prompt user input x seconds, if user doesn't enter value needed. use default value. currently when use read-host waiting on user input indefinitely, want have timeout on it. how can achieve this. code have below. im unable find option lets me define timer on this. $input = read-host ("enter y or n") if(!input) { $input = y } this regarding possible duplicate question: in post answers directed more towards whether user pressed key or not. did not mention how capture user input in there use it?

php - mod rewrite rule for searching a string from url and replace just domain name of that url -

i want create rewrite rule .htaccess. example: in url if itemid=702 found want redirect below original url is: www.dashboard.example.com/comp/temp/health/appt?itemid=702 redirect to: www.admin.example.com/comp/temp/health/appt?itemid=702 i have tried below condition, doesn't work. rewritecond %{request_uri} itemid=702$ rewriterule .* http://admin.example.com [r,l] how can create this? you're close, change rule to: rewritecond %{query_string} itemid=702 [nc] rewriterule (.*) http://admin.example.com/$1 [r,l]

php - How do you use multiple controllers in CodeIgniter? -

i'm new codeigniter , i've gone through of user guide me understand how multiple controllers. i have figured out how load multiple pages using 1 of examples. default controller, called site.php: class site extends ci_controller { public function index($page = 'home') { if ( ! file_exists(apppath.'/views/'.$page.'.php')) { // whoops, don't have page that! show_404(); } $data['title'] = ucfirst($page); $this->load->view('header', $data); $this->load->view($page, $data); $this->load->view('footer', $data); } } this works , routes.php: $route['default_controller'] = 'site'; $route['(:any)'] = 'site/index/$1'; i have few views load correctly when go localhost/website/index.php/about , example. now, further learn controllers , uri routing. created new controller, application/controllers/mycontroller.php , coded such: ...

php - phpWord - Tables with borders in headers/footers -

i working phpword , bringing changes header/footer content gives me real hard time. trying have header content arranged in table. table created through code write. styles try apply table placed in header not take effect. following part of code in may making mistake. $phpwordobj = new phpword(); $section = $phpwordobj->addsection(); $styletable = array('bordersize' => 18, 'bordercolor' => '006699'); $phpwordobj->addtablestyle('my custom style', $styletable); //add header document $header = $section->addheader(); $header->firstpage(); $table = $header->addtable(); $table->addrow(); //logo $table->addcell(2000)->addimage( '../vendor/phpoffice/phpword/samples/resources/phpword.png', array('width' => 80, 'height' => 80, 'align' => 'left') ); //logo $cell = $table->addcell(7000); $textrun = $cell->addtex...

validation - How to validate inputs and prevent save actions using databinding in eclipse? -

i want create input forms validate user input , prevent model being saved invalid data. have been using databinding works point implementation not intuitive like. imagine input contains '123' , value must not empty. user deletes characters 1 one until empty. databinding validator shows error decoration. however, if user saves form , reloads it, '1' displayed in field - i.e. last valid input. databinding not transmit invalid value model. i have changelistener called before databinding @ point invalid state has not been detected. i error displayed in ui model remains valid (this so). also, long ui contains errors, should not possible save model. /** * bind text control property in view model **/ protected binding bindtext(databindingcontext ctx, control control, object viewmodel, string property, ivalidator validator) { iobservablevalue value = widgetproperties.text(swt.modify).observe( control); iobservablevalue modelvalue = be...

Rails carrierwave has_many error -

each user has_one character. each character has_one :profilepicture, of class picturething, holds carrierwave mount_uploader upload singe picture. each character has_many :standardpictures, of class picturething. picture upload handled in views/users/edit, hits update_pictures method in users_controller. the idea upload 1 standardpicture @ time. seems work, rails console > picturething.all shows new picturething has been added database, , correctly displayed on page. intended 1 of character.standardpictures. the weird thing is, somehow in whole process, character's :profilepicture set same picture uploaded. don't understand how happening. @ no point have code saying "@character.profilepicture = standardpicture", somehow has decided both first :standardpicture , :profilepicture 1 , same. if profilepicture exists, shouldn't yet, displayed on edit.html.erb page, have line <% if @character.profilepicture.nil? %> . displays uploaded picture here, profi...

html - Send in form if button pressed -

i have 2 buttons in form (that js listening can show fields in form). <div class="btn-group" role="group" aria-label="..."> <button type="button" class="btn btn-default" name="distance" id="one_way_button">distance & time</button> <button type="button" class="btn btn-default" name="distance" id="stored_button">stored address</button> </div> i send button pressed in form post data. using ruby on rails, if matters. not sure need change html send button pressed. you can store button name in hidden input before submit function fnsubmitform(obj) { document.getelementbyid("buttonname").value = obj.value document.getelementbyid("myform").submit(); } onclick call above function <div class="btn-group" role="group" aria-label="..."> <input type="hidd...

javascript - jQuery attribute selector based on value with periods in it -

trying: $("div.docs-right div.api-manager div[ng-model=page.api.examples]").length this breaks with: uncaught error: syntax error, unrecognized expression: div.docs-right div.api-manager div[ng-model=page.api.examples] how select ng-model=page.api.examples ? try : $("div.docs-right div.api-manager div[ng-model=\"page.api.examples\"]").length