Posts

Showing posts from June, 2010

jquery - Javascript static variables and using in different pages -

i have jquery plugin in layout page header: <script src="@url.content("~/scripts/js/kendo.web.min.js")"></script> <script src="@url.content("~/scripts/app/jscommon.js")"></script> <script src="@url.content("~/scripts/app/layout.js")"></script> and layout.js: (function ($) { var layout = function (node, options) { this.node = node; this.options = $.extend({ url: "" }, options); $(this.node).find('.hbutton').bind('click', $.proxy(this.hbuttonclicked, this)); }; layout.prototype = { constructor: layout, _loadbackground: function () { debugger; //load second 'common.currenttarget' have been lost $(common.currenttarget).removeclass(); $(common.currenttarget).addclass(".hbutton_selected"); }, hbuttonclick

c# - WCF to Android communication and vice versa -

hi guys ask how talk wcf service using android java im using wshttpbinding in wcf , android send , receive service calling methods exposed wcf. how deal data contracts in android because im using add service reference in visual studio. guys please help? thanks...

Common usages for chain of responsibility? -

i saw tutorial video explain chain of responsibility design pattern, , think understand how works i'm not sure when use it. common usages of chain of responsibility? from gof : known uses several class libraries use chain of responsibility pattern handle user events. use different names handler class, idea same: when user clicks mouse or presses key, event gets generated , passed along chain. macapp [app89] , et++ [wgm88] call "eventhandler," symantec's tcl library [sym93b] calls "bureaucrat," , next's appkit [add94] uses name "responder." the unidraw framework graphical editors defines command objects encapsulate requests component , componentview objects [vl90]. commands requests in sense component or component view may interpret command perform operation. corresponds "requests objects" approach described in implementation. components , component views may structured hierarchica

r - Saving a graph with ggsave after using ggplot_build and ggplot_gtable -

i modifying graph built ggplot altering data produced ggplot_build (for reason similar include space missing factor level used in fill aesthetics in geom_boxplot ). far understand found on topic, should able save result applying ggplot_gtable , arrangegrob before calling ggsave on results ( saving grid.arrange() plot file ). however obtain error "plot should ggplot2 plot", simple reproductible example: require('ggplot2') require('gridextra') df <- data.frame(f1=factor(rbinom(100, 1, 0.45), label=c("m","w")), f2=factor(rbinom(100, 1, 0.45), label=c("young","old")), boxthis=rnorm(100)) g <- ggplot(aes(y = boxthis, x = f2, fill = f1), data = df) + geom_boxplot() dd <- ggplot_build(g) # printing graph works: print(arrangegrob(ggplot_gtable(dd))) # saving graph doesn't: ggsave('test.png',arrangegrob(ggplot_gtable(dd))) can explain why not work ? there way u

android - dynamic generation of layout view inside scrollbar -

i facing issue need generate dynamic views 1 below inside scrollview. views should generated after button click. for first button click, working fine after second click failing error "java.lang.illegalstateexception: scrollview can host 1 direct child" can me fixed. my main activity layout scrollview activity_main.xml: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:context=".mainactivity" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/parentrl"> <spinner android:id="@+id/spinstate" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <spinner android:id="@+id/spincity" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_b

objective c - NSImageView resized with image size -

i'm new obj-c/cocoa programming , facing problem nsimageview. goal create app allow user put image on drag&drop. the problem following : when we're dropping image larger window, resizes window image size, i don't want that ! put nsimageview nsscrollview part of image must showed , user move sliders view entire 1 (or resize window), that's want.. here xib hierarchy (concerned part) : view nsscrollview view nsimageview in code of nsimageview, have (about problem) : [self setimagescaling:nsscaleproportionally]; [self setimage:newimage]; note : sliders seem move view , not image note2 : can't resize window lower size image i have horrible aversion nib files , prefer things programmatically whenever possible i'm not that... here's little listing little nsscrollview test app coded similar. non-self-contained thing mentioned in code chunk window name, refers nswindow * window created. , self here refers controller obj

caching - cpu cache performance. store misses vs load misses -

i'm using perf basic event counter. i'm working on program suffers data cache store misses. as high ratio of %80. i know how caches in principle work. loads memory on various miss cases, removes data cache when pleases. don't understand , difference between store - load misses. how differ loading , storing. how can store-miss ? a load-miss (as know) referring when processor needs fetch data main memory, data not exist in cache. whenever processor wants data main memory, esquires cache, , if data loaded load-hit , otherwise load-miss. a store-miss related when processor wants write newly calculated data main memory.when wants write-back data main memory, hasto make sure content of cache , main memory in sync each other. can happen 2 different policies can find here: writing policies . so no matter policy choose, first need check whether data in cache can store cache first (since it's faster), , if data block looking has been evicted cache, store-miss r

Powershell variables not written correctly -

so in powershell script have 2 variables getting multiplied each other, there 1 problem, powershell can't tell want multiply variables each other. script below: $answer = $a*$equation the $a variable 7 . $equation variable 365*675/54 want script 7*365*675/54 , set answer $answer variable. when debug script says problem in * symbol . can here? i use invoke-expression instead of running powershell instance. $answer = invoke-expression "$a*$equation"

actionscript 3 - Array won't refresh itself after removeChild -

there array of objects. i'm trying removechild object array below. removechild works fine array won't refresh after removing uppest object. can see in below, tried trace array items out. firstly, array has 3 items, myarray.length must 3. after removing child, myarray.length must 2, 3 (wrong). removechild(myarray[currshape]); trace(myarray); please tell me missing here. assuming you're using actionscript, removechild() serves take objects off stage. doesn't take things out of array. have take object out of array manually in statement.

Android NDK undefined reference during linking -

i'm trying link executable created ndk-build existing .so library built ndk. here's android.mk file: local_path := $(call my-dir)/.. include $(clear_vars) local_module := mini_executor local_c_includes := ../.. local_src_files := main.cpp local_cxxflags += -std=c++11 local_static_libraries := mylib include $(build_executable) i'm getting ton of undefined references when try build it, implies me linking process not working. sure enough, if enable switch v=1 on ndk-build, see following lines: "compile++ thumb : mini_executor <= main.cpp c:/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++ -mmd -mp -mf ./obj/local/armeabi/objs/mini_executor/main.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float -fno-exceptions -fno-rtti -mthumb -os -g -dndebug -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -i../.. -ic:/android-

python - How to make a list formed by changing some defaults in multiple ways -

i have list of default dictionaries: default = [{"one": 1, "two": 2, "three": 3}, {"one": 5, "two": 6, "three": 7}, {"one": 9, "two": 10, "three" : 11}] all same keys. have separate dictionary key list: varying = {"one": [12,13,14,15], "two": [20,21,23], "three": [12,44]} what want make list of dictionaries possible made changing 1 of values in 1 of default dictionaries 1 of corresponding values in varying dictionary. here examples of dictionaries in final list: {"one": 12, "two": 2, "three": 3} {"one": 13, "two": 2, "three": 3} {"one": 14, "two": 6, "three": 7} {"one": 15, "two": 10, "three": 11} {"one": 5, "two": 20, "three": 7} {"one": 9, "two": 23, "three": 11} {"one&q

ruby on rails - Can I convert model with one of its associations to YAML format? -

i want print activerecord model in yaml format debugging purposes. currently invoke model.to_yaml . doesn't return model's associations how can convert model 1 of associations yaml format? you can convert json first. default activerecord as_json method allows include assocations. there, it's straightforward convert yaml. example: menu.as_json(include: :dishes).to_yaml

string - Getting data for replacement (python 3.3) -

for example, have string or list of such strings: text = '000 #-tags-2-7-# 001 002 003 004 05 06 07 08 sdfgsdfg #-tags-3-9-#' keys = ['key-1', 'key-2', 'key-3', 'key-4', 'key-5', 'key-6', 'key-7', 'key-8', 'key-9', 'key-10'] and need replace #-tags-2-7-# on result keys[randint(2, 7)] , #-tags-3-9-# on keys[randint(2, 7)] etc. need every time 2 integers #-tags- - -# , send keys[randint(*, *)] , send result instead #-tags- - -# you use re.sub replace pattern r'#-tags-(\d)-(\d)-#' desired string: import re import random text = '000 #-tags-2-7-# 001 002 003 004 05 06 07 08 sdfgsdfg #-tags-3-9-#' keys = ['key-1', 'key-2', 'key-3', 'key-4', 'key-5', 'key-6', 'key-7', 'key-8', 'key-9', 'key-10'] def tag_replace(match): start, end = map(int, match.groups()) return ', '.joi

python - Where do I put a function to count foreign keys in Django? -

i have django model object, record, has foreign keys 2 other models recordtype , source: class record(models.model): title = models.charfield(max_length=200) record_type = models.foreignkey(recordtype) source = models.foreignkey(source) question: if want count number of record objects refer recordtype id "x" , source id "y", appropriate area of code put function? right have in views.py , feel violation of best practices "fat model, thin views", want move views.py. i'm not entirely sure if row-based or table-based type of operation, i'm not sure if should implemented model method, or instead manager. here's current (working) logic in views.py: record_count = record.objects.filter(record_type__id=record_type_.id, source__id=source_.id).count() just clear, isn't question of how count, in area of code put function. here's similar question, addressing "how to" not "where": counting , summing

Error in xml file premature end of data in tag -

i took system ever made not know happening! line: 197 core.php foreach ($this->getall() $banner) { line: 191 core.php $_xmlbanners = simplexml_load_file(path_xml."banners.xml"); my xml: <?xml version="1.0" encoding="utf-8"?> <list> <banner id="1"> <image>http://lineagefree.com/acp/images/l2jbr.png</image> <link>http://l2j.lt/topai/balsuoti-7907.php</link> <votes> <link>http://l2j.lt/topai/mokamas-7907.php</link> <regexp><div class='list_8' style="font-weight: bold">(.*)</div></regexp> </votes> </banner> <banner id="2"> <image>http://lineagefree.com/acp/images/top100mmorpg.png</image> <link>http://l2j.lt/topai/balsuoti-7907.php</link> <votes> <link>http://l2j.lt/

sql - IF statement evaluating bit from php -

i have form posting script. there value on form called stat . here how handle it: $data['stat'] = isset($_post['stat']) ? true : false; echo "stat value: " . var_dump($data['stat']); the output (i testing false response: bool(false) stat value: my relevant sql evaluate value: @stat bit -- inserted data if @stat = 1 declare @newconsultid int select @newconsultid = scope_identity() exec insertfacilitydecision @newconsultid, 'emergency request', null, 17 what happening insertfacilitydecision stored procedure being called, though false values being passed stored procedure. am evaluating bit incorrectly? you should enclose begin ... end statements supposed executed on if condition if @stat = 1 begin declare @newconsultid int select @newconsultid = scope_identity() exec insertfacilitydecision @newconsultid, 'emergency request', null, 17 end begin end can ommited single

Using JavaScript and PHP to create a chatbot -

i have chat server. know if can use javascript xhr polling, , pass data php script processing, javascript can send message chat server , displayed users connected. possible? this can done using web sockets. a quick google search yields php library called ratchet web sockets create tunnel between server , client server can push/broadcast clients. for example when user types message , sends server, server broadcast of clients. don't have have javascript polling updated messages. i don't have experience ratchet have experience web sockets. combine sort of front end javascript framework such backbone.js

vb.net - ASP.Net Listview Eval time format -

i can't seem format right eval statement in label text in template on asp.net listview vb. did try escaping time still resulted in invalid format. data type in sql server bound data time(0). text='<%# eval("time", "{0:hh:mm tt}") %>' has run seemingly problem before , found correct format? did research posted @ http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx did not find solution problem. this 1 had me tearing hair out while... found solution: the second colon character needs escaped in format string backslash. try this, should work: text='<%# eval("time", "{0:hh\:mm}") %>'

Do all the named colors render correctly in WinRT apps? -

Image
i putting shapes on canvas , noticed of shapes appeared white despite being set different color. when changed color different appear fine. @ first thought fluke 1 color. after while noticed more. colors.lavender, colors.lavenderblush, , colors.honeydew 3 examples. when set these colors appears white instead. have tried on 2 different screens now. problem in emulator or did go selectively color blind? thanks you aren't going color blind, colors subtle off-white difference minimal. here's them next white , if closely different white.

bitbucket - Git: unable to create symlink (File name too long) -

i had pushed project linux bitbucked , cloned on windows. turns out there 2 symlinks, appeared textfiles on windows. since knew should point to, replaced them copies of destination files, committed , pushed. now butbucket repository looks okay when it web interface. git clone on unix machine gives me 2 messages like: error: unable create symlink ... (file name long) and 2 files, symlinks absent. tried cloning /tmp/... shorter filenames, got same results. suggests, went bad bitbucket repository. tried core.symlinks on , off. i can live without symlinks, i'd have working repository. know way (other recreating repository)? as changed content of fake-symlink-file without changing mode symlink regular file , committed result, made blob can't extracted on os real symlinks, because have object supposed symlink content long pathname. web interface not doing favors hiding problem. you're going have commit, fix it, , re-commit after it. git rebase -i help, st

osx - how to do simple concat in awk in mac -

so have file list.txt similar one: 186 423 423 234 634 437 and want output similar this: set 186 0 set 423 0 set 423 0 set 234 0 set 634 0 set 437 0 i tried this: sed 's/^ *//g' list.txt | awk '{a="set ";b=" 0";print a,$0,b}' but prints 0 186 0 423 0 423 0 234 0 634 0 437 given that sed 's/^ *//g' list.txt | awk '{a="set ";b=" 0";print a,$0}' works perfect: set 186 set 423 set 423 set 234 set 634 set 437 so don't know i'm doing wrong. do know how solve , why print a,$0,b doesn't work? it doesn't work because input file created on windows , has spurious control-ms @ end of each line , that's messing displayed output. run dos2unix on file or otherwise rid of control-ms

objective c - Adjust UICollectionViewFlowLayout When UICollectionView Frame Changes -

i have uicollectionview created programmatically, along uicollectionviewflowlayout. code looks like: - (uicollectionview *)createcollectiontodisplaycontent:(nsarray *)array viewwithcellidentifier:(nsstring *)cellidentifier ofwidth:(cgfloat)width withheight:(cgfloat)height foremailview:(emailview *)emailview { cgfloat mininteritemspacing; if (!self.orientationislandscape) mininteritemspacing = 9.0f; else mininteritemspacing = 20.0f; uicollectionviewflowlayout *layout = [[uicollectionviewflowlayout alloc]init]; layout.itemsize = cgsizemake(220.0f, 45.0f); layout.sectioninset = uiedgeinsetsmake(5.0f, 0.0f, 5.0f, 0.0f); layout.minimumlinespacing = 10.0f; layout.minimuminteritemspacing = mininteritemspacing; //get pointer layout can change later emailview.personlabelslayout = layout; uicollectionview *collectionview = [[uicollectionview alloc]initwithframe:cgrectmake(40, 4, width, height) collectionviewlayout:layout]; collectionview.dat

c# - Windows Forms toolstrip q -

i have application tab control. tab control dock property set fill. if place toolstrip along top of screen, tabs on tab control hidden beneath toolstrip. how include toolstrip , avoid having tabs hidden beneath it? you can this: yourtoolstrip.dock = dockstyle.top; yourtabcontrol.dock = dockstyle.fill; yourtabcontrol.bringtofront();

java - Difference webcontent and webapp -

i've 2 spring mvc projects in eclipse, web content in different positions. in 1 app it's located under: /webcontent in other app under: /src/main/webapp why that? what's difference? is there way can see how each project created in order create new 1 in same fashion? project directory structure depends on how created , build tool using. if create selecting file -> new ->dynamic web project in eclipse, find /webcontent directory. if created using maven, directory strutcure /src/main/webapp. please go throuh here more information on maven project strutcure.

c++ - boost spirit expression grammar issue while creating AST -

i'm trying parse expression grammar (with variables) abstract syntax tree (ast) later on make use of ast , calculate values basing on expressions (they may part of function example, there no need store expressions rather calculate value right away). to surprise, after handling loops , instructions (which require nested structures in ast well), got nothing seg faults after trying parse expression.. after hours of struggling decided ask here, because have no idea (maybe grammar) this statement-loop part works well. struct 'loop' gets parameter number of repetitions - string far (later on want put expression here): statement %= loop | inst; inst %= lexeme[+(char_ - (';'|char_('}')) )] >> ';'; loop = "do(" > lexeme[+(char_ - "){")] // parse number of loop repetitions > "){" > *statement > "}" ; structures like: typedef boost::variant< boost::

Gallery of proj4 projections? -

is there gallery of 100+ map projections proj4 supports ("cs2cs -l")? i'm tempted create 1 myself, i'm sure else has done this? a google images search '"apian" "boggs" "bonne" "chamb" "eck3"' (some of abbreviations used proj4): https://www.google.com/search?tbm=isch&q=%22apian%22+%22boggs%22+%22bonne%22+%22chamb%22+%22eck3%22&biw=1010&bih=572 yields nothing useful. looking @ proj4 main page you´ll find in documentation section: - projections list page on geotiff site includes information on how describe many common projections proj.4 command arguments. in same proj4 main page there link gallery of projections: paul b. anderson's map projections site

javascript - Jquery .val() doesn't work on firefox -

i have textarea user can type comment , press enter submit comment , after textarea's text should cleared , placeholder should appear used function <tr id="sc-1-comment" style="background-color:white;"> <td colspan="2"> <textarea id="id_comment_to_post-1" name="comment" style="resize: none; vertical-align: middle;" placeholder="leave comment..." onkeydown=" if (event.keycode == 13 && !event.shiftkey) { event.preventdefault(); new_comment('commentsinnerhtml-1', '1',document.getelementbyid('id_comment_to_post-1').value); $('#id_comment_to_post-1').val(''); } "></textarea> </td> in chrome , ie works in firefox, ends clearing text , inserting new line in textarea , placeholder won't appear there new line in textarea. any suggestions?

javascript - Example, is this strategy pattern? -

as topic itself, example of strategy pattern in javascript? (i think question more suitable codereview redirect me on stackoverflow) var canvas = { context: document.getelementbyid("canvas").getcontext("2d") }; /////////////////////////////////////////////////// function square(_strategy) { this.x = 50; this.y = 50; this.width = 100; this.height = 100; this.strategy = _strategy; } square.prototype.draw = function() { this.strategy(this); }; /////////////////////////////////////////////////// function circle(strategy) { square.call(this, strategy); this.radius = 25; } circle.prototype = new square(); /////////////////////////////////////////////////// function drawsquare(shape) { canvas.context.strokerect(shape.x, shape.y, shape.width, shape.height); } /////////////////////////////////////////////////// function drawcircle(shape) { canvas.context.beginpath(); canvas.context.arc(shape.x , shape.y, shape.radi

android - Posting a runnable to a View that invalidates the View sometimes doesn't work -

i been fighting odd issue these last few days. have custom expandablelistadapter each row contains imageview, among other things. have class handles asynchronous loading of images multitude of places may reside (disk cache, app data, remote server, etc). in adapter's getview method delegate responsibility of returning view list item (i have multiple row types group list). request image load follows: final imageview thumb = holder.thumb; holder.token = mfetcher.fetchthumb(mimage.id, new bitmapfetcher.callback() { @override public void onbitmap(final bitmap b) { thumb.post(new runnable() { @override public void run() { thumb.setimagebitmap(b); } }); } @override public void onfailure() { } }); yeah, it's ugly, decided against contract have bitmapfetcher.callback execute meth

cordova - Ajax error load Url from remote server in phonegap -

i have been develop phonegap android app. put folder www in remote server, , in mainactivity(droidgap) loadurl server. had config in phonegap , app running in device ( load , show page server). problem when send request ajax server fail. not connect host. please me? thanh much. - mainactivity @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); super.loadurl("http://172.16.3.198:8080/servermail/index.html"); } - config.xml <access origin="*"/> <content src="http://172.16.3.198:8080/servermail/index.html" /> the app not have internet permission. can edit androidmanifest.xml, , below: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.petro" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:mi

c# - How can I update a MVC model list property first be compiling the list on client -

how can update mvc model list property dynamically when user adds value each time input field on view my app c# web application , using razor views. so, model has property called workers of data type list: public class factory { public list<worker> workers { get; set; } public class worker { public string name { get; set; } } } and, in razor view have following: @model app.models. factory <div id="worker" class="form-group"> @html.labelfor(m => m.workers, new { @class = "col-lg-2 control-label" }) <div class="container"> @html.textboxfor(m => m.workers, new { placeholder = "worker name", @class="form-control", id="workerinput"}) </div> </div> the input @html.textboxfor should have corresponding button called "add worker". so, when user adds worker , clicks button, name of worker should added list of workers

symfony - FOSRestBundle force one route in format html -

it possible make sure single route made available in html format? in configuration set html , json, 1 route json not used. can do? i have not tried on cell phone have looked @ trying 1 route: my-awesome-route: pattern: /hello/{fist_name}/{last_name}.{_format} defaults: { _controller: acmehellobundle:default:index, _format:html} requirements: _format: html

javascript - Integrate Fancybox with AngularJs -

i getting started angularjs , know if possible integrate fancybox angularjs controller there default fancybox loading animation shown between ajax requests. using following code nothing happens , there no console errors or messages. if example code provided in case there alternative solution using fancybox. thanks. note: have defined div ng-view inside index.html file. $scope.search = function () { $.fancybox.showloading(); myapp.query({ query: $scope.query }, function (value, responseheaders) { $.fancybox.hideloading(); }); }; you need create directive integrate fancybox angular code. @ similar lightbox directive created here . can seen in action here . coming showing loading animation on ajax request, using fancybox not correct not primary purpose. google how ajax spinner angularjs. basic idea implement request , response interceptor , show animation. 1 such example present here

java - Practical Use to Temp Files -

what practical use temporary files (see code below)? file temp = file.createtempfile("temp-file-name", ".tmp"); why can't store data keep in file in variables? if file (probably) going deleted on program exit (as "temp" implies), why create them? an example can such when downloading file, appears temporary file while downloading completes. aside ram versus disk comment above. may use temp files precusor files or files processed or served. example, server may generate large pdf browser. pdf file stored temp file while (possibly slow) browser downloads file. once communication complete, temp file can destroyed.

java - Outputting JSON -

i trying output list in json formatting it's not coming out quite way want it. here output: { "songmap": [ { "sid": "699", "sdid": "1079287588763212246" }, { "sid": "700", "sdid": "1079287588763212221" }, { "sid": "701", "sdid": "1079287588763212230" } ] } here like: [ { "sid": "699", "sdid": "1079287588763212246" }, { "sid": "700", "sdid": "1079287588763212221" }, { "sid": "701", "sdid": "1079287588763212230" } ] i don't need nor want intermediate array, im not sure why it&

I am using javamail IMAP but I dont know how to get Sent or another folder except inbox -

i trying sent folder in gmail. it's depend on language. ex, if used english tree list below: [gmail]/all mail [gmail]/bin [gmail]/drafts .... but if use other language, folder translated language. try create index folder it's not successful because folder sorted follow alphabet. can't hardcode : getfolder("[gmail]/sent mail") , in other language "sent mail translated. have question. can name of folder how recognize "sent mail" folder mail sent. gmail folders have attributes , can rely on them folder want (if it's 1 of standard ones). so, if store.getdefaultfolder().list("*"); you folders, not first level. , response server should looks this: a3 list "" "*" * list (\hasnochildren) "/" "inbox" * list (\noselect \haschildren) "/" "[gmail]" * list (\hasnochildren \all) "/" "[gmail]/all mail" * list (\hasnochildren \drafts) "/"

sorting - How can I sort tuples by reverse, yet breaking ties non-reverse? (Python) -

if have list of tuples: results = [('10', 'mary'), ('9', 'john'), ('10', 'george'), ('9', 'frank'), ('9', 'adam')] how can sort list might see in scoreboard - such sort score biggest smallest, break ties alphabetically name? so after sort, list should like: results = [('10', 'george'), ('10', 'mary'), ('9', 'adam'), ('9', 'frank'), ('9', 'john')] at moment can results.sort(reverse=true) , breaks ties reverse alphabetically too... any appreciated. thanks! the simplest way achieve want use fact python sort stable. allows first sort alphabetically , score: in [11]: results = [(10, 'mary'), (9, 'john'), (10, 'george'), (9, 'frank'), (9, 'adam')] in [12]: results.sort(key=lambda x: x[1]) in [13]: results.sort(key=lambda x: x[0], reverse=true) in [14]: results out[1

javascript - How to hide multiple Show/Hide DIV's when another DIV is clicked -

how hide buttons in second , third row if different button clicked in first row , if button clicked in second row hide buttons column , show buttons column clicked? i'm trying achieve form similar http://gazelle.com/ website it's getting bit difficult me. example: if click, "iphone" -- buttons iphone 5, iphone 4s, iphone 4, , iphone 3gs show, click, "iphone 5" -- buttons at&t, sprint, verizon, unlocked, , other show under first row, change mind , decide click "tablet" in first, buttons "tablet" show buttons iphone 5 go hiding buttons "tablet" show up. <!doctype html> <html> <html xmlns=" http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript"> function showhide(obj) { var div = document.getelementbyid(obj); if (div.style.display == 'none') { div.style.display = ''; }

android - SQLite disk IO exception and can't open database exception -

i have gone through other similar questions did not answer. in android app i'm opening pre-built database. in assets folder , copied using sqliteopenhelper , if not present. class: import java.io.fileoutputstream; import java.io.ioexception; import java.io.inputstream; import java.io.outputstream; import android.content.context; import android.database.sqlexception; import android.database.sqlite.sqlitedatabase; import android.database.sqlite.sqliteopenhelper; public class externaldbopenhelper extends sqliteopenhelper { public static string db_path; public static string db_name; public sqlitedatabase database; public final context context; public sqlitedatabase getdb() { return database; } public externaldbopenhelper(context context, string databasename) { super(context, databasename, null, 1); this.context = context; string packagename = context.getpackagename(); db_path = string.format("//data//data//%s//databases//", packagename);

java - How does builder pattern works -

ruby (rails) programmer 2 years, switched team uses java. have questions java builder pattern. i understand benefits of using pattern, namely avoid telescoping constructor , java bean setters creates inconsistent state have trouble understanding how works, following exact pattern team requires me use: public class person { //why important final, hence immutable private final string firstname; private final string lastname; // constructor public person(string firstname, string lastname) { this.firstname = firstname; this.lastname = lastname; } //i have absolutely no idea , why necessary public static builder builder() { return new builder(); } //this inner class, person outer class (the owning class) //but why has static class? public static class builder { private string firstname; private string lastname; public builder withfirstname(string firstname) {

django - Another South "table does not exist" issue: none of the previously posted solutions working -

i trying make app using django , using south handle migrations. after define app's models.py, include south in "installed_apps" in settings.py. sync database. when validate database, 0 errors. execute following commands on command prompt: c:\users\abagaria\desktop\integrateid\website>python manage.py schemamigration w ebsite.integrate --initial creating migrations directory @ 'c:\users\abagaria\desktop\integrateid\website\ website\integrate\migrations'... creating __init__.py in 'c:\users\abagaria\desktop\integrateid\website\website\i ntegrate\migrations'... + added model integrate.publisher + added model integrate.author + added model integrate.book + added m2m table authors on integrate.book created 0001_initial.py. can apply migration with: ./manage.py migr ate integrate c:\users\abagaria\desktop\integrateid\website>python manage.py migrate website.i ntegrate running migrations integrate: - migrating forwards 0001_initial. > integr

javascript - How to build a simple string from a multidimensional array? -

basically, have multidimensional array need build simple string. quite easy question, although has been eating away @ me quite time since can't seem nail it. here example of how array 3 questions within it: [["question1","answer1","answer2","answer3","answer4"],["question2","answer1","answer2","answer3","answer4"],["question3","answer1","answer2","answer3","answer4"]] for example, d.rows[0][0] "question1" , d.rows[2][3] "answer3", clarify. here how must saved string as: question1,answer1,answer2,answer3,answer4 question2,answer1,answer2,answer3,answer4 question3,answer1,answer2,answer3,answer4 each element must have comma between them, , each question must separated line-break. this have not working: var fullstring; (i = 0; < csvarray.length; ++i) { second = secondarray[i]; (j

c# - nhibernate returns an empty collection -

i have scenerio saving graph of objects , need retrieve later on in process. simple case of data manupulation really. the problem after successful save of object , associated collection- indicated output insert statements- subsequent query same object returns empty collection associated collection. call flush() before that. strangely, closing , reopening application makes return populated collection. i have mapping appointment class <set name="workhours" inverse="true" cascade="all" lazy="true"> <key> <column name="person" /> </key> <one-to-many class="workhour" /> </set> here's code data retrieval method1() { dataaccessmanager.startoperation(); ienumerable<entity> q = getqueryprovider(); if (total > 0) { q = q.skip(startindex).take(total); } totalfound = q.count(); ilist<entity> list = q.