Posts

Showing posts from June, 2015

python - Javascript to Django views.py? -

this may sound simple, how send data javascript array in index.html template views.py? when user clicks "recommend" button, code calls function accesses database , prints name on template. def index(request): if(request.get.get('recommend')): sql_handler.recfunc() context['name'] = sql_handler.name return render(request, 'polls/index.html', context) i have array of checkbox values in javascript calculated after user presses "recommend". want send index view , use parameter function. so: def index(request): if(request.get.get('recommend')): sql_handler.recommend() context['name'] = sql_handler.name //something?? tags = check_array_javascript context['tags'] = tags return render(request, 'polls/index.html', context) how can this? i've been searching similar questions, i'm new django , web development in general...

java - Retrieving count of specific attribute in MongoDB collection -

i have mongodb collection lot of data. part of json documant looks this: { "_id":{ "$oid":"5364e0867a2690e2a2be13ff" }, "share_name":"test123", "data_objects":[ { "user":"the flying pirate.", "location":"devon, uk.", "share_id":462568869077716992 }, { "user":"the dragon.", "location":"london, uk.", "share_id":462568869077716992 }, { "user":"lozzien", "location":"miami, usa.", "share_id":462568869077716992 } ] } as can see, single document can have list of data_objects. above document has 3 data objects. need total count of data objects in collection. how can total count? what after "summing up" total length of array elements contained in document collection. ...

node.js - socket.io: client receive all incoming messages into a single function -

i using socket.io 1.2.0 . in client browser how receive events in single listener socket.on("*",fuction(event,data){ }); my previous implementation not working after uploaded 0.9 .... my previous hack receive events var original_$emit = getsocket().$emit; getsocket().$emit = function () { var args = array.prototype.slice.call(arguments); original_$emit.apply(getsocket(), ["*"].concat(args)); if (!original_$emit.apply(getsocket(), arguments)) { original_$emit.apply(getsocket(), ["default"].concat(args)) } }; this not perfect solution working fine.... code changes server socket.io /node_modules/socket.io/lib/socket.js in line no: 128 if (~exports.events.indexof(ev)) { emit.apply(this, arguments); } change if (~exports.events.indexof(ev)) { var arg = ["*",arguments]; emit.apply(this, arg); } in line no: 328 emit....

android - how to reprecent catched imge in offline mod -

hello app works in 2 modes i.e offline , online.when selected offline app prepare offline mode catches json , saves in database.in online mode represents image , text in offline mod it's supposed represent cached text , images,but doesn't. why ? (i think receives image doesn't represent it).what should protected integer doinbackground(void... params) { arraylist = new arraylist<hashmap<string, string>>(); jsonarray = jsonfunctions.getjsonfromurl(murl2); if ( internetpresent ) { db = new databasehelper(getapplicationcontext()); (int = 0; < jsonarray.length(); i++) { hashmap<string, string> map = new hashmap<string, string>(); jsonobject = jsonarray.getjsonobject(i); // retrive json objects map.put("id", jsonobject.getstring("id")); ...

java - Navigating to a new page of application in PLAY framework -

i working play framework 1.2.5. trying load (say) page2 on click of button (say) page1. on page1 have button , calling jquery on button follows: $(document).ready(function(){ $("#next").click(function(){ alert("reached jquery") $.get("/nextpage"); }); }); according me above code should call url "/nextpage" route file , should go mapped method. code method is: public static void nextpage(){ logger.info("reached nextpage method"); render(); } now, problem method being hit, log in method getting printed. expecting method change browser url , render "nextpage.html" page on browser nothing happens. page1 stays is. no errors play side. logs printed on console , all. is wrong render() because code working until above render(). you should not load page content after backend operation via ajax, instead, use old js redirect: $(document).ready(func...

c# - how to display full SQL query run by entity framework LINQ to SQL -

say have linq query: var query = (from person in ctx.people person.name == "john" select person); ctx context inheriting system.data.entity.dbcontext . now how full sql query including parameters? have tried: var sql = ((objectquery) query).totracestring(); sql = query.string(); context.database.log = (s) => sql += s; the first solution throws invalid cast exception. second solution gives me query part references variables not included. third prints "variables" in strange format. var query = person in ctx.people person.name == "john" select person; string sql = ctx.getcommand(query).commandtext;

ruby on rails - How to show my profile page using devise? -

i have devise model default fields email , password, , few more manually added full name, age, etc... i'd have page shows profile details i'm not seeing how can this. somewhere in application.html view : <%= link_to "profile", current_account%> any appreciated controller class yourscontroller < applicationcontroller def profile @account = current_account end end route get "myprofile" => "yours#profile", :as => :myprofile view /yours/profile.html.erb <%= @account.email %> <%= @account.etc %> link current profile <%= link_to "my profile", myprofile_path %>

javascript - Replace special characters different variables -

i'm trying put firstname + lastname email address, , works, need replace special characters in firstname , lastname or in finished variable emailad : function createemailaddress(){ var ss = spreadsheetapp.getactivespreadsheet(), sheet = ss.getactivesheet(), range = sheet.getdatarange(), values = range.getvalues(); (var r=1; r<values.length; r++) { var row = values[r], firstname = row[0], lastname = row[1], email = row[2]; if(email != "nodata" ){ var emailad = (firstname + "." + lastname + "@superenterprisecompany.com"); logger.log(emailad); sheet.getrange(1 + r, 3).setvalue(emailad); } } } i found this, not know how work variables function convert_accented_characters(str){ var conversions = new object(); conversions['ae'] = 'ä|æ|ǽ'; conversions['oe'] = 'ö|œ'; conversions['ue'] = 'ü'; conversi...

javascript - Resize event on multiple select control -

i have multiple select html element. want catch resize event, can store latest value. <select multiple="multiple" class="ra-multiselect-collection" style="resize: vertical; margin-top: 0px; margin-bottom: 5px; height: 527px;"></select> the following code doesnt work: $('.ra-multiselect-collection').on( 'resize', function(){ alert('resized'); }); any ideas? well, don't think can bind resize event dom element, check out: $("select").on("mouseup", function() { var el = $(this); if (el.data("old-height") == null || el.data("old-height") != el.height()) { alert("resized!"); } el.data("old-height", el.height()); }).data("old-height", $("select").height()); fiddle i have used mouseup event checking old height stored in data property current height on moment of event. if different, re...

ruby on rails - $ gem update --system > Unable to require openssl -

ruby version: /users/myname/.rvm/rubies/ruby-2.1.4/bin/ruby when try to: $ gem update --system i following error: error: while executing gem ... (gem::exception) unable require openssl, install openssl , rebuild ruby (preferred) or use non-https sources openssl installed: $ brew install openssl warning: openssl-1.0.1j installed should "rebuild ruby"? best way?

ajax - Trouble parsing JSON feed from REST API call with jQuery -

i have rest api endpoint i'm trying parse using $.ajax call. can see json structure endpoint url, can't access key:value pairs. how can access "live" "type" , "items" "sections"? there not cross domain issue in case holding me back. code: <div> <p class="type">type:</p> <p class="id">id</p> </div> $(document).ready(function () { $.ajax({ url: "http://myrestapiurl.com/" }).then(function (data) { $('.type').append(data.type); $('.id').append(data.items.id); }); }); json response: { status: { code: 200 }, entity: { sections: [{ type: "live", items: [{}, {}, {}, {}, {}, {}], entitytype: "section" }], entitytype: "content" } } there no data.items.id in json specified , though , can access data first : var itemsarray = ...

get height of jQuery popup when it shows up -

i want geht height of popup when loaded can set left/top value , make sure not out of viewport. @ first time popup toggled, there's hight of static div available, not including content ajax. $(".td_id").click(function(e) { var leftval = e.pagex+10; var topval = e.pagey; var bodytop = document.documentelement.scrolltop; topval -= bodytop; win = $(window).height(); wincenter = win / 2; $.post("ajax.php",{do:'load_data'},function(table){ $(".popup tbody").html(table); } ); $(".popup").toggle(); popup = $(".popup").height(); if (topval > wincenter) topval -= popup; if ((topval+popup) > (win + 10)) topval = win-10-popup; if (topval < 10) topval = 10; $(".popup").css({left:leftval,top:topval}); }); how height after content received , added popup div? the popup seems gettin...

rspec - How do i use named routes in an Rails engine's specs? -

i have rails engine engine.rb defined: module keywords class engine < ::rails::engine isolate_namespace keywords end i have routes defined: keywords::engine.routes.draw resources :keyword_groups, only: [:new] end now, works great inside dummy app. can use variable keywords.new_keyword_group_path url path. however, when try same in rspec tests using capybara, fails! tried add following line spec_helper.rb suggested: config.include keywords::engine.routes.url_helpers but, when try use following line in tests: visit keywords.new_keyword_group_path i following error: nameerror: undefined local variable or method `keywords' #<rspec::core::examplegroup::nested_1:0x00000108833390> if instead try leave off "keywords" prefix, , do: visit new_keyword_group_path i error: actioncontroller::routingerror: no route matches [get] "/keyword_groups/new" which makes sense path should "/keywords/keyword_groups/new". ...

Oracle Package inside a CLOB with length > 32767 characters. How to "execute immediate" it? -

please suppose have package creation script stored inside table alpha, in column beta of type clob. clob length > 32767 characters. using pl/sql code, "execute immediate" package creation script. i achieve this? thank in advance kind help. i using oracle 10g execute immediate didn't support clobs until 11gr2 . can use dmbs_sql handle larger statements. in earlier versions build statement, 11g allows parse clob . there example here . creating package dynamically seems odd requirement though. since you're on 10g, need use version of dbms_sql.parse lets build large statements : the parse procedure supports following syntax large sql statements: dbms_sql.parse ( c in integer, statement in varchar2s, lb in integer, ub in integer, lfflg in boolean, language_flag in integer); note: procedure concatenates elements o...

How to count the number of elements added to an array and find the average of numbers added in Java? -

how can number of elements in array counted? so array can hold 10 elements, not filled. how count number of elements entered? also, correct way find average of array? have gives me this, the number of valid grades entered 10 [d@7ea987ac[d@7ea987acaverage: 0.0 //validate strings entered user if(convertedinput >= 0 && convertedinput <=100){ validarray[validarraycount] = convertedinput; validarraycount ++; } } catch(numberformatexception e){ } //prints number of valid values entered system.out.println("the number of valid grades entered " + varraylen); //for printing array backwards (int = (arraycount-1); i>=0; i--){ system.out.print(validarray); } //calculates sum of values in array of validarray (of grades) for(double d : validarray){ sum += d; } //avergae of valid number array double average = (sum/validarray.length); sy...

php - IN operator only returns if parameter is a specific value -

i have questions table (that contains questions) , tags table (that contains tags (represented integers) each question). what trying list of questions have same tag in in operator. however, query returns questions if 1 there , 0 if isn't there. doesn't return questions tag integer matches in operator. here sqlfiddle: http://sqlfiddle.com/#!2/c2ded3/2 it seems id in id = questions_tags.q_id somehow ambiguous. if more specific, succeeds: select id questions exists ( select 1 questions_tags questions.id = questions_tags.q_id , questions_tags.t_id in (1) );

javascript - Upload image in div of different size using html5 -

Image
i want upload image box (div) may rectangle, square , circle or of shape using html5 something below any appreciated from comments assume know how upload , draw image normally, explain how image "into shape" when drawing it. take @ compositing settings of 2d context. these allow use path or image perform masking on canvas. draw image canvas in desired size create path marks edges of shape want "cut out". 3. set context.fillcolor solid without alpha transparency when don't did so set context.globalcompositeoperation = 'destination-in' use context.fillpath draw path in destination-in mode. erases outside of path , keeps inside path. set context.globalcompositeoperation = 'source-over'` restore normal drawing behavior.

android - on Pause starts audio from starting not where i paused -

this code, using pause song , play has been left, playing song starting not has been paused, why ? private mediaplayer mediaplayer; mediaplayer = new mediaplayer(); public void play(){ try { mediaplayer.reset(); mediaplayer.setdatasource(strnurl); } catch (illegalargumentexception e) { } catch (securityexception e) { } catch (illegalstateexception e) { } catch (ioexception e) { e.printstacktrace(); } try { mediaplayer.prepare(); } catch (illegalstateexception e) { } catch (ioexception e) { } mediaplayer.start(); .................... } public void pause(){ mediaplayer.pause(); btnpause.setenabled(false); btnplay.setenabled(true); } i have placed whole code, allowing user tap on of item in listview. this pr...

linux - How to understand "$location" in a Systemtap script? -

the systemtap script: # array hold list of drop points find global locations # note when turn monitor on , off probe begin { printf("monitoring dropped packets\n") } probe end { printf("stopping dropped packet monitor\n") } # increment drop counter every location drop @ #probe kernel.trace("kfree_skb") { locations[$location] <<< 1 } # every 5 seconds report our drop locations probe timer.sec(5) { printf("\n") foreach (l in locations-) { printf("%d packets dropped @ location %p\n", @count(locations[l]), l) } delete locations } and source code of kfree_skb() is: void kfree_skb(struct sk_buff *skb) { if (unlikely(!skb)) return; if (likely(atomic_read(&skb->users) == 1)) smp_rmb(); else if (likely(!atomic_dec_and_test(&skb->users))) return; trace_kfree_skb(skb, __builtin_return_address(0)); ...

javascript - why is jquery resize not working? -

i making responsive menu. put code change menu in function called file. when document or window resized jquery call function file again change menu. not work. when load page works on resize don't. jquery: var width = $(window).width(); file(); function file(){ if(width <= 400){ $('.link').remove(); $('head').append('<link class="link" rel="stylesheet" href="nav2.css">'); }else if(width >400){ $('.link').remove(); $('head').append('<link class="link" rel="stylesheet" href="nav.css">'); }else{ alert('error'); } } $(window).resize(function(){ file(); }); $(document).resize(function(){ file(); }); can me fixing problem your width variable isn't going change once it's set. should move inside function declaration. function file(){ var width = $(window).width(); if(width <= 40...

html - Container height 100% - px -

i'm trying simple structure. header (35px height), container (100% height) , bottom (35px height too). for i'm ussing height: calc(100% - 72px); height: -webkit-calc(100% - 72px); height: -moz-calc(100% - 72px) , doesn't works safari v5 , ie ... http://jsfiddle.net/2kng68pa/ also try magin-top but... lost of time. please, can me? need same result jsfiddle compatible ie , safari v5 ... thanks in advance. if header , bottom fixed height, rest easy: html, body { height:100%; } * { box-sizing: border-box; margin:0; padding:0; } header,footer { height: 35px; background: #0ff; color: #fff; position:absolute; left:0; right:0;} header { top:0; } footer { bottom:0; } .container { background: #0f0; height: 100%; padding: 35px 0;} <header>header</header> <div class="container"> container </div> <footer>footer</footer>

c# - Custom ValidationAttribute error not showing up in ValidationSummary (MVC 4) -

i have simple field want ensure greater number. things note: i can't install additional nuget packages. i want server-side validation. i want use following custom validation technique rather opting pre-existing solution, because validation needs far more complex , application-specific. here's what's happening: enter -5 in hours text box , click submit. greaterthan's isvalid function called. the return new validationresult(formaterrormessage(validationcontext.displayname)); line hit (confirmed tracing through debugger). the form posts successfully, , no errors appear in validationsummary area in view. i expect "must greater than" error appear after calling validationsummary in view, given greaterthan class determined -5 not greater zero. idea why not case? here's custom validation class: public class myviewmodel { [required] [greaterthan(0)] [displayname("hours")] public string hours { get; set; } } publ...

c# - Array value seems to be different while in for loop compared to when it isn't -

i have multidimensional array values. use 2 loops loop through each item , add value them. while in array return correct value, when exits , value different. example: before loop: [[1,1],[2,2],[3,3]] during loop: [[2,2],[3,3],[4,4]] after loop [[50,50][65,65][90,90]] it seems randomly change. int[,] squareb = basesquare; int[,] squarec = basesquare; int[,] squared = basesquare; console.writeline("{0}", squareb[0, 1]); (int x = 0; x < sub; ++x) { (int y = 0; y < sub; ++y) { squareb[x, y] += 9; console.writeline("{0}", squareb[x, y]); squarec[x, y] += 18; squared[x, y] += 27; } } console.writeline("{0}", squareb[0, 1]); you're modifying exact same array tree times @ every single loop iteration: squareb[x, y] += 9; squarec[x, y] += 18; squared[x, y] += 27; these change exact same value.

php - removing array duplicates from associative array -

so have: array ( [animals] => array ( [0] => horse [1] => dog [2] => dog ) [team] => array ( [0] => cubs [1] => reds [2] => cubs ) ) trying eliminate repeat ones animals , same team. tried didn't help. $unique = array_map("unserialize", array_unique(array_map("serialize", $result))); seems doesn't reach deep inside, don't want either hard code animals or team. $data = [ 'animals' => ['horse', 'dog', 'dog'], 'team' => ['cubs', 'reds', 'cubs'] ]; $result = array_map('array_unique', $data); print_r($result);

java - Does Storm Trident newValueStream after persistentAggregate maintain partition from groupBy -

i trying scale trident topology post processing after groupby , persistentaggregate, using newvaluestream stream values after aggregate step. wondering if tuples remained partitioned during groupby step, or redistributed in other fashion. relevant code: .groupby(new fields("key")) .name("groupby") .persistentaggregate(new memorymapstate.factory(), new fields("foo", "bar"), new aggregator(), new fields("foobar")) .newvaluesstream() .name("newvaluestream")

haskell - Evaluating and gathering results of conditions -

i have bunch of conditions returns lists, there way of evaluating them without giving each condition name? simplified example: conditions j = c1 j ++ c2 j ++ c3 j c1 j | > 2 = ["x"] | otherwise = [] c2 j | j > 5 = ["y", "a"] | otherwise = [] c3 j | j > 10 = ["z"] | otherwise = [] c4 j | j > 10 && > 1 = ["z", "c", "hello"] | otherwise = [] you can define operator this: infixl 1 *| (*|) :: [a] -> bool -> [a] xs *| b | b = xs xs *| b = [] conditions j = (["x"] *| > 2) ++ (["y", "a"] *| j > 5) ++ (["z"] *| j > 10) ++ (["z","c","hello"] *| j > 10 && > 1) it'a possible rewrite last line as ++ (["z","c",...

php - tcpdf page number getting 0 -

in tcpdf trying add page, , getting wrong page number on setpage() function: 0 , can not find way solve. here code: require_once('../tcpdf.php'); // extend tcpdf class create custom header , footer class mypdf extends tcpdf { //page header public function test( $ae ) { if( !isset($this->xywalter) ) { $this->xywalter = array(); } $this->xywalter[] = array($this->getx(), $this->gety()); } } // create new pdf document $pdf = new mypdf('l', pdf_unit, 'a1', true, 'utf-8', false); // set rotate $params = $pdf->serializetcpdftagparameters(array(90)); // other configs $pdf->setopencell(0); $pdf->setcellpadding(0); $pdf->setcellheightratio(1.25); // create html content $html = '<table width="100%" border="1" cellspacing="0" cellpadding="5"> <thead> <tr bgcolor="#e6e6e6"> <th rowspan="2" width="15%" align="c...

regex - adding parameter to wordpress url without query string -

i want have parameter in friendly urls way, have done query string not want below link http://www.example.org/category-name/sub-category/post-name-goes-here and want have link in template http://www.example.org/category-name/sub-category/post-name-goes-here/parameter it should still load same single page parameter can use condition in single page template how can ignore using rewrite rule or other method? you need add rewrite rule doesnt try , "solve" url address using standard function . see previous answers here: add "custom page" without page wordpress rewrite based on form hidden field you can pretty add url after that.

xcode - Let other user to debug my iOS app -

what easiest option let debug app's source code on macbook? must registered developer in apple portal, or registering device udid enough? can send him developer provisioning profile contains device or should export certificate keychain (.p12) , send him? thanks! just send him source code. able open , run other programs.. if want go more controlled use eg github sharing code.

android - ListView.addHeaderView(View) Crash on Api 11 and API12 -

i have list view need add header view , footer view, it runs on api else 11 & 12. this log cat java.lang.illegalstateexception: cannot add header view list -- setadapter has been called. 11-13 11:21:13.717: e/androidruntime(583): @ android.widget.listview.addheaderview(listview.java:255) 11-13 11:21:13.717: e/androidruntime(583): @ mediafragment.setadapter_(mediafragment.java:1041) 11-13 11:21:13.717: e/androidruntime(583): @ mediafragment.jsonobjectonsuccess(mediafragment.java:991) 11-13 11:21:13.717: e/androidruntime(583): @ mediafragment.getcache_db(mediafragment.java:2074) 11-13 11:21:13.717: e/androidruntime(583): @ databaseadapter$getasynctask.onpostexecute(databaseadapter.java:253) 11-13 11:21:13.717: e/androidruntime(583): @ databaseadapter$getasynctask.onpostexecute(databaseadapter.java:1) 13 11:21:13.717: e/androidruntime(583): @ android.os.asynctask.finish(asynctask.java:590) 11-13 11:21:13.717: e/androidruntime(583): @ android.os.asynctask.access$600(...

amazon s3 - Unable to load images -

i'm getting error , image doesn't show . unable load image . banging head on . please help. error below, get https://s3.amazonaws.com/ashu1197/demo+3?awsaccesskeyid=akiajgn4j4rsrnw26iea&expires=1415795641&signature=wdp6xu%2ff9e2lq6fpzkbr0ef5olm%3d 403 (forbidden) please help.

java - Create a copy of Gradle Test task -

i need run project tests both locally , automatically on teamcity server. local test execution must use local database connection, , when run on teamcity, tests must use remote connection database. so need tell tests, when use local connection , when use remote , pass url, username , password in case. to tell decided use java system properties. found built-in support in gradle that systemproperty 'some.prop', 'value' the question is, how can create standard test task local test run, not pass properties, , custom test task, set system properties before run? i tried task teamcitytest(type : test) { scanfortestclasses = false includes = ['**/*test.class'] systemproperty 'some.prop', 'value' } but failed npe, means i'm doing wrong. the approach fine (you can use java plugin's test task running tests locally), you'll have configure further properties teamcitytest such classpath = configurations.te...

linux - Change python path for a specific python install -

i have full python installation files in /usr/local/ , have 1 compiled source sitting in ~/python_dist . if @ sys.path on each interpreter see indeed import different libraries. currently can run $ pythonpath=~/other_py_libs ~/python_dist/bin/python invoke custom interpreter other modules available in path. however, don't want permanently change global pythonpath variable. how can permanently change python path 1 specific python install? the easiest way use virtualenv (manage virtualenvwrapper ). virtual environments can set different, isolated python environments (kind of little python playgrounds). switching between them (with of virtualenvwrapper) easy typing workon envname . don't have worry switching pythonpath around, , can direct scripts use specific environment running them python install in environment, e.g. using #! /home/myname/.virtualenvs/envname/bin python .

mysql - Update two Rows of one column in one table -

lib_issue_id book no member id issue date return date ------------ ------- --------- ---------- ----------- 7001 101 1 10-dec-06 null 7002 102 2 25-dec-06 null 7003 104 1 15-jan-06 null 7004 101 1 04-jul-06 null 7005 104 2 15-nov-06 null 7006 101 3 18-feb-06 null i have table following constraint: lib_issue_id - primary key book_no - foreign key member_id - foreign key issue_date <= system date issue_date < return_date how can modify return_date of 7004 , 7005 15 days after issue_date ? you can use in or or in update: update [tablename] set return_date = issue_date + 15 lib_issue_id in (7004, 7005);

javascript - Show android native datepicker in a webview -

hi every programming guru i building android webview app based , pick date datepicker. found mobi pick not compactible css output bad. don't want use phonegap. know possible call android native datepicker javascript when text input focus. show me samples or links tutorials have done please. in advance. my html code <form > <span> <input type="date" placeholder="start date : aaaa-mm-jj"> </span> <span> <input type="date" placeholder="end date : aaaa-mm-jj" > </span> <input type="button" value="filter" onclick="filter()" /> <div class="clear"> </div> </form> i want display native android datepicker on date field focus. public void opendatepickerui() { calendar c = calendar.getinstance(); year = c.get(calendar.year); month = c.get(calendar.month); day = c.get(calendar.day_of_month); //updatedisplay(); date...

smalltalk - check if 2 linked list have the same elements regardless of order -

is there way check if 2 linked lists have same elements regardless of order. edit question: have fixed code , given more details: this method compares 2 lists compare: object2 ^ ((mylist asbag) = ((objetc2 getlist) asbag)). the method belongs class myclass has field : myllist. mylist linkedlist of type element. i have compiled in workspace: a: = element new id:1. b:= element new id:2. c:=element new id:3. d: = element new id:1. e:= element new id:2. f:=element new id:3. elements1 := myclass new. elements addfirst:a. elements addfirst:b. elements addfirst:c. elements2 := myclass new. elements addfirst:d. elements addfirst:e. elements addfirst:f. transcript show: (elements1 compare:elements2). so getting false.. seems checks equality reference rather equality value.. so think correct question ask be: how can compare 2 bags value? have tried '=='..but returned false. edit: question changed too - think...

android - Apply Font Family on TextView -

i new in android. in app have number of textviews , want apply different font family on textview along number's of following condition: 1: textview should never extend i.e don't want create custom textview 2: don't want set font on run time i.e first reference of textview in code set programmitically using settype method. 3: want xml tag "customefontfamily" , tag can provide different font family on different textview. i read this link shows first android default font family. after 500 mili seconds changes font family defined in xml . any on problem appreciated! thank in advance! your requirements: 1: don't want create custom textview extending textview 2: don't want set font @ run time. 3: want use custom xml attribute "customfontfamily" under these requirements, there no solution problem. none of views in android sdk have code handle custom xml attributes define. if want use custom xml attributes, hav...

Exception handling and continuing with a for loop in python -

i have following code: import bio bioservices import keggparser, uniprot, quickgo #start new method of custom 'retrieve_data' class def locate_common_go(self,list_of_genes,go_term): #initialize variables , classes q = quickgo() = retrieve_data() b=[] get uniprot ids using (custom method) hugo2uniprot in range(0,len(list_of_genes)): b.append(a.hugo2uniprot(list_of_genes[i],'hsa')) print 'gene: {} \t uniprotid: {}'.format(list_of_genes[i],b[i]) search go terms (using bioservices quickgo) , store dictionary go_dict = {} q = quickgo() some of large list of gene names have not return hits. these cause attributeerror want handle move on next item in list. current code returns error: attributeerror: 'int' object has no attribute 'split'. error originates within bioservices module (so when i'm calling q.annotation...) in range(len(b)): try: go_dict[list_of_genes[...

javascript - Why does document.getElementsByName have a length of 0 despite having elements? -

this question has answer here: getelementsbytagname().length returns zero 1 answer the script runs before document loaded, why console.log(b) show elements in collection? if console.log(b) has elements why console.log(b[0]) show undefined , console.log(b.length) 0 ? <html> <head> <script> function test(){ var b = document.getelementsbyname('a'); console.log(b); console.log(b[0]); console.log(b.length); } test(); </script> </head> <body> <form id="a" name="a"></form> </body> </html> getelementsbyname returns nodelist . it's object containing list of matching nodes, b not null. however, you're running script before...

magento - Display text when Select is chosen -

i have form select, radio , checkbox options. php builds array of options , designators assigned them. how display designator each option when option selected? selects , options code: <select onchange="bundle.changeselection(this)" id="option-1" name="bundle_option_1" class="option-1"> <option value="1">option1</option> </select> <ul class="options-list"> <li><input type="radio" onclick="bundle.changeselection(this)" class="radio" id="bundle-option-2-select-2" name="bundle_option_2" value="2"/></li> </ul> <ul class="options-list"> <li><input type="checkbox" onclick="bundle.changeselection(this)" class="checkbox" id="bundle-option-3-select-3" name="bundle_option_3" value="3"></li> </ul> array gen...

angularjs - Unexpected Request: GET using grunt-angular-templates -

trying use generator-cg-angular. testing directives "error: unexpected request: ecosystem/job/directive/configkey/configkey.html" can fix using html2js, according cgross shouldn't need to. says don't have httpbackend configured pass through requests templates. can't figure out i'm doing wrong. more info here: https://github.com/cgross/generator-cg-angular/issues/78 code: describe('directive: configkey', function () { beforeeach(module('app')); var scope, ctrl, new_key; beforeeach(inject(function ($rootscope, $controller) { scope = $rootscope.$new(); ctrl = $controller('configkeyctrl', { $scope:scope }); new_key = { edit:true }; scope.data = angular.copy(data); })); it('should highlight added keys', function () { scope.key.change = 'add'; scope.savekey(); scope.$digest(); expect(elem.hasclass('alert-suc...

javascript - How can I pass an email address along with stripe token using $http POST and angular-payments? -

when process subscription credit card payment want include users email address before move on next step (setup actual account). i can setup subscription/charge card cannot seem include email address. i'm using angular-payments module. how can pass email address stripe? the form: <form stripe-form="stripecallback" name="checkoutform"> <input type="email" placeholder="email" ng-model="email" name="email"> <input ng-model="number" placeholder="card number" payments-format="card" payments-validate="card" name="card" /> <input ng-model="expiry" placeholder="expiration" payments-format="expiry" payments-validate="expiry" name="expiry" /> <input ng-model="cvc" placeholder="cvc" payments-format="cvc" payments-validate="cvc...

ember.js - pretender and query params -

i'm using pretender lib trek success long don't have query params. i've spent officialiy 4 hours staring @ code below , can't work. i'm defining url doesn't seem hit. when @ call has not been caught coming exact url defined! if can me out 1 great. the test code have: var server; module("check search index page", { setup: function() { 'use strict'; ember.run(function() { app.reset(); server = new pretender(function() { this.get('/api/v1/holidays.json?display_type=detail&page=1&sort%5bprice%5d=&sort%5bname%5d=&sort%5brating%5d=&filter%5bduration_min%5d=1&filter%5bduration_max%5d=32&filter%5bprice_min%5d=50&filter%5bprice_max%5d=3800&filter%5bbus%5d=true&filter%5bflight%5d=true&filter%5bself_transportation%5d=true', function (request) { return [200, {'content-type': 'application/json'}, '{"holidays":[{"id...

jquery - Twitter Bootstrap - Navbar toggle won't open on pages other than the index -

i've been experimenting bootstrap 3 on site here: http://infenterprises.com/ problem is, when attempt open navbar toggle (mobile view) opens on home page. services drop-down as-well. thank you! <div class="container-fluid"> <!-- brand , toggle grouped better mobile display --> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse"> <span class="sr-only">toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href=...

How can I show the window print dialog using JavaScript in Google Chrome? -

i’m using javascrpt window.print() function print out document. here problem in google chrome when window.print() function run shows chrome print dialog not window print dialog. how can show window print dialog in google chrome? it behaving correctly see more information. the window object represents open window in browser. if document contain frames ( tags), browser creates 1 window object html document, , 1 additional window object each frame. source.

SQL Server Authentication using encrypted password -

i keeping sql server password in clear text, security threat now. i replace encrypted password. don't know whether sql server accepts encrypted password or not. or if there other solution it. any on appreciated. lokesh sql server requires password specified in connection string set in plain text. if password stored encrypted, connection string can dynamically created , password decrypted use in connection string. to keep password safe @ network level, things such ssl based connections sql server or ipsec can leveraged provide protocol safety. http://technet.microsoft.com/en-us/library/bb742429.aspx http://technet.microsoft.com/en-us/library/ms189067(v=sql.105).aspx

javascript - Image map by alpha channel -

<img src="circle.png" onclick="alert('clicked')"/> let's imagine circle.png 400x400 px transparent background image circle in middle. what i've got entire image area (400x400px) clickable. have circle (non transparent pixels) clickable. of course know in example use <map> tag , circular area, i'm looking general solution take consideration actual image transparency , work kind of images (i.e. non regular shapes). the complex way see trace contour of image basing on each pixel alpha, convert path (maybe simplify) , apply map. is there more efficient / straightforward way so? using canvas tag, can determine color value of pixel under given spot. can use event data determine coordinates, check transparency. remains loading image canvas. first, we'll take care of that: var ctx = document.getelementbyid('canvas').getcontext('2d'); var img = new image(); img.onload = function(){ ctx...

sigma.js: is there a way to drag-select multiple nodes? -

i try drag-select end dragging graph itself. don't see settings can change drag action. is there way drag-select multiple nodes @ once? yes, see example: https://github.com/linkurious/linkurious.js/wiki/how-to-select-and-drag-multiple-nodes with plugin: https://github.com/linkurious/linkurious.js/tree/linkurious-version/plugins/sigma.plugins.dragnodes linkurious.js provides high-level plugins sigma.js. free open source projects. disclaimer: work @ linkurious sas.

c++ - Design pattern for static base constructor that calls static method in final class -

how can achieve following design using c++11: class consumer : base<consumer> { // different consumers have different methods (of same signature) void foo(){...} void bar(){...} : // etc. static void override register_all () { register_method<&consumer::foo>("foo"); register_method<&consumer::bar>("bar"); : // etc. } : } template<typename t> class base { static base() { register(); } virtual static void register_all(){ }; using f = void(t::*)(); template<f f> static void register_method(std::string name) { ... } } ...? note i'm doing 2 illegal things: i using static constructor (not allowed) on base class i using virtual static function (also not allowed) note: registration of methods needs occur once, before first instance accessed (it populate static c-function-pointer table). finally,...

android - MediaPlayer setOnPreparedListener doesn't get called for second time -

i using listview adapter displays list of tracks.each list item has play , stop icons play , stop track.the issue having track gets played once when first click on play button.after if stop clicking on stop button , try play track doesn't played.through toast message found out holder.img1.setonclicklistener() method called onprepared() method doesn't called on clicking on play button second time or after that..if replace mmediaplayer.pause(); mmediaplayer.release(); still same result..if put mmediaplayer=new mediaplayer(); inside onclick() method of holder.img1.setonclicklistener above issue resolved clicking on multiple play buttons start playing multiple tracks @ same time don't want.. trying going nightmare due naming conventions , lack of commenting. recommend change naming convention people looking @ code have idea each of variables doing. small comments on can helpful when in understanding trying do.