Posts

Showing posts from May, 2011

google maps - Why does this KML line not get plotted in the right place? -

this question has answer here: after importing kml google maps, point showing in antartica 1 answer i have following list of co ordinates represent points on race track in argentina: -34.6945568333,-58.4617525000 -34.6937816667,-58.4611296667 -34.6927506667,-58.4602933333 -34.6919313333,-58.4596181667 -34.6917445000,-58.4594528333 -34.6916251667,-58.4593376667 -34.6914956667,-58.4591936667 -34.6914396667,-58.4591050000 -34.6914105000,-58.4590106667 -34.6913923333,-58.4588921667 -34.6914015000,-58.4587473333 -34.6914261667,-58.4586343333 -34.6914796667,-58.4585265000 -34.6915693333,-58.4584185000 -34.6916373333,-58.4583646667 -34.6916901667,-58.4583301667 -34.6917491667,-58.4583063333 -34.6918041667,-58.4582841667 -34.6918608333,-58.4582746667 -34.6919396667,-58.4582666667 -34.6928048333,-58.4582771667 -34.6928768333,-58.4582876667 -34.6929505000,-58.4583120000 -34.

xslt - Need help transforming xml via xlst -

hi need sum element values in xml via xlst 1.0 , give output. this xml i'm working on <store> <counter> <item> <id>1</id> <name>desk</name> <price>96</price> </item> <item> <id>1</id> <name>chair</name> <price>323</price> </item> <item> <id>1</id> <name>lamp</name> <price>52</price> </item> <item> <id>2</id> <name>desk</name> <price>200</price> </item> <item> <id>2</id> <name>chair</name> <price>62</price> </item> <item> <id>3</id> <name>desk</name> <price>540</price> </item> <item&g

c# - Cursor position inside a RichTextBox in WPF -

i developing small wpf application, has multiple tabs in it. have status bar in bottom; requirement show linenumber , column of cursor. when user changes cursor position, linenumber , column has updated automatically. here code add richtextbox; code calculates linenumber , column in keydown event handler, event never gets called. event should handle cursor linenumber , column? private void addtabitem(string filepath, mode filemode) { if (filemode == mode.openfile) { if (file.exists(filepath)) { richtextbox mcrtb = new richtextbox(); mcrtb.keydown += new keyeventhandler(linenumber); //rest of code goes here } } } mcrtb.keydown += new keyeventhandler(linenumber); private void linenumber(object sender, keyeventargs e) { textpointer tp1 = rtblist[editortabcontrol.selectedindex].selection.start.getlinestartposition(0); textpointer tp2 = rtblist[editortabcontrol.selectedindex].selection.start; int colum

javascript - Why does SoundCloud API cause the loop to list data in different orders -

i made json file store soundcloud urls. $.each() load data of json file , based on data gather more data soundcloud api. somehow since soundcloud causes loop load data in random orders, not way in json file. here code data , soundcloud bit: $.getjson("http://www.json-generator.com/api/json/get/bljohiysay?indent=2", function(data){ //link of playlist $.each(data.playlistarray, function(key, val){ //navigate array called playlistarray var songlink = val.url; // value of url in array sc.get('/resolve', { url: songlink }, function(track) { //convert soundcloud urls ids data. $("#demo").append("<p id= "+ track.id + ">" + track.title + "</p>"); }); }); }); the order correct when load data without having soundcloud code in loop. soundcloud each time refresh pages, order different. have @ demo please: http://jsfiddle.net/fq2rw/ on jsfiddle please run code copple of times , see orde

python - How to set up django-siteree with django-postman -

i'm trying set django-sitetree work django-postman , i'm not having luck. most of pages work correctly, can't seem figure out how map postman_view url work properly. here's have far. maybe can me out bit? sitetrees.py from sitetree.utils import tree, item sitetrees = ( tree('postman', items=[ item('messages', '/messages/', url_as_pattern=false, access_guest=false, access_loggedin=true, children=[ item('compose', 'postman_write', access_guest=false, access_loggedin=true), item('inbox', 'postman_inbox', access_guest=false, access_loggedin=true), item('view', 'postman_view message.id', access_guest=false, access_loggedin=true, in_menu=false, in_sitetree=false) ]) ]) ) postman urls.py excerpt urlpatterns = patterns('', url(r'^inbox/(?:(?p<option>'+op

ios - Hide UiAlert for PayPal MPL -

Image
i'm using paypal mpl ios lib. when ever press cancel button alert message displayed. how prevent uialert coming up? it appears if paypal library putting alertview up. unless there in paypal library disable feature can't directly disable it. there might couple of workarounds, here thoughts: listen notifications when new uiwindow displayed via nsnotification center. notifications listed @ bottom of document. https://developer.apple.com/library/ios/documentation/uikit/reference/uiwindow_class/uiwindowclassreference/uiwindowclassreference.html heres post deals listening notification. is there notification on ios if uialertview shown? my thought maybe can catch when alertview being shown can undo calling makekeyandvisible on appdelegates window object [[uiapplication sharedapplication].delegate.window makekeyandvisible]; the other thought me seems total hack i'm not going advocate or justify use method swizzling. if swizzled [show] function of uia

multithreading - Android: runOnUiThread() Runnable Sequencing -

i have 2 jni native methods callback java methods in ui. 1) display progress.. 2) dismiss progress both of above calls in sequence. both call java methods create new runnables follows: m_activity.runonuithread( new runnable() { @override public void run() { displayprogressupdate( m_progresspercent ); } } ); -- m_activity.runonuithread( new runnable() { @override public void run() { m_progress.dismiss(); } } ); what seeing dismiss runnable happening before progress update runnable completes. have thought because called in sequence , because both being requested on same (ui) thread occur in sequence well. not case? is why should using such handler synchronise/sequence these calls? edit: ok, implemented handler , still observed same behaviour. debug confused me. looked though dismiss java code happening before progress update had completed, in fact java debug printing jni called java method did posting handler - not actual runnable thread itself

How does circular import work exactly in Python -

Image
i have following code (run cpython 3.4): basically red arrows explain how expected import work: h defined before importing test2. when test2 imports test1 it's not empty module anymore (with h) , h thing test2 wants. i think contradicts http://effbot.org/zone/import-confusion.htm any hints? what you're missing fact from x import y , not solely imports y . imports module x first . it's mentioned in page: from x import a, b, c imports module x, , creates references in current namespace given objects. or in other words, can use , b , c in program. so, statement: from test import h does not stop importing when reaches definition of h . let's change file: test.py h = 3 if __name__ != '__main__': #check if it's imported print('i'm still called!') ... when run test.py , you'll i'm still called! before error. the condition checks whether script imported or not. in edited code, if add condition, you

scala - case class modification and design generic way -

code snippets trivialized, sampled, purpose of post. case class person(firstname:string,lstname:string) this person class has been used on place in codebase. later requirements changed , deciding add phonenumber in person case class e.g. case class person(firstname:string,lstname:string,phonenumber:string) again, examples extremely simplified in post. in reality there more interesting things happening. note phonenumber not option required field. 1 go , update code that's using person class, cater new field lastname . quite tedious when have 100 references of it. can shapeless in creating more flexible hlist go vs case class? the easiest way go provide default value phonenumber : case class person(firstname: string, lastname: string, phonenumber: string = "") alternatively, create companion object , implement apply() method both cases, i.e. , without phonenumber . if decide take approach, , you're using case class in pattern matches,

java - weka ROC chart cannot be differentiated -

Image
i using knowledge flow compare between roc curves of different algorithm in weka gui knowledge flow. i have installed jfreechart not seem have effect. the sample of roc image here. firstly, not understand why on right hand side there duplicates symbols example j48 appearing twice. roc curve obtained selecting image model performance chart. is there possible way me extract roc curves plotted on graph or other clearer apis me use effectively. secondly, knowledge flow diagram. i using training , test set.

networking - uIP DNS clinet fails if external DNS server is used -

i've using uip stack send http posts remote webserver sensor data. i'm using resolv.c (included part of uip) dns client resolve remote webserver domain name ip address. works long use router (192.168.1.1) dns server address. if try use external dns server address (such google's public dns server 8.8.8.8), fails resolve. router firewall ruled out i've tried using same external dns servers on computers network settings manually configured , works fine. i'm struck @ problems since long time , grateful if can me solve problem! my platform uses rdb1768 (based on lpc1768) + lpcxpresso. please let me know if need further information.

api - Would this be a possible work around for the issue of the HTML 5 SoundCloud Widget not autoplaying for iOS? -

i'm aware apple has restricted autoplay audio , video ios, , requires player manually clicked. annoying because i'm trying develop javascript based radio type web app needs automatically jump after playing 1 track next. i doing in web app loading next track in sc widget set autoplay. of course, works fine on desktop, disabled on ios. i've noticed however, playlists within sc widget have ability automatically jump 1 track next on ios, maybe can use instead of own manual system. so, idea send 50-100 songs @ time sort of temporary generic sc playlist , have user click play first 1 started. before nitty gritty on how this, whether or not can generate 'generic' playlist without having setup , account, etc. want verify there isn't solution available let songs flow 1 other once process manually started. thanks -mike

auto increments get old values after deleting records in mysql -

in mysql table tabrespond have field rn primary field , set auto_increment . my 1 php process 1 continue add records in table. , php process 2 read , delete records same table. my php process 2 wants rn values in table must unique. (as set auto_increment should unique). process 1 add daily 40 50 records in table , same read , deleted process 2. it worked fine days. 1 day shocked see next rn value come 345 (where last record read value of rn 765) means instead of next rn value 766, comes 345,346,347. values of rn taken process 2, required rn must unique. how can solve problem rn auto-increment should not auto reset previous values.

PHP: How to get keyless URL parameters -

i parameter in key such http://link.com/?parameter i read somewhere key null , value parameter . i tried $_get[null] didn't seem work. here code: if ($_get[null] == "parameter") { echo 'invoked parameter.'; } else { echo '..'; } it prints out .. means i'm not doing right. can please show me right way. there no such things keyless url parameters in php. ?parameter equivalent of $_get['parameter'] being set empty string. try doing var_dump($_get) url http://link.com/?parameter , see get. it should this: array (size=1) 'parameter' => string '' (length=0) thus, can test in couple of ways depending on application needs: if (isset($_get['parameter'])) { // } else { // else } or // recommended if you're 100% sure 'parameter' in url. // otherwise throw undefined index error. isset() more reliable test. if ($_get['parameter'] === '') {

loaddata - Django 1.6.5 - Unable to load initial data from fixtures -

i tried load initial-data suggested in djangoproject . couldn't able load object on database. when tried load data, says > python manage.py loaddata ./fixtures/initial_data.json installed 0 object(s) 0 fixture(s) but have data on initial_data.json [/test-project/tabletest/tabletest/fixtures/initial_data.json] [ { "model":"tabletest.person", "pk":1, "fields": { "name":"kevin" } }, { "model":"tabletest.person", "pk":2, "fields": { "name":"harry" } }, { "model":"tabletest.person", "pk":3, "fields": { "name":"piter" } } ] #models.py django.db import models class person(models.model): name = models.charfield(max_length=100, verbose_name=

Android: Start animation after fragment is completely loaded -

i have fragment has animation of textview fadein. animation must start after time delay 2 seconds after fragment loaded. wrote code this. animation part done , view rendered. how can load fragment , after time delay start animation my code below: note: class extends fragment animation animfadein; menuclickhelper mclickhelper; textview tv; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { final view rootview = inflater.inflate(r.layout.fragment_main_menu, container, false); mclickhelper = new menuclickhelper(rootview, getfragmentmanager()); tv = (textview) rootview.findviewbyid(r.id.tvpresentation); animfadein = animationutils.loadanimation(getactivity() .getapplicationcontext(), r.anim.fade_in); animfadein.setanimationlistener(new animationlistener() { @override public void onanimationstart(animation animation) { // todo auto-generate

Finding largest 2 values in a range using excel formula -

i have data below classifiaction hours home 157.40 home 157.39 mens apparel 157.39 mens apparel 157.39 sunglasses 157.39 sports 157.33 biss 157.33 mens apparel ia 157.32 mens apparel ia 157.32 kitchen 157.32 beauty 157.32 home 157.32 home 157.31 mens apparel 157.31 mens apparel 157.31 sunglasses 157.31 sports 157.29 biss 157.29 mens apparel ia 57.29 mens apparel ia 157.29 kitchen 157.28 beauty 157.28 from looking solution find largest 2 hours under each category. like below beauty 157.32 '1st largest value in under beauty beauty 157.28 '2nd largest value in under beauty mens apparel 157.39 '1st largest value in under mens apparel mens apparel 157.39 '2nd largest value in under mens apparel using large func

multithreading - How to use rtnl and spinlock for synchronization? -

can 1 explain rtnl( rtnl_lock() rtnl_unlock() ) tried google unable dig much what got net rtnl netlink used communication ipc bet user , kernel space didn't more that i got spinlock() why spinlock better semaphore, not much but helpful if explain rtnl any link details appreciated.

dashboard Error under Sharepoint 2013 -

i create 4 score card report in dashboard designer in sp2013, have sp on server , sql on other server. report can access analysis cube , show data. deploy dashboard, once open in in browser reports gives me unexpected error occurs. have checked event viewer logs , sp logs , use fiddlers nothing give error concern this. hoping can assist me concern thanks , regards

python - Plot a pandas dataframe with vertical lines -

i want plot dataframe each data point not represented point vertical line 0 axis : df['a'].plot(style='xxx') where xxx style need. also ideally able color each bar based on values in column in dataframe. i precise x axis values numbers , not equally spaced. the pandas plotting tools convenient wrappers matplotlib. there no way know of functionality want directly via pandas. you can in few lines of matplotlib. of code colour mapping: import pandas pd import matplotlib.pyplot plt import numpy np import matplotlib.colors colors import matplotlib.cm cmx #make dataframe = np.random.rand(100) b = np.random.ranf(100) df = pd.dataframe({'a': a, 'b': b}) # colour mapping c_norm = colors.normalize(vmin=min(df.b), vmax=max(df.b)) scalar_map = cmx.scalarmappable(norm=c_norm, cmap=plt.get_cmap('jet')) color_vals = [scalar_map.to_rgba(val) val in df.b] # make plot plt.vlines(df.index, np.zeros_like(df.a), df.a, colors=c

How do I package a python script to run on Windows? -

i created pyhthon script on ubuntu share windows users. how package script windows user not have install python , modules use script? you can try py2exe : packages script windows

batch tiff image processing -

i have 100 tiff images need draw each of them 1 transparent image on specific coordinates , save. time consuming manualy using editor. there commandline software windows, can combine 2 images using xor or , operation. try fiji/imagej . has image calculator supports , and xor operations. record set of commands within user interface first ( plugins > macros > record... ), such as: open("/path/to/first-image.tif"); open("/path/to/second-image.tif"); imagecalculator("and create", "first-image.tif","second-image.tif"); you can perform same action on whole set of images within gui, or command line in headless mode .

mysql - SQL Query to retrieve next available ID from table -

i have table contains column called ticket_id , contains values follows: ticket_id stk0000000001 stk0000000002 stk0000000001 stk0000000003 stk0000000002 stk0000000001 the ticket_id value repeat in rows, not unique. i using query next available id, not able working. returns stk0000000002 . any appreciated! sql: select concat('stk', lpad(seq, 10, '0')) nextid (select @seq:=@seq+1 seq, num (select cast(substr(ticket_id, 4) unsigned) num sma_support_tickets union select max(cast(substr(ticket_id, 4) unsigned))+2 num sma_support_tickets order num) ids cross join (select @seq:=0) init ) pairs seq!=num limit 1 maybe i'm missing in question, seems should it: select concat('stk', lpad(max(substring(ticket_id, 4)) + 1, 10, '0&#

extjs - Ext js Grid Pagination -

i new ext js , have tried example ext js docs, unable pagination. i have designed application using mvc architecture. here code: title : 'trade data', store : 'ramdatastore', id:'tradedatagrid', dockeditems:[{ xtype:'pagingtoolbar', store:'tradedatastore', displayinfo:true, id:'tradepage', itemid:'tradepage', displaymsg:'{0}-{1} of {2}', emptymsg:'no topics show', dock:'bottom'} ], columns : [ { xtype : 'gridcolumn', width : 85,align : 'center', dataindex : 'tradeid', text : 'tradeid' }, { xtype : 'gridcolumn', width : 120, dataindex : 'instrumenttype', text : 'instrumenttype' }, { xtype : 'gridcolumn', width : 103, align : 'center',

python - Putting utf-8 dict in Django template -

i've got little faq.conf file containing dict structure i'm importing ast django. question , answer contain utf-8 chars , html markup. { '1': {'question':'','answer':''}, '2': {}, '3': {}, } so use ast import it: with open(os.path.join(fs_root, faq_file)) q: faq = ast.literal_eval(q.read()) after putting view context , using filter {{ faq|safe }} receive: {'1': {'answer': 'zewn\xc4\x99trznych mog\xc4\x85 si\xc4\x99 do\xc4\x87 osoby. w szczeg\xc3\xb3lno\xc5\x9bci takie, kt\xc3\xb3rych. ...} what should proper output in templates? assuming using python 2, problem reading file byte string , not unicode string. believe ast handles utf-8 fine, can do: with open(os.path.join(fs_root, faq_file)) q: faq = ast.literal_eval(q.read().decode('utf-8')) or use codecs.open open file correct encoding. if ast doesn't unicode characters, can call decode() on strings before

java - Get notification history for android application -

i trying not sure possible or not . have created android application "abc" . have used gcm issue notifications 3rd party service. now client asks wants history of notifications issued 3rd party server . sceptical . i believe might able show list of notifications issued server responded upon user . think notifications on user has not responded cannot recorded application . is true ? i have broadcast receiver in code responds gcm messages. <receiver android:name="com.mob.uae.notifications.gcmbroadcastreceiver" android:permission="com.google.android.c2dm.permission.send" > <intent-filter> <action android:name="com.google.android.c2dm.intent.receive" /> <category android:name="com.evento.uae" /> </intent-filter> </receiver> shouldn't called regardless of user's action upon notification ? . if c

node.js - Mongoose null checking before saving on nested schema array -

i have schema model this: var propertyschema = new schema({ name: {type: string, required: true}, surname: string }); var objschema = new schema({ properties: [prepertyschema] }); var accountschema = new schema({ objects: [objschema] }); mongoose.model('account', accountschema); then have operations: account.objects.push(null); account.save(function(error, account) { //error checking , response }) in case, i'm getting validationerror because of null value. expected. but, in next operations: var obj = {properties: null} account.objects.push(obj); account.save(function(error, account) { //error checking , response }) here value stored on database, , have unexpected null value had been array. doing objects this, var obj = { properties: [{name:'randname'}, null] } also saves null values in database prohibited data model. i've read validators, , middleware checking things. there anyway directly on schema, or have parse receiv

c# - Is return variable automatically created by compiler? -

when going on project source code, stumbled upon method , wondered 1 thing. following 2 methods same performance/memory/compiler point of view? public static string foo(string inputvar) { string bar = dosomething(inputvar); return bar; } public static string foo(string inputvar) { return dosomething(inputvar); } is return variable automatically created compiler? using il disassembler (included in .net sdk/vs) can @ il generated compiler. code generated using vs2013 (not roslyn). the top 1 gives following il: .method public hidebysig static string foo(string inputvar) cil managed { // code size 14 (0xe) .maxstack 1 .locals init ([0] string bar, [1] string cs$1$0000) il_0000: nop il_0001: ldarg.0 il_0002: call string testil.program::dosomething(string) il_0007: stloc.0 il_0008: ldloc.0 il_0009: stloc.1 il_000a: br.s il_000c il_000c: ldloc.1 il_000d: ret } // end of method program::foo the

Pros and Cons of using Choice Router in Mule -

hi working mule. have multiple flows. selection multiple flow based on choice router. want know pros , cons of using choice router . how maximum use of choice router effect performance. how choice router works internally , how upgrade , degrade performance. notes: as general principle, time spent in choice router orders of magnitude less mule spends waiting on i/o systems in interacts with. don't worry performance beforehand, load test , measure. choice routers short circuit @ first route expression true performance affected number of routes have. performance affected type , complexity of expression run. tips: consider nesting choice routers, refining options in nested routers. extract nested routers in private flows, , call them flow-ref , readability. pre-compute decision expressions , store them in flow variables: example don't run same xpath expression in different routes pre-compute , store it, use flow variable in expressions.

Touchscreen calibration on android -

i've android tv box (jellybean) have connected 17'' egalaxy touchscreen. moves pointer in small are. i've created necessary idc file don't know right configuration put in it. you need run touch screen calibration app. regards rasmus

ios - UIScrollView -setContentOffset : animated YES or NO produce different results -

hei, know sounds stupid. i'm programming first uiscrollview , i'm trying set position of elements inside scroll view according parameter. found can use setcontentoffset no matter values feed function result same , have no idea why? (is problem of contentsize of scroll view?) here code: first set scroll view this: //make view scrollable scrollview=[[uiscrollview alloc]initwithframe:cgrectmake(0, 0, [[uiscreen mainscreen] bounds].size.width, [[uiscreen mainscreen] bounds].size.height-216-30)]; scrollview.scrollstotop = no; scrollview.bounces=no; [self.view addsubview: scrollview]; scrollview.contentsize=cgsizemake([[uiscreen mainscreen] bounds].size.width, [[uiscreen mainscreen] bounds].size.height-110); and later try set position of scroll view if(ymultiplier==4){ [scrollview setcontentoffset:cgpointmake(0,imageheight) animated:no]; nslog(@"4"); } else if(ymultiplier==5){ [scrollview setcont

Manifest merger failed : uses-sdk:minSdkVersion 10 cannot be smaller than version L declared in library com.android.support:appcompat-v7:21.0.0-rc1 -

got above error after downloading l preview release version in android studio , when project had minsdkversion 19. furthermore, when setting mindsdkversion below: defaultconfig { .... minsdkversion 'l' .... } i dozens of errors below, regarding resources appcompat-v7-21 : /home/user/workspace/project/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0-rc1/res/values-v21/values.xml error:error retrieving parent item: no resource found matches given name '@android:textappearance.material.searchresult.subtitle'. so have 2 questions: why complain minsdkversion ? presume because appcompat-v7 21 supports l release; why ? also, support l release when going officially released in autumn ? because problem... or temporary restriction in order apps not be pushed play store, specified in google i/o 2014 keynote ? why appcompat-v7 21 complain errors, set mindsdkversion l ? compilesdkversion 'android-l' boom.

rest - How do I send a JSON string in a POST request in Go -

i tried working apiary , made universal template send json mock server , have code: package main import ( "encoding/json" "fmt" "github.com/jmcvetta/napping" "log" "net/http" ) func main() { url := "http://restapi3.apiary.io/notes" fmt.println("url:>", url) s := napping.session{} h := &http.header{} h.set("x-custom-header", "myvalue") s.header = h var jsonstr = []byte(` { "title": "buy cheese , bread breakfast." }`) var data map[string]json.rawmessage err := json.unmarshal(jsonstr, &data) if err != nil { fmt.println(err) } resp, err := s.post(url, &data, nil, nil) if err != nil { log.fatal(err) } fmt.println("response status:", resp.status()) fmt.println("response headers:", resp.httpresponse().header) fmt.println("respo

java - Dynamic User Input Forms -

i want collect information user. let's say, want collect information age , gender each of family members. how this, in form, given not know family size, when prompted, can input number of family members. screen shows, form list family member 1: age: gender: family member 2: age gender , on. 1 big list, scroll down app input information. , submit button @ end submit form me. don't know how handle unknown number of edittext forms etc , how extract info each. if show me how code snippets. there many different way mention 1 of them: -start have layout of edittext , button. size of family question -layout viewpager -layout fragement, how u want form example 2 edittext (age , gender) , 1 button -create fragment.java class , inflate fragment layout inside it now on main activity set first layout size of family layout. for example enters 4. now open new activity viewpager layout content. int size = 4; arraylist<fragments> lf = new arraylist<

css - Finding the right path of an image -

i've web site on www.open-guide.com , i'm trying put background-image each list item of general information form (why choose us?), can't seem find right path (either relative or absolute) images, i've in folder (tour_icons) in desktop. i tried: li { background-image: url(../tour_icons/imagename.jpg); } but not finding it. doing wrong? you need copy "tour_icons" folder hosted application path root, otherwise wont find correct file path. use / prefix start path consider root of application , define path asa string format. background-image: url('/tour_icons/imagename.jpg');

How to use for loop in JavaScript, especially in my program? -

i want run following program in continuous loop till length of array. want program run first input after first comparison program should not end rather should run till loop condition satisfied. program follows: var userchoice = prompt("what select: rock, paper or scissors?"); var computerchoice = math.random(); if(computerchoice<0.34) { computerchoice = "rock"; } else if(computerchoice<=0.67) { computerchoice = "paper"; } else if(computerchoice<=1) { computerchoice = "scissors"; } console.log("computer: "+computerchoice); var compare = function(choice1, choice2) { if(choice1 === choice2) { return "it tie!"; } else if(choice1 === rock) { if(choice2 === paper) { return "paper wins"; } else { return "rock wins"; } } else if(choice1 === paper) { if(choi

python - How to get css to work in Django -

for reason css file isn't doing anything, can me figure out why? think being sources properly, because when in source code generated when runserver , click on link css file text css file shows up. nothing css file being used settings.py: import os import sys base_dir = os.path.dirname(os.path.dirname(__file__)) dirname = os.path.dirname(__file__) sys.path.insert(0, os.path.join(base_dir, 'apps')) template_dirs = ( os.path.join(dirname, "templates") ) secr

Cordova IOS 7.1 Calendar is read only. -

we using cordova built cross platform app. calendars getting saved in ios 7.0 , prior. in newest version gives error. calendar not found while creating calendar, if create calendar manually using iphone calendar application, calendar read error. we using calendar plugin of eddyverbruggen. var startdate = new date(2014,10,1,18,30,0,0,0); var enddate = new date(2014,10,30,19,30,0,0,0); var title = tempitem.name; var location = "home"; var notes = tempitem.description; var success = function(message) { alert("success: " + json.stringify(message)); }; var error = function(message) { alert("error: " + message); }; var createcaloptions = window.plugins.calendar.getcreatecalendaroptions(); createcaloptions.calendarname = "calendar"; createcaloptions.calendarcolor = "#ff0000"; // optional hex color (with # char), default null, os picks color window.plugins.calendar.createcalendar(createcaloptions,success,error); window.plugins.calenda

PHP class refer to second class which refer to first and so on -

sorry question title, don't know how name issue, here is: i have 2 classes, order , item. order has many itens (array of itens). item refer order (order object). the problem is: order has itens, each item refer order, wich has itens, wich refer order, wich refer itens, , on... the array hierarchy gets infinite. also don't know how construct order object. have create itens , set them order's item array, how can set item's order if order isn't yet constructed? btw, data comes database. table item has order_id. nothing fance do, just: class order { public $id; public $item; public function setitem(item $item) { $this->item = $item; } } class item { public $id; public $order; public function setorder(order $order) { $this->order = $order; } } $order = new order(); $item = new item(); $order->setitem($item); $item->setorder($order); php saves references objects, there no e

c++ - Remove duplicates in string algorithm -

my homework remove duplicates in random string. idea use 2 loops solve problem. 1st 1 scan every character in string. 2nd 1 check character duplicated or not. if so, remove character. string content = "blah blah..." (int = 0; < content.size(); ++i) { char check = content.at(i); (int j = + 1; j < content.size() - 1; ++j) { if (check == content.at(j)) { content.erase(content.begin()+j); } } } the problem doesn't work. removes wrong character. seems indices problem don't understand why. a temporary fix change content.erase(content.begin()+j); content.erase( remove(content.begin() + i+1, content.end(), check),content.end()); but think trigger "remove value" scan isn't nice way. want 2 loops or fewer. any ideas appreciated :) your loops following way #include <iostream> #include <string> in

Batch Request to Google API making calls before the batch executes in Python? -

i working on sending large batch request google api through admin sdk add members groups based upon groups in our in-house servers(a realignment script). using python , access google api using [apiclient library][1]. when create service , batch object, creation of service object requests url. batch_count = 0 batch = batchhttprequest() service = build('admin', 'directory_v1') logs info:apiclient.discovery:url being requested: https://www.googleapis.com/discovery/v1/apis/admin/directory_v1/rest which makes sense json object returned http call used build service object. now want add multiple requests batch object, this; for email in add_user_list: if batch_count != 999: add_body = dict() add_body[u'email'] = email.lower() n in range(0, 5): try: batch.add(service.members().insert(groupkey=groupkey, body=add_body), callback=batch_callback) batch_count += 1 break

css - Hard to position on sub-elements in a drop down menu -

basically, have simple css drop down menu background images links. when hover on element has sub-element , try position on sub-element, it's hard , doesn't work. here's snippet: css nav { width: 710px; } nav ul ul { display: none; } nav ul li:hover > ul { display: block; } nav ul { padding-top: 20px; list-style: none; position: relative; display: inline-table; } nav ul li { float: left; width: 95px; height: 32px; } nav ul li { display: block; text-indent: -9999em; } .element, .element:hover { width: 95px; height: 32px; } .home { background-image: url(img/home.png); } .home:hover { background-image: url(img/home1.png); } nav ul ul { padding: 0; position: absolute; top: 100%; } nav ul ul li { padding: 0; padding-right: 90px; position: relative; } nav ul ul li { font-family: arial, helvetica, sans-serif; color: #fff;

java - Get stream from IP Webcam -

i trying stream ip webcam app on android in browser mode time unsuccessful. tried webview loading html page hosted on laptop not working in app works in chrome android ...here code : camera.html <img id="browser_video" class="video-image" alt="video" src="http://192.168.1.101:8080/video"> mainactivity import android.app.activity; import android.os.bundle; import android.os.handler; import android.webkit.webview; public class mainactivity extends activity{ webview wv; string url = "http://192.168.1.187:8080/camera.html"; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); wv = (webview) findviewbyid(r.id.wvimage); wv.loadurl(url); } } and activity_main : <?xml ve