Posts

Showing posts from January, 2010

IE8 IE9 drop down menu inline error -

my css menu bar has little problem. bar works fine in other major browsers including ie10, not in ie 8 or 9. seem float or inline-block being ignored. shown stacked on top of 1 instead of side side. if have ie 8 or 9 can view problem @ kitchenova.com. have made jsfiddle of menu bar: http://jsfiddle.net/blzzl/ ie pain! #cssmenu ul, #cssmenu li, #cssmenu span, #cssmenu { margin: 0; padding: 0; position: relative; font-family:verdana, geneva, sans-serif } #cssmenu { height: 30px; border-radius: 5px 5px 0 0; -moz-border-radius: 5px 5px 0px 0px; -webkit-border-radius: 5px 5px 0 0; background: #e0e0e0; background: -moz-linear-gradient(top, #ffffff 0%, #e0e0e0 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ffffff), color-stop(100%, #e0e0e0)); background: -webkit-linear-gradient(top, #ffffff 0%, #e0e0e0 100%); background: -o-linear-gradient(top, #ffffff 0%, #e0e0e0 100%); background: -ms-linear-gradien

ios - Confused by how to setup my .xcdatamodel for versioning -

i reading core data model verisoning , data migration programming guide , confused on how set initial verison number. i have existing app in did not set core data versioning. in addition, using magical record. current version of app 1.3; ready release 1.4 minor changes, , want change 1 of core data entities (add new attributes) in release 1.5. absolutely need versioning users not lose existing data. assume must set current verison enable lightweight versioning release 1.5. the question is: core data version have match app version? or common way versioning work? magical record has convenience method this. in appdelegate setup magical record use. [magicalrecord setupcoredatastackwithautomigratingsqlitestorenamed:@"storename"]; alternatively click on core data .xcdatamodeld top bar editor > add model version

Why Does Output of This Command to a File Work Differently Inside a .BAT Script? -

wmic process name,processid,commandline >> test2.txt works dandy cmd.exe. however, not work .bat script (no output file changed or generated). echo output reads follows: wmic process name,processid,commandline 1>>test2.txt what "1" doing there? reflection of handle? why work differently , how can address it? the 1 number of file descriptor you're redirecting. if leave out file descriptor in redirection, 1 (stdout) implicitly assumed. more information see here . as command, it's working fine me both in batch file , directly in cmd .

java - JLabel on West/East won't show up in BorderLayout -

i using borderlayout, 3 containers gridlayout , array of 8 jlabels. container #1 uses 2 jlabels, container #2 uses 2 jlabels , container #3 uses 2 jlabels well. include container #1 north, works fine. container #2 center, works fine, container #3 south, works fine too. when come include 1 jlabel of array east , 1 jlabel west don't show up, don't know why , i've spend hours searching it. pretty much: add("north", con1); add("center", con2); add("south", con3); add("east", myarray[6]); add("west", myarray[7]); what doing wrong? d: lot you have add jlabels own panels, add panels borderlayout.

perl 101 subroutine and return value -

i don't understand how return 4 answer. not sure happening inside subroutine. sub bar {@a = qw (10 7 6 8);} $a = bar(); print $a; # outputs 4 the subroutine called in scalar context. last statement in subroutine assignment @a , expression , becomes implied return value. in scalar context, evaluates number of elements returned assignment's right-hand side (which happens same number of elements in @a ).

html - How can I make Javascript target the month? -

okay, theoretical me, have no code help. saying :) i wondering since possible, or @ least have seen been done before, make if statements time i.e. if (time>20) possible months? or did example mention (which found on w3schools.com) use variable without telling me haha. what i'm looking if statement (hopefully simple) resembles if(month==1) { //incorrect script follows goto(id);}; that example hideous function self not i'm looking for. i curious , couldn't find anywhere didn't have page worth of code that, me, looks simple in times we're in. i'll experiment code until can tell me. thank time : ) --------------------update!----------------- i started working on it. , not working me. tried. idea when open or style.display="block"; div of mine, automatically calls current month show people events happening month. var = new date(); var month = now.getmonth(); var jan = document.getelementbyid("january"); var feb = docu

SQL Server Aggregate functions -

i have table has 3 columns: customers, billingdate, consumption city - parks/6th ave bmx park 2013-04-29 00:00:00.000 0 city - parks/6th ave bmx park 2013-04-29 00:00:00.000 30 city - parks/6th ave bmx park 2013-05-30 00:00:00.000 0 city - parks/6th ave bmx park 2013-05-30 00:00:00.000 19500 city - parks/6th ave bmx park 2013-06-28 00:00:00.000 0 city - parks/6th ave bmx park 2013-06-28 00:00:00.000 42100 city - fire station #3 2012-11-27 00:00:00.000 0 city - fire station #3 2012-11-27 00:00:00.000 8900 city - fire station #3 2012-12-27 00:00:00.000 0 city - fire station #3 2012-12-27 00:00:00.000 7900 city - fire station #3 2013-01-28 00:00:00.000 0 city - fire station #3 2013-01-28 00:00:00.000 3090 city - fire station #3 2013-01-28 00:00:00.000 7210 city - fire station #3 2013-02-28 00:00:00.000 0 city - fire station #3 2013-02-28 00:00:00.000 10100 city - fire station #3 2013-03-29 00:00:00.000 0 city - fire station #3 2013-03-29 00:00:00.000 6700 city

html - Input with joined query component without JavaScript -

i have form element , url be http://example.com/page.html?a=constant+query_text if wanted http://example.com/page.html?a=constant&b=query_text i use <form action="http://example.com/page.html"> <input type="hidden" name="a" value="constant"> <input type="text" name="b"> <input type="submit"> </form> but there way desired form without scripting? you create server proxy you. put handler on server redirects requests target server , adds constant querystring. depending on web server, seems should able configuration settings, no code required. <form action="/myproxy"> <input type="text" name="a"> <input type="submit"> </form> apache mod_alias redirectmatch directive : redirectmatch ^/myproxy?a=(.+)$ http://example.com/page.html?a=constant+$1 iis url rewrite module : <

python - Implementing Referenceable objects client-side with Twisted Perspective Broker -

i trying implement simple server reply in perspective broker. possible implementation (please suggest others if possible): client requests server execute server method, server executes replies (by executing client method sole purpose print message): [client-side]: class clientprint(pb.referenceable): def remote_clientprint(self, message): print "printing message server: ", message [server-side]: class rootserverobject(pb.root): def remote_onefunc(self, ...): ... print "now sending reply..." *get clientprint object?* clientprintobj.callremote("clientprint", "this reply!") how can implement grabbing of client-side objects? there better way implement server replies grabbing client-side object , calling print-only client method? here full code trying implement replies: [client-side]: from twisted.internet import reactor twisted.spread import pb class client(): def __init__(self,

c# - SqlDataSource not reselecting data from database when data is changed -

i have dropdown list being populated sqldatasource, following markup: dropdown: <asp:dropdownlist id="saleiddropdown" runat="server" cssclass="dropdown" datasourceid="dropdowndatasource" datatextfield="title" datavaluefield="id" appenddatabounditems="true"> </asp:dropdownlist> datasource <asp:sqldatasource id="dropdowndatasource" runat="server" connectionstring="<%$ connectionstrings:sql-dev %>" selectcommand="select [id], [title], [userid] [adselect]"> </asp:sqldatasource> the problem i'm running when of data changed via web interface i'm making (i delete item, or change it's title example) dropdown populates old data, though has changed in database (i checked using sql server studio). if reload page, then dropdown populated correctly. i need way "force" refetching/selecting of data, effor

javascript - Changing the placeholder text based on the users choice -

jquery permitted, html-only solution preferred. i have select box couple of options. when user selects 'name', want placeholder text 'enter name' appear in adjacent text-box. likewise 'id' -> 'enter id'. see http://jsfiddle.net/uy9y3/ <select> <option value="-1">select one</option> <option value="0">name</option> <option value="1">id</option> </select> <input type="text"> this requirement client haven't been able figure out. if helps, website using spring framework. since need update placeholder when select updates, you'll need use javascript it. you set placeholder display attribute on each option element using html5 data- style attributes. use jquery attach change event listener update placeholder attribute of input box. note placeholder attribute doesn't have effect in older versions of ie, if need sup

jquery - get elements that is in viewport -

what wanted visible elements within viewport respect parent container. checking triggered via , animated scrolling of parent. i have found codes here, functions can check if element in viewport somehow not right. here's current function checks if it's in viewport or not. function checkinview(elem,partial) { var container = $("#timeline_wrapper"); var contheight = container.height(); var conttop = container.scrolltop(); var contbottom = conttop + contheight ; var elemtop = $(elem).offset().top - container.offset().top; var elembottom = elemtop + $(elem).height(); var istotal = (elemtop >= 0 && elembottom <=contheight); var ispart = ((elemtop < 0 && elembottom > 0 ) || (elemtop > 0 && elemtop <= container.height())) && partial ; return istotal || ispart ; } and here's fiddle of complete set i'm trying make : http://jsfiddle.net/j3toxicat3d/zrncu/

syntax - a small issue with mysql -

i'm started learn php & mysql, wanna know what's wrong function show(){ $query=mysql_query(" select * family "); if (!$query) { die("invalid query ".mysql_error()); } while ($row=mysql_fetch_array($query)) { echo "<tr> line 24 ===><td><?php echo $row['id']; ?></td> <td><?php echo $row['name']; ?></td> <td><?php echo $row['lname']; ?></td> </tr>"; } } as can see have function show data fields, , have table in page want including & calling function,my variables appear in table,but keep getting stupid error: plz parse error: syntax error, unexpected '' (t_encapsed_and_whitespace), expecting identifier (t_string) or variable (t_variable) or number (t_num_string) in c:\xampp\htdocs\php\lib.php on line 24 for wanna suggest below code: echo "<tr> <td>".

java - When does object go out of scope if no variable is assigned? -

when object of type list, occupying memory, become eligible garbage collection, variable holds reference list ? in case of code below, there no variable assigned it. case 1: for (integer : returnlist()) { system.out.println(i); } in case of code like: case 2: list list = returnlist(); (integer : list) { system.out.println(i); } list = null; we can take control of gc, there ways take care of in first case when no variable assigned ? to summarize: what mechanism of referrence, without reference variable list case 1? does list eligible gc'd when stack frame popped ? any way speed eligibility gc'ing ? what mechanism of referrence, without reference variable list case 1? there implicit reference list. can seen understanding enhanced for translated into: for(iterator e = returnlist().iterator(); e.hasnext(); ) { integer = (integer)e.next(); system.out.println(i); } here, e has reference iterator on returnlist , itself

python - Set Matplotlib colorbar size to match graph -

Image
i cannot colorbar on imshow graphs 1 same height graph, short of using photoshop after fact. how heights match? you can matplotlib axisdivider . the example linked page works without using subplots: import matplotlib.pyplot plt mpl_toolkits.axes_grid1 import make_axes_locatable import numpy np plt.figure() ax = plt.gca() im = ax.imshow(np.arange(100).reshape((10,10))) # create axes on right side of ax. width of cax 5% # of ax , padding between cax , ax fixed @ 0.05 inch. divider = make_axes_locatable(ax) cax = divider.append_axes("right", size="5%", pad=0.05) plt.colorbar(im, cax=cax)

ios - Sorting array based on date and time with two dictionary keys -

i trying sort array based on date , time , can sort array based on date both time coming value in dictionary. so date comes string in format "yyyy-mm-dd" , time comes in string in format "hh:mm" time value comes in key "starts" string '"hh:mm"' format. i know somehow need combine 2 strings 'yyyy-mm-dd hh:mm' how? -(nsmutablearray *)sortarraybasedondate:(nsmutablearray *)arraytosort { nsdateformatter *formatter = [[nsdateformatter alloc] init]; [formatter setdateformat:@"yyyy-mm-dd"]; nscomparator comparedates = ^(id string1, id string2) { nsdate *date1 = [formatter datefromstring:string1]; nsdate *date2 = [formatter datefromstring:string2]; return [date1 compare:date2]; }; nssortdescriptor * sortdesc1 = [[nssortdescriptor alloc] initwithkey:@"start_date" ascending:yes comparator:comparedates]; [arraytosort sortusingdescriptors:[nsarray arra

java - Problems loading resource files -

im working on little programm, should annoying copy&paste stuff me. i've written code allows me insert right titles, numbers etc. , copy inputs in 4 different files @ right place. have prepared files (.xml , .html) editing easier. im using keyword, , .replaceall("", ""); my plan keep prepared files resource, drag .jar anywhere on computer let programm generate new files resources , edit files in same directory .jar. okay whenever launch application via eclipse, fine. programm creates new files based on inputs using templates, , edits existing files chose edited. when export .jar programm stops @ point, without error or that. jarpath = getclass().getprotectiondomain().getcodesource() .getlocation().getpath().substring(1); //substring removes / jarpathparent = jarpath.replace("alpha.jar", ""); // replacing "" directory .jar is. public void generate(string s) throws ioexception { string path = "&

Converting simple Python code into a Java method -

i found code snippet gives me want in automated tournament bracket generator: array. there issue. not read nor write python, proficient (enough) in java. don't know if bad stack overflow etiquette, asking assist in conversion of code java method. def cbseed( n ): #returns list of n in standard tournament seed order #note n need not power of 2 - 'byes' returned 0 ol = [1] in range( int(ceil( log(n) / log(2) ) )): l = 2*len(ol) + 1 ol = [e if e <= n else 0 s in [[el, l-el] el in ol] e in s] return ol which returns nice 2 [1, 2] #seed 1 plays seed 2 3 [1, 0, 2, 3] #seed 1 gets 'by' game , seed 2 plays seed 3 4 [1, 4, 2, 3] #etc. 5 [1, 0, 4, 5, 2, 0, 3, 0] 6 [1, 0, 4, 5, 2, 0, 3, 6] 7 [1, 0, 4, 5, 2, 7, 3, 6] 8 [1, 8, 4, 5, 2, 7, 3, 6] #and on , forth till 31 [1, 0, 16, 17, 8, 25, 9, 24, 4, 29, 13, 20, 5, 28, 12, 21, 2, 31, 15, 18, 7, 26, 10, 23, 3, 30, 14, 19, 6, 27, 11, 22] 32 [1, 32, 16, 17, 8, 25, 9, 24, 4, 29, 13,

excel - Insert text into the background of a cell -

i looking way insert text background of cell, can still enter numbers on top of text - similar watermark except individual cell. ways this, preferably without using macro (but open these solutions well)? select cell want make background. click "insert" , insert rectangular shape in location. right click on shape - select "format shape" goto "fill" , select "picture or texture fill" goto “insert file” option select picture want make water-mark picture appear @ place of rectangular shape now click on picture “right click” , select format picture goto “fill” , increase transparency required “water mark” or light beckground this printed also. taken here

php - Replacing variables in a string -

i working on multilingual website in php , in languages files have strings contain multiple variables later filled in complete sentences. currently placing {var_name} in string , manually replacing each occurence matching value when used. so : {x} created thread on {y} becomes : dany created thread on stack overflow i have thought of sprintf find inconvenient because depends on order of variables can change language another. and have checked how replace variable in string value in php? , use method. but interested in knowing if there built-in (or maybe not) convenient way in php considering have variables named x , y in previous example, more $$ variable variable. so instead of doing str_replace on string maybe call function : $x = 'dany'; $y = 'stack overflow'; $lang['example'] = '{x} created thread on {y}'; echo parse($lang['example']); would print out : dany created thread on stack overflow thanks! edit th

How to use not exists in a sql query with w3schools? -

i have issue not exists sql query @ w3schools i want select customers work shipperid = 1 not shipperid = 3 . tried following: select o1.customerid, o1.shipperid orders o1 o1.shipperid=1 , not exists (select o2.customerid orders o2 o1.orderid=o2.orderid , o2.shipperid=3) order customerid ; the above query gives customers work shipperid = 1 , not exclude customers work shipperid = 3 . not correct query. (i need speifically use not exists ) ps: know in solution: select customerid, shipperid orders shipperid=1 , customerid not in ( select customerid orders shipperid=3 ) order customerid; why not not exists solution work? i'm problem lies in way you're joining correlated subquery, on orderid = orderid. i'm not familiar dataset, seems surprising same order have different shippers, , adds condition not found in 'correct' answer. should work: select o1.customerid ,o1.shipperid orders o1 o1.shipperid = 1 , not exists ( select o

How do I turn a Python string stored in a variable into a byte sequence? -

very simple, know, docs aren't helpful. i'm trying hash simple string. following this guide. example given therein is: import hashlib hash_object = hashlib.md5(b'hello world') print(hash_object.hexdigest()) and have hash representation. suppose want take 1 step further. have 4 strings want concatenate together, result of needs converted byte sequence, in order passed hashlib.md5() function. however, i'm curious how can replicate b'hello world' syntax using variable instead of hard-coded string. docs seem suggest can pass in format built-in format function, use-case like: my_string = '%s%s%s%s' % (first, second, third, fourth) byte_string = format(my_string, 'b') this doesn't quite work, though. how do this? strings in python sequence of characters, convert string sequence of bytes encode using character set. example: my_string = '%s%s%s%s' % (first, second, third, fourth) byte_string = my_string.encode(

Python - How do I install Pmw in ubuntu? -

in pydev eclipse appears unresolved imports: pmw, i've downloaded pmw from: http://pmw.sourceforge.net/ http://sourceforge.net/projects/pmw/files/ ,to specific pmw2 one, comes folder called pwd2, supposed i'm going folder? thanks. untar file: tar xvzf foo.tar.gz cd foo sudo python setup.py install

android - Passing data from dialogfragment to fragment -

i got activity 3 fragments , 1 of these fragments i'm calling mydialogfragment.show()-method. dialog appears, text-input , try pass text-input fragment. far good. i set back-communication via onactivityresult() of 'parent'-fragment in combination set/gettargetfragment()-calls (see code below). , result in parent-fragment, cannot pass data. every attemp create intent , putting extra-data in fails. don't know if blind or such.. shouldn't able create intent inside onclick()-method?! any appreciated! inside dialog-fragment: public dialog oncreatedialog(bundle savedinstancestate) { alertdialog.builder builder = new alertdialog.builder(getparentfragment().getactivity()); layoutinflater inflater = getactivity().getlayoutinflater(); builder.setview(inflater.inflate(r.layout.dialog_choose_title, null)); builder.settitle(mtitle) .setpositivebutton(r.string.dialog_save_title, new dialoginterface.onclicklistener() { @over

android - What happens if I define a class in a build type and a product flavor? -

what happens if define java class product flavor example free , build type example debug. if build myapp-free-debug.apk gradle class packaged apk? your question title different question body. trying mix ? build types or build type/flavor? in case of build type , flavor, think can't build project if class present in flavor and in build type. duplicate class error. when use product flavors, 1 of flavor included in project, definition. class variants must in each product flavors, , not in build types. in case of build types only, that's i'm trying currently, expected build select java class selected build type, , ignore 1 in main folder not, duplicate class error. asked the question on adt-dev groups, wait , see... edit : had response xavier previous question, , design it's not possible override class defined in main directory. says, gave few workarounds handle need. see link above if interested.

r - Weighting maximum abundance by the number of samples -

i have dataset contains data on abundance of organism , sediment mud content % in found. i have subsequently partitioned mud content data 10 bins (i.e. 0 - 10%, 10.1 - 20% etc) , placed abundance data each bin accordingly. the primary aim plot maximum abundance in each mud bin on mud gradient (i.e. 0 - 100 %) these maximums weighted number of samples in each bin. so, question how weight maximum abundance in given mud bin number of samples in each bin? here simple subset of data: mud % bins: | 0 - 9 | 9.1 - 18 | 18.1 - 27 | abundance: 10,10,2,2,2,1,1 15,15,15,2 20,20,20,1,1,1,1,1 you can use ddply plyr package that. in following code,wtdabundance weighted abundance= (max of bin*number of observation of bin)/total observation sample data, mydata<-structure(list(id = 1:19, bin = structure(c(1l, 1l, 1l, 1l, 1l, 1l, 1l, 3l, 3l, 3l, 3l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l), .label = c("0-9", "18.1-27", "

Wordpress 3.6 Custom Post Type & wp_nav_menu > No current-menu-item class -

Image
having troubles wordpress 3.6. create custom nav using this: add_theme_support("nav_menus"); register_nav_menu('main','main nav'); and display wp_nav_menu with wordpress 3.6 can add custom post type items our custom navigation still have problem. the problem is: when click (in front end) on sub menu, example b-club, not add class parent called: location de lieux... does know how fix that? thanks lot ! grateful ! ok guys, works ! i had problem single-post-type.php ! thanks anyway !

Why can't I change position with a CSS animation -

i had idea create animation words of tagline start squashed on top of each other @ right , slide left position. i wrapped each word in tagline in span tag , gave class of "slide". styled slide this: .slide { right: 0; animation: slide 5s; -webkit-animation: slide 5s; } and made animation so: @keyframes slide { 0% {position: absolute;} 100% {position: static;} } @-webkit-keyframes slide { 0% {position: absolute;} 100% {position: static;} } i don't understand why doesn't work. position: absolute should squash right (i have position relative on containing div, , squash right when style way, no animation). returning position: static should make them sit normally. reason, there's no animation taking place. ideas? another version using transitions rather animations - triggered javascript. this version bit brittle though it's relying on trial , error words line initially. buyer beware :) css - sets container offscreen initial positions

c# - How do I Include a .dll in compilation to avoid dynamic linking? -

i using third party dll file referenced within visual studio project using c#. in previous experiences on other projects, able load objects different dlls using dllimport, create objects if source code of dll included in project. however, method not working 3rd part dll. program works flawlessly on computer programming on, however, when run on different computer, cannot find dll. there method include dll compiling , avoid using dynamic linking? the default setting of .net framework load native libraries system paths, not current directory. but might learn system.data.sqlite project (open source), pre-loading native libraries current folder, , based on os bitness, http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki although generating mixed mode assembly (native , managed bits merged) sounds better solution, system.data.sqlite users confused. thus, recommend pre-loading approach.

jquery - KeyBoard Navigations -

i attempting have navigation visible on menu user hits key on keyboard. if no menu item selected, select first instance of class "row", if row-focus exists remove current focus , update next instance of row class "row-focus". my html formatted: <div id="group_1386" idgroup="1386" class="group"> <div class="row feed-group-name row-focus" idgroup="1386"> <span class="text">winter coming</span></div> <div class="thetitles ui-sortable"> <div id="feed_26451" class="row t-row"><span class="text">#sgluminis - twitter search</span> </div> <div id="feed_26453" class="row t-row"><span class="text">twitter / mikemagician</span> </div> </div> </div> <div id="group_1387" idgroup="1387" class="group"&g

entity framework - EF Code First One-To-One with Join Table -

i trying configure model existing database, , running problem. previous developer modeled one-to-one relationship using join table. if have following classes , database structure below, how can map using code first? public class title { public property property { get; set; } } public class property { public title titleinsurance { get; set; } } tbtitle -titleid = pk tbpropertytotitle -titleid - fk tbtitle.titleid -propertid - fk tbproperty.propertyid tbproperty -propertyid = pk code in vb.net here, should easy translate. mark primary keys key data attribute. entity framework automatically properties named class + id, i.e. tbtitleid assign primary keys, since isn't applicable here, need key attribute. overridable properties denote navigation properties. in c#, should equivalent virtual properties. when navigation property accessed, entity framework automatically valid foreign key relations, , populate appropriate data. for one-to-one relationship, ent

How to decrypt/decode this php code? (possible malicious code) -

hello there fellow stackoverflow members, first of hope having amazing day. going through files on web server, , noticed recent modification date few files, dont remember doing on dates. upon inspecting files, noticed of files had similar code. sadly seems obfuscated i'm assuming malicious, since did not place here. well here's code, if provide insight, great! http://pastebin.com/qd0bmbxm reason im posting on pastebin because, putting code code tag, make huge endless line since unformated. thanks advice. all info reading in there, need unwrap bit bit, like: pack('h*','6261736536'.'345f6465636f6465') => base64_decode() base64_decode(substr($junk, 3442, 16)) => preg_replace() base64_decode(substr($junk, 773, 2664)) => eval(gzuncompress(base64_decode("ejyvv3tv2kgq/yobfew25pr84nmct6cuxjbygbnsquqrrwfjrbo7mubskmp3v5l9ejdgulvmj8lm7lznn0oyjsbziq6tjk6mxoqwtngk2almi4zpvph1lluwsz4rnrovab42zqpicslhihfno9eotv0skph97a1j3oi

python - Program gives error "List indices must not be string" -

the code generates error 'list indices must str" line for res in r['d']['results']: import requests url = "https://mykey:mykey@api.datamarket.azure.com/bing/search/web?$format=json&query=%(query)s" api_key = 'my_key' def request(query, **params): query = ('%27'+query+ '%27') r = requests.get(url % {'query': query}, auth=('', api_key)) print [res['url'] res in r.json()['d']['results']] urlss = [res['url'] res in r.json()['d']['results']] return urlss r = request("jason bourne") res in r['d']['results']: print res['url'] how can avoid error? the error: traceback (most recent call last): file "c:\python27\project\yql.py", line 15, in <module> res in r['d']['results']: typeerror: list indices must integers, not str print r outside func returns this: [u&#

java - Eclipse Window Builder Monty hall gui -

my program set test monty hall problem 10000 times , set text boxes number of rounds (10000) , number of wins, doesnt take second text box , set text when method called, can tell me why? package com.main.www; import java.awt.eventqueue; import java.util.random; import javax.swing.jframe; import javax.swing.jlabel; import javax.swing.jtextfield; public class montyhallredo { public static final random gen = new random(); public static final int rounds = 10000; /** chooses random door other door1 or door2 */ private static int chooseanotherdoor(int door1, int door2) { int result; result = gen.nextint(3); while (result == door1 || result == door2); return result; } private jframe frame; private jtextfield textfield; /** * launch application. */ public static void main(string[] args) { eventqueue.invokelater(new runnable() { public void run() { try { montyhallredo window = new montyhallredo(); wind

Java - Duplicate methods in classes and how to call them from another class -

i learning , loving java , android have long way go. best practice question, think. in android activity have 6 classes. several of them calling methods have duplicated class. seems redundant duplicate methods when call them class. think easier maintain them in 1 class. (main activity, maybe?) question is: best practice calling same method more 1 class? example, classes are: main activity gameselector game1home game1 i have few methods same in every class. lets call them getprefs() , setprefs(). not passing them or out of them. class should go in, , how call them class? edit - helpful answers have functioning configurations class , other 6 classes cleaner! easy maintain , learn few great pointers while making it. i'm posting finished class here in case may else. can call methods other classes this: configurations.getprefs(this); and refer static variables you've defined global in configurations file this: configurations.buttonclicked.start(); configurations.ja

Is it true that Google Static Maps V2 will be depreciated? -

i read blog post: http://googlegeodevelopers.blogspot.com/2013/03/an-update-on-geocoding-api-v2.html i having these issues: https://productforums.google.com/forum/?hl=en#!msg/maps/yog64gkcqqa/i8valicd1fsj and have determined center= address,city not work - , lat,long working - hence geocoder (being depreciated) some of users , servers experienced blue box instead of map (failing in geo-coding address reason) - while other users seeing map... (different states, ips, isp, etc) for sanity , business - know either google or knows - if google static maps going supported. display small map in email (hence cant use js v3) - cripple me if unable display static map... cheers ;)

filter none on django field -

i have model person has nothing in birth_date field. here example: (pdb) dude = person.objects.get(pk=20) (pdb) dude <person: bob mandene> (pdb) dude.birth_date (pdb) dude.birth_date == none true how filter these records have birth_date == none ? i have tried following no success: 1: "birth_date__isnull" not work. person.objects.filter(birth_date__isnull = true) # not return required # object. returns record have birth_date set # null when table observed in mysql. the following not return the record id 20. person.objects.filter(birth_date = "") how filter on field being none? seems null , none different. when see data using sequel pro (mysql graphical client) see "0000-00-00 00:00:00", , following did not work either (pdb) ab=patient.objects.filter(birth_date = "0000-00-00 00:00:00") validationerror: [u"'0000-00-00 00:00:00' value has correct format (yyyy-mm-dd hh:mm[:ss[.uuuuuu]][tz]) in