Posts

Showing posts from June, 2014

javascript - Stereoscopic(side by side) mobile web app -

have little experience mobile web apps, want create stereoscopic image(identical side side images) of site (192.168.2.87:8080/jsfs.html). know if possible mobile web app? in context, it's video feed using javascript ip webcam android, , video rendered in browser putting still shots.

php - File uploads in Symfony 2 using sonata-project -

i trying upload image in symfony 2 backend using sonata-project. challenge i'm facing right image inserted database table , uploaded specified path. have given upload folder writeable permissions. not sure missing here steps have taken. class homeenumerate { // ... protected function getuploaddir() { return 'uploads/houses'; } protected function getuploadrootdir() { return __dir__.'/../../../../web/'.$this->getuploaddir(); } public function getwebpath() { return null === $this->house_picture ? null : $this->getuploaddir().'/'.$this->house_picture; } public function getabsolutepath() { return null === $this->house_picture ? null : $this->getuploadrootdir().'/'.$this->house_picture; } } i have edited homeenumerate.orm.yml have put in lifecyclecallbacks: lifecyclecallbacks: prepersist: [ preupload, setcreatedatvalue, setexpiresatvalue ] preupdate: [ preupload, setupdatedatvalue ] postper...

bash - store all files name in a variable from directory/subdirectoy unix -

i want store files of *.mk type in variable sub directories , use in program. tried below command it's not working. shell script: for in `find . -name *.mk` echo $i done it's showing below error message. bash: ./make_files.sh: line 6: syntax error near unexpected token echo' bash: ./make_files.sh: line 6: echo $i' it's not printing anything. try either in `find . -name '*.mk'`; echo $i done or for in `find . -name '*.mk'` echo $i done note use of quoting, too.

ruby on rails - Neo4J Gem - Saving undeclared relationships -

i trying create realtionship between 2 nodes described here https://github.com/neo4jrb/neo4j/wiki/neo4j-v3-declared-relationships from_node.create_rel("friends", to_node) i getting undefined method create_rel what doing wrong? trying create q+a system inside model. both questions , answers treated models right now. i'm getting undefined method create_rel' # event.rb has_many :out, :event_questions event_question.rb has_one :in, :events has_many :out, :event_answers def create_questions_of(from_node,to_node) from_node.create_rel("questions_of", to_node) end event_answer.rb has_one :in, :event_questions event_questions_controller.rb def new #is needed end def create @event_question = eventquestion.new(event_question_params) if @event_question.save @event = event.find(params[:id]) @event_question.update(admin: current_user.facebook_id) @event_question.create_questions_of(self,@even...

python - Creating folders based on a list read from a text file -

i have code follows: from sys import argv import os; home_dir = '/home/joga' script, dirlist = argv mylist = open(dirlist, 'r') folder in mylist: newfolder = home_dir+'/'+folder print "folder name " +newfolder if not os.path.exists(newfolder): os.makedirs(str(newfolder)) os.chdir(newfolder) mylist.close() the idea read list of folders listed in text file, , create each of these folders if don't exist. getting folders created, have strange names, example stray '?' appended folder name how fix this? answering own question i added folder = folder.strip() first line in loop. guess line-ending creating junk character.

selenium - Find out correct xpath -

i have html page this: ... <div class="container"> <div class="title">meat</div> <div class="someclass"> <div class="tile aaa"> <div class="text">aaa</div> <img class="image" src="somewhat.jpg" /> </div> </div> <div class="someclass"> <div class="tile bbb"> <div class="text">bbb</div> <img class="image" src="somewhat.jpg" /> </div> </div> </div> <div class="container"> <div class="title">fish</div> <div class="someclass"> <div class="tile aaa"> <div class="text">aaa</div> <img class="image" src="somewhat.jpg...

lotus notes - parentView property in NotesDocument class -

i have function calls function - bones shown below. when second function runs , reaches 'set doc = view.getnextdocument(doc)' line, parentview property on unrelated notesdocument, doc1, updated, breaking original loop. any thoughts? function getdept(){ dim doc1 notesdocument dim view1 notesview . . . set doc1 = view1.getfirstdocument while not(doc1 nothing) . . . call getdeptnumber() . . . set doc1 = view1.getnextdocument(doc1) } function getdeptnumber(){ dim doc notesdocument dim view notesview . . . set doc = view.getfirstdocument while not(doc nothing) . . . set doc = view.getnextdocument(doc) } it's driving me nuts! thanks graeme it's little unclear without seeing more code, suspect problem may have caching. if access same notesdocument different views, second , subsequent accesses may end using same document have in memory in part of code. using view entry collection shown in other answer hel...

What is the best way to host node.js app on Windows? -

i have restful api implemented on nodejs have host on windows. app simple restful service, maybe in future implement backoffice manage users, display statistic etc. app api, maybe in future extended serve few pages dynamic content, not going provide access static content (except regular content web apps: favicon, images, css, js files etc). after research see few options host app on windows: use windows service run node server. use iis , iisnode module front server. use nginx on windows front server (i didn't work nginx, seems can used host node , can used on windows). my questions: as understood better use front server. approach has lot of benefits: can manage app state, logs, domain names etc. benefits of using windows service host app? how choose between iis , nginx. wise use nginx on windows, have advantages? thank you. iisnode has number of benefits outlined on project page. https://github.com/tjanczuk/iisnode/wiki i lean direction because if h...

oracle - Creating dynamic sql statement -

i'm making package use grants safegaurd, want make search procedure searches rows contain name/value column bellow: procedure "search"(p_column in varchar2(30), p_value in mytable.{p_column}%type, p_refcur out sys_ref_curser) -- variables declaration begin -- logic validation open p_refcur select * mytable {p_column} = p_value; end "search"; how can define p_value 's type in procedure's signature , create clause column ( p_column ) variable string. simply put command quotes. apart should use bind variables. open p_refcur 'select * mytable '||p_column||' = :val' using p_value; and remove curling brackets {} , not used in oracle pl/sql.

html - Link to css file in documents from UIWebView without using Base Path -

i have loaded html string (after downloading css file documents) this: /* result html file references local resources <link href="file:///users/user/library/developer/coresimulator/devices/123/data/containers/data/application/123/documents/gen1.css" rel="stylesheet" type="text/css"> , external resources <link href="http://api.tiles.mapbox.com/mapbox.js/v1.6.4/mapbox.css" rel="stylesheet" /> */ pagegenerator *generator = [pagegenerator sharedgenerator]; nsstring *result = [generator generatepagewithoptions:options]; // filesdir file:// + [[[nsfilemanager defaultmanager] urlsfordirectory:nsdocumentdirectory indomains:nsuserdomainmask] lastobject] + / [self.webview loadhtmlstring:result baseurl:[nsurl urlwithstring:[generator filesdir]]]; now, problem external resources contain url's "//www.site.com/img.png" , uiwebview rewrites them "file://www.site.com/img.png", , gets 404 error. how can ...

Reversing list with strings in python -

i have list, last_names = [ 'hag ', 'hag ', 'basmestad ', 'grimlavaag ', 'kleivesund ', 'fintenes ', 'svalesand ', 'molteby ', 'hegesen '] and want print reversed, 'hegesen' comes first, ' molteby' , @ end 'hag'. i have tried last_names.reverse() , returnes none.. any help? .reverse returns none because reverses in-place : >>> last_names = [ ... 'hag ', 'hag ', 'basmestad ', 'grimlavaag ', 'kleivesund ', ... 'fintenes ', 'svalesand ', 'molteby ', 'hegesen '] >>> last_names.reverse() >>> last_names ['hegesen ', 'molteby ', 'svalesand ', 'fintenes ', 'kleivesund ', 'grimlavaag ', 'basmestad ', 'hag ', 'hag '] to in expression, last_names[::-1] .

c - Two dimensional array median filtering -

Image
i'm trying write code implements median filtering on two-dimensional array. here's image illustrate: the program starts @ beginning of array. maximum array size 100. know can use array like: int a[100][100]; to store input, , can iterate on part of array using 2 for loops this: for(i=0;i<size_filter;i++) for(j=0;j<size_filter;j++) temp[i][j]=a[i][j] // not sure but how can make code loop on neighbors of every element in array, calculate median, , replace center element median? for examples of i'm trying do, let's input 5x5 matrix, input size 5. , want run 3x3 median filter on it, i.e. each element should replaced median of 3x3 elements surrounding it. the program starts @ corner index (0,0). index, scans 3x3 region surrounding (of 4 indexes lie within input array), contains values 0, 0, 1, , 0. median of these values 0, that's code should output array index. in picture below, number in bold italics center cell, , plain bold...

matlab aggregate bounding box area in an image -

Image
i have image i, , set of bounding box positions in matrix a, a=[x10 y10 x11 y11; x20 y20 x21 y21...xn0 yn0 xn1 yn1]. boxes can visualized on image below. imshow(i); numparts = floor(size(a, 2)/4); = 1:numparts x1 = a(1,1+(i-1)*4); y1 = a(1,2+(i-1)*4); x2 = a(1,3+(i-1)*4); y2 = a(1,4+(i-1)*4); line([x1 x1 x2 x2 x1]',[y1 y2 y2 y1 y1]','color',colorset{i},'linewidth',2); end how can aggregate bounding box areas, pixels in boxes labeled 1, otherwise labeled 0? don't want all-inclusive bounding box includes bounding boxes in a. need more precise area map aggregates bounding boxes in a. if understand correctly, want find outer perimeter of of bounding boxes placed together, set entire interior of shape 1. i'm going assume array structured such each row, first 2 co-ordinates...

Where do I put media query code in rails for twitter bootstrap? -

i new twitter-bootstrap , difficulty form offset on tablet , phone views. know margin-left styling hat correct each view im not sure need code media queries. tried code in bootstarp.css file, did not work . in app/assets/stylesheets/bootstrap_and_overrides.css.scss . that's put overrides. if don't have file, should add it. i assuming using rails 3 or 4, , using these gems ofcourse: gem 'bootstrap-sass', '~> 3.2.0.0' gem 'sass-rails', '>= 3.2'

How to show/hide fragment with swipe up/down like soundcloud android app -

Image
i getting curious know how view can created 1 shown below . drag , drop or custom view gesture detection , animations? can starting point? viewdraghelper can used achieve effect. tutorials , samples are: dragging-with-viewdraghelper , each-navigation-drawer-hides-a-viewdraghelper , draggablepanel , androidslidinguppanel

ios - Merging two NSArray removing duplicates -

i have array of cities , array of countries. these 2 objects have property in common: city name. need create new array adding countries have city name not there in cities array. i tried iterating on both arrays, comparing city name , adding different 1 new array. result that, while checks first city, cities have name added array , other cities in cities array there. self.filteredcountriesarray = [nsmutablearray new]; (country* country in self.countries) { (city *city in self.cities) { if (![country.city isequaltostring:city.name]) { [self.filteredcountriesarray addobject:country]; } } } suggestions? not sure whether understand want, guess you'd this: for (country *country in self.countries) { bool found = no; (city *city in self.cities) { if ([country.city isequaltostring:city.name]) { found = yes; break; } } if (!found) { [self.filteredcountriesarray addobjec...

Drools, how to check if an object with a specific property exists more than once in the list -

i have number of personentitys in working memory. need write rule check if 2 personentitys same someproperty existed in working memory. have written follows, problem is, when there 2 personentitys same someproperty, sys.out executing twice: when $person : personentity(person.persontype == persontype.legalperson); $personlist : arraylist( size > 1 ) collect( personentity(someproperty.id == $legalperson.someproperty.id)) system.out.println("error occured"); i tried this, think since working memory has number of personentities, rule executing 4times (number of personentitys) , "error occurred " sentence appears 4times in console: personentity(some conditions, $relatedid :relatedperson.id); exists personentity(some conditions, relatedperson.id > $relatedid) the standard solution problem add constraint using unique property guarantees ordering. when personentity(persontype == persontype.legalperson, $pid: personid) ...

Android Studio fails to find SDK -

i downloaded android studio , unzipped file. when run it, loads says "please provide path android sdk". have tried loads of different file paths nothing happens. missing file need download or else? update path point android sdk platform-tools directory. didn't provide how can because depends on os using.

java - Make an enhanced for loop wait until something is done -

i creating black jack game. i'm @ point if ace shows up, it'll ask user if ace should low or high. for(card card : hand){ ui.choseace = false; if(card.getpointvalue() == 1){//if ace. ui.loworhigh();//preps ui ask if ace low or high } else{ if(hand.equals(playershand)){ playerpointtotal += card.getpointvalue(); } else{ dealerpointtotal += card.getpointvalue(); } } } in separate class... public void loworhigh(){ hitbutton.setvisible(false); standbutton.setvisible(false); lowbutton.setvisible(true); highbutton.setvisible(true); updateui(buttonpanel); inputjtflabel.settext("is ace low or high?"); } and buttons... if(obj.equals(lowbutton)){ choseace = true; game.playerpointtotal += 1; } if(obj.equals(highbutton)){ choseace = true; game.playerpointtotal += 11; } i trie...

css - Responsive, sortable Bootstrap thumbnails -

i'd format list of thumbnails using bootstrap 3 displayed in rows of 4 on large screens, 2 on smaller screens etc. also, need able drag , drop thumbnails change order. so far tried markup <ul class="thumbnails list-unstyled"> <li class="thumbnail-container"> <div class="thumbnail"> <img src="..."> </div> </li> </ul> styled (less) .thumbnails { .row; .clearfix; .thumbnail-container { .make-md-column(3); &:nth-child(4n+1) { clear: left; } } } i used clear because thumbnails not of equal height. tried implement sorting using jquery ui sortable , this script , both ended same - when sorting, rows of thumbnails break often, leaving gaps in grid. can worked around somehow? know use masonry or isotope, seems huge overkill me. behaviour same in latest firefox , chrome. use power of bootstrap. c...

javascript - Change url without reloading the page -

how can pass type of url: http://domain.com to type: http://domain.com/#0123456789 without reloading page. i not want use html5 window.history.replacestate function, not work older versions of internet explorer. i found answer: location.hash = "0123456789"; sorry answer own question...but no answer gave right point.

javascript - CSS3 transitions seem to need a "warmup" time before they kick off? Do I have to add a wait? -

i have css3 transition shrink height of element. i'm doing by: css3 transition , destination height specified on class (e.g. height:5px in class) assign height=$el.height() element in style attribute (e.g. height:100px on style) add class element remove height defined in style attribute computed css value changes style's 100px class's 5px, triggers transition what i'm discovering there seems delay on setting css3 transition trigger, , if step #4 done after #3, trigger see height auto instead of 100px, , no transition happens (due limitation of css3, can't transition height:auto height:x). here's actual code: $(document).ready(function() { $a = $('#box'); // height:auto, not specified $a.css('height',$a.height()); // height:100px on style; $a.addclass('shrink'); // height:100px on style, height:5px on class $a.css('height',''); // height removed style, falls 5px on class }); here's jsfiddle d...

php - How does Fedex calculate Handling rates in magento? -

i using fedex shipping method in magento website want add more 30% on shipping charges margin. possible using handling charges section in shipping methodd setting of magento. how fedex calculate handling charges. please explain me , give correct suggestion. in advance. step 1. go to: fedex developer resource center , create developer’s account. step 2. when create developer’s account go developer resource center , click on top navigation fedeex web services -> fedeex web services shipping. now, see link develop & test application (about testing, obtain developer test key) click on it. have send request test environment, can see link “obtain developer test key” click on , fill form. after sending form data, receive email message fedex required data testing fedex shipping method.

regex - Cscope insensitive search -

i trying case insentive search in vim cscope. example: :cs find e regexp should find regexp, regexp, regexp , on... how can this? i've been trying (?i) in front of expression, didn't help. :cs find e expects egrep pattern. since egrep not case-insensitive default there's no reason expect pattern regexp match regexp , regexp , etc. also, egrep doesn't honor (?i) . to make cscope's search (all search methods, not egrep ) case-insensitive default, must add -c flag initialization command: :cscope add cscope.out -c

ios - Location authorization status is 3 -

i using core location cheching location details.while checking authorization status ([cllocationmanager authorizationstatus]) got status 3.what means? code: nslog(@" [cllocationmanager authorizationstatus] %d" ,[cllocationmanager authorizationstatus]); output: [cllocationmanager authorizationstatus] 3 from apple docs : typedef enum { kclauthorizationstatusnotdetermined = 0, kclauthorizationstatusrestricted , kclauthorizationstatusdenied , kclauthorizationstatusauthorized , <---- one! kclauthorizationstatusauthorizedalways = kclauthorizationstatusauthorized , kclauthorizationstatusauthorizedwheninuse } clauthorizationstatus; kclauthorizationstatusauthorized this app authorized use location services. available in ios 2.0 , later. deprecated in ios 8.0.

uitableview - iOS Evenly space 5 labels in UITableViewCell -

Image
i have prototype cell use display data. trying apply constraints 5 labels dynamically space evenly depending on device used display them. far, have been able add constraints constant values cause labels disappear off screen on small display devices. how add constraints evenly spaced between 1 another? thanks. edit: iphone 6: here's list of constraints you'll need make happen: 1st label: leading container, top/bottom container 2nd-4th labels: top alignment + bottom alignment 1st equal width 1st 5th label: top+bottom+equal width first trailing container finally: and between 2 adjacent labels, add 0 horizontal space constraint. after of set up, click little triangle constraint tool in bottom right , update frames. should snap place! here pic of final outcome in storyboard.

ios - How to solve Apple Mach-O Linker Error (MobileWifi framework)? -

i tried use project classes: https://github.com/cykey/wifi/tree/master/src but didnt call class, lot of linker error... i uploaded picture errors: http://oi59.tinypic.com/aaw5z7.jpg please me!

mysql - How to substitute the values while Fetching itself -

i have table shown create table `document` ( `t1` varchar(50) default null, `t2` varchar(50) default null, `t3` varchar(50) default null, `t4` varchar(50) default null, `t5` varchar(50) default null, status int default 0 ); insert document (t1 , status ) values ('pocorn',0); insert document (t1 , t2 , status ) values ('pocorn', 'bucket' , 1); insert document (t1 , t2 , t3 , status) values ('pocorn', 'chocka' , 'small' , 2); this sqlfiddle http://sqlfiddle.com/#!2/d816e/2 my question have 3 status 0 indiccates pending 1 indicates approved 2 indicates declined is possible substitute values pending , approved , declined while fetching select t1, t2, t3, t4, case when status=0 'pendig' when status=1 'approved' when status=2 'declined' end document

How update row without using update query and View in sqlserver 2008 -

i have doubt in sql server my question is: i have 2 table named table1 , table2 table1: **id name current_address** 44 john 44, t-nagar, chennai table2: **id addreess** 44 102, cit nagar, chennai 44 44, t-nager, channai and question is: when insert new address in table2, last insert address automatically update in table1. difficulty without using update query , view in sql server help.... thanks in advance.. in case when don't want update query , first delete data table1 having id=44 , use insert query :p

laravel - Stripe: add a one off payment to a subscription -

is possible in stripe add 1 off payment subscription, without creating dedicated plan? for example, if had apple subscription business charge £4 per month receive bag of apples, , wanted offer users chance add couple of bananas in january. except, bananas add number of other type of fruit, following month go straight being signed bag of apples. i charge card difference, subscription going out on set day each month , might make messy bank statement. i'm using laravel cashier @ moment. you can use invoice item object purpose. invoice item can added subscription , payed during next subscription billing cycle. alternatively can create charge la carte. have nothing subscription directly, , charged card purchase. invoice item: https://stripe.com/docs/api#create_invoiceitem charge: https://stripe.com/docs/api#create_charge

Javascript object notation -

i did manipulations , stored values in arrays say, miles , type. need display object own specific properties. have obj ={ "miles" : [500,200], "type": ["fer","bug"] }; i need return object in format obj = { "fer" : 500 , "bug" : 200 }; thanks. idea appreciated! iterate , create new object var obj = { "miles" : [500,200], "type": ["fer","bug"] }; var obj2 = {}; (var i=0; i<obj.type.length; i++) { obj2[obj.type[i]] = obj.miles[i]; } // snippet output document.body.innerhtml = '<pre>' + json.stringify(obj2, null, 4) + '</pre>';

javascript - CrossRider - is there a way to pass arrays as function parameters without converting them to objects? -

we using crossrider develop extension internet explorer. have object downloaded http://jsons.[part_of_link_suppressed].com.s3.amazonaws.com/selectors.json . found out when object sent callback, arrays converted objects integer keys. why arrays converted objects , there way prevent it? know can json.stringify object , json.parse calling function, there way send arrays without converting them strings? checked , ['a','b','c'] converted object ( {"0":"a","1":"b","2":"c"} ) when calling function it. i'm using internet explorer 11 extension should work on versions of internet explorer. edit (1) : tested debug mode in internet explorer 11 , google chrome. created new extension - id 67708. in chrome works fine, in explorer doesn't. here code: background.js: /************************************************************************************ background code. more information please vi...

javascript - How to load XHR requests in Cordova relative to the base href? -

i using angularjs , have like: myapp.config([ '$stateprovider', '$urlrouterprovider', '$locationprovider', '$sceprovider', 'appconstants', function($stateprovider, $urlrouterprovider, $locationprovider, $sceprovider, appconstants) { $sceprovider.enabled(false); $urlrouterprovider.otherwise('/login'); $stateprovider.state('login', { url: '/login', templateurl: "/templates/login.html" }).state('tos', { when loads in cordova, tries file:///templates/login.html should file:///users/ssiddiqui/library/developer/coresimulator/devices/5bfa4f09-2c0a-4916-9d08-21d8bdc9e0a8/data/containers/bundle/application/12b77264-bcb1-4daa-b1fa-8bc4033adfac/helloworld.app/www/templates/login.html since: <base href="file:///users/ssiddiqui/library/developer/coresimulator/devices/5bfa4f09-2c0a-4916-9d08-21d8bdc9e0a8/data/containers/bundle/application/12b77264-bcb1-4daa-b1fa-8bc4033...

performance - Storing a 32 byte object, on Ivy Bridge? -

i trying find out whether, on ivy bridge, possible write 256-bit object consists of various data types (int, double, float etc)? i have had @ intel manual , ctrl+f "32-byte" results discussing 256-bits of same data type (so 4x doubles or 8x floats etc). i doing part of lock-free design ensure data consistency- load 256 bits of data together, extract each of various components separately. i did web search, , appears intel not guarantee 32 byte write atomic. found this suggests not regular 8 byte writes guaranteed atomic. intel provides compare , exchange 8 byte instruction atomic. bottom line think need take approach. edit: forgot x86 lock prefix. looking @ this , says byte memory operations guaranteed atomic, while larger operations not unless lock prefix used on read/write instruction.

java - Ruby-like modules for Fragments? -

i inherited project have lot of fragments share same functions. i want refactor have basefragment these other fragments can extend , shared functions exist. issue i've run these fragments extend different classes: tasklistfragment , taskfragment . is there way me implement basefragment different types of fragments can use methods - similar how ruby modules work? you have implement interface tasklistfragment , taskfragment. share methods could/would have implemented separately inside classes. children of each class call method. there more complicated way of doing interface best bet. question should shed little more light on issue. java multiple inheritance

Convert Percentage to Decimal Format WinForms C# -

any can me little problem.. i'm programing , validating datagridview in c# winforms. have 2 columns in datagridview. 1. discount %. 2. discount decimal. i want next operation.. i have article , costprice equals $100.00, if put value example 10% in datagridview.rows.column["discount %"].value.. then, automatically converting 10% in decimal, it's mean value in decimal 10% of $100 $10 , value $10 automatically put datagridview.rows.column["discount decimal"].value ... can help, because have no idea how , have headache trying regex not works ? thx in advance. for automatic conversion use lostfocus on textbox http://msdn.microsoft.com/en-us/library/system.windows.forms.control.enter.aspx for decimal value answer help https://social.msdn.microsoft.com/forums/vstudio/en-us/85c5d6d2-1a79-4be7-8af6-7261d4172e74/convert-a-percentage-to-decimal?forum=csharpgeneral set discount decimal text results both of links.

string - uUable to use the output of the command "SFC /scannow" in powershell -

what have done in powershell: $sfc = sfc /scannow write-output $sfc | out-file d:\cours\powershell\sfc.txt $string = 'd d n o t f n d n y n t e g r t y v o l t o n s' $test = $false $sfc | foreach {if ($_.name -match $string) {$test = $true}} if ($test -eq $false) {write-host 'ok'} what in file 'sfc.txt' unreadable notepad++. more, $test equal $false (and that's not true). what save output correctly in file in order able read , testing output? out-file defaults writing in unicode. can change -encoding ascii . you can use set-content defaults ascii. you might able tell notepad++ interpret file unicode, i'm not familiar how that.

django sites framework custom settings for each site -

how can extend django sites framework ? i need add more fields, logo file, subtitle, etc. or other solution kind of thing? just make onetoone relation site model from django.contrib.sites.models import site class customsite(models.model): class meta: verbose_name = "custom domain" verbose_name_plural = "custom domains" site = models.onetoonefield(site, null=true, related_name='customsite') subtitle = models.charfield(max_length=100) #... #... def __unicode__(self): return 'customsite of {0}'.format(self.site.domain)

php - Ensure order in for loop involving json_decode() -

i'm using json_decode parse json files. in loop, attempt capture specific cases in json in 1 element or exist. i've implemented function seems fit needs, find need use 2 loops catch both of cases. i rather use single loop, if that's possible, i'm stuck on how both cases caught in single pass. here's mockup of result like: <?php function extract($thisfile){ $test = implode("", file($thisfile)); $obj = json_decode($test, true); ($i = 0; $i <= sizeof($obj['patcher']['boxes']); $i ++) { //this found 2nd if ($obj['patcher']['boxes'][$i]['box']['name'] == "mystring1") { } //this found 1st if ($obj['patcher']['boxes'][$i]['box']['name'] == "mystring2") { } } } ?> can tell me how catch both cases outlined above within single iteration? not if ($obj['patcher'][...

How to use this json variable in C#? -

i want data in json , use them in program. use these codes: public class test { public class coord { public double lon { get; set; } public double lat { get; set; } } public class weather { public int id { get; set; } public string main { get; set; } public string description { get; set; } public string icon { get; set; } } public class root { public coord coord { get; set; } public list<weather> weather { get; set; } public string name { get; set; } } } i know how use simple variables this: var obj = jsonconvert.deserializeobject<test.root>(jsontest); double mylon = obj.coord.lon; my question how use variables inside weather class because defined in list! example want store "icon" in st...

html - Add a 'point zero' to first level of nested css counter -

here's ordered list have far: 1 item 2 item 2.1 item 2.2 item 2.3 item 2.3.1 item 2.3.2 item 2.3.3 item 3 item 4 item this produced following: <ol> <li>item</li> <li>item <ol> <li>item</li> <li>item</li> <li>item <ol> <li>item</li> <li>item</li> <li>item</li> </ol></li> </ol></li> <li>item</li> <li>item</li> </ol> and css: ol { counter-reset:section; list-style-type: none; } li:before { counter-increment: section; content: counters(section, ".") " "; } what want make top level list items have 'point zero' following counter, in 1.0 item 2.0 item 2.1 item and forth. can done in css? may need creative solution. set initia...

wsh - windows Shell Script not working with VB editor -

can tell me why code: set wshnetwork = wscript.createobject("wscript.network") strcomputername = wshnetwork.computername msgbox strcomputername pcname = mywb.cells(4, 3).value if strcomputername = pcname msgbox "hi vivek!!" end if works in vbs file when it's put in code in vb editor runtime time error 424 - object required? library need reference? using ms excel 2010. have tried adding below libraries in reference: ms scripting runtime ms script control , windows script host object model none of these seem work me. late binding excel 2010 using object variable tools-->reference-->microsoft 14.0 object library dim strcomputername string dim objws object set objws = createobject("wscript.network") strcomputername = objws.computername msgbox strcomputername set objws = nothing

JavaFX combobox, getting white background after listview -

i m getting white background in combobox in javafx screenshot of combobox m getting i used this combobox mode = new combobox(); mode.getitems().addall("cash", "cheque", "account transfer"); please tell me how resolve this.. as can read here , when combo shown popupcontrol extends `popupwindow' shown. has own scene , styling. my guess have styling applied css rule .root.popup , this: .root.popup { -fx-background-color: white; } try remove sytling or change to: .root.popup { -fx-background-color: transparent; } and check if problem solved.

asm/socket.h: No such file or directory cross compiling Dart for Raspberry pi -

i'm cross-compiling dart runtime using instruction here . i've installed dependencies specified. i've cloned git repository necessary tool chain. i'm running runtime compilation command: ./tools/build.py -m release -a arm --toolchain=../tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf runtime the compilation starts no problem stops error: link(target) out/releasexarm/libdart_dependency_helper.target cxx(host) out/releasexarm/obj.host/libdart_lib_withcore/runtime/vm/bootstrap.o in file included /usr/include/sys/socket.h:38:0, /usr/include/netinet/in.h:23, /usr/include/arpa/inet.h:22, runtime/platform/globals.h:56, runtime/platform/assert.h:16, runtime/vm/allocation.h:8, runtime/vm/bootstrap.h:9, runtime/vm/bootstrap.cc:5: /usr/include/bits/socket.h:345:24: fatal error: asm/socket.h: no such file or d...

java - Calling Jersey services from Android , unkown Exception -

i'm trying call web service made using jersey. tested services calling them console java app, , working fine. when calling android, first gave me android.os.networkonmainthreadexception, searched , found out should use asynctask solve that, the following code crashes when "response.getentity(string.class)" called while calling service, if return status ( response.getstatus()) instead of getentity, works fine. same thing doesnt work in case of post request. getentity() crashes on both public string posttest(string arg){ log.d("service", "postregister1"); client = client.create(); webresource service=client.resource(getbaseuri()); log.d("service", "postregister2"); form form = new form(); form.add("arg", "lol"); int status; clientresponse response=null; try{ response = service.path("test").get(clientrespons...

python - TypeError: object of type 'builtin_function_or_method' has no len(), in 2 parts of the code -

i'm working on hangman game, , keep running same error, , i've been trying debug couple hours no progress. this error message: traceback (most recent call last): file "hangman.py", line 128, in <module> guess = guessletter(miss + correct) file "hangman.py", line 103, in guessletter if len(guess) != 1: typeerror: object of type 'builtin_function_or_method' has no len() here relevant parts of code: line 98 - 110 `def guessletter(previousguess): #this function lets player guess letter, , see if guess acceptable while true: print ('guess letter') guess = input() guess = guess.lower if len(guess) != 1: print ('enter single letter please.') elif guess in previousguess: print ('that letter guessed. choose another') elif guess not in 'abcdefghijklmnopqrstuvwxyz': print ('please put lette...

javascript - Parsing an array posted to nodejs server using querystring -

i use querystring parse data posted client. first time posting array, , i'm having same issue. client side: $.ajax({ url: 'myurl', type: "post", data: {ids: ["str1","str2","str3"]}, success: function (msg) { location.reload(); }, error: function (msg) { alert("servererror"); }, cache: false, }); server side: var body=''; req.on('data', function(chunk) { body += chunk.tostring(); }); req.on('end', function() { var parsedbody = querystring.parse(body); console.log(parsedbody);// {'ids[]':["str1","str2","str3"]} my problem? well, first note comment: key ids[] intead of ids . strange , annoyng. , big problem: if pass array 1 string this: data of ajax request--> data: { ids: ["str1"] } the console.log becomes c...

ubuntu - C malloc doesn't work the way I expected it to -

i have no idea wrong code. char *names; int = 6; names = (char *) malloc((i+1)*sizeof(char)); printf("%d", strlen(names)); 0 result instead of 7, why? //i learnt using malloc this: tomb = (double*) malloc(n*sizeof(double)); line line... int len1 = 0; int = 6; these should both size_t . names = (char *) malloc((i+1)*sizeof(char)); you did not show variable declaration names . going assume char * , in future make sure show variable declarations all variables, or better, provide complete test program can compile , run ourselves if have to. in c, not cast return value of malloc . in c-family languages, not write sizeof(char) , 1 by definition . you need check whether malloc failed (returned null ). while (names[len1] != '\0') undefined behavior on line, because memory returned malloc uninitialized. loop may iterate any number of times, including zero, seven, six, five, four, three, two, one, eight, nine, ten, 4096, , infinity. ...

xml - Android Studio - how was this resource file structure trick achieved? -

Image
i checking out google i/o app source code in android studio, , came across ide layout of res/ folder - how achieved? but if @ filesystem @ actual file structure, it's conventional values/styles.xml , values-v17/styles.xml , values-v21/styles.xml arrangement. how can achieve in own app? this "android" project view, group different files in order minimise file differences vs folder differences. this default in android 0.9.x

jquery - How make fixed webkit-mask for div? -

suppose have 2 blocks div superposed, difference between them in lower block content div applied effect assume black-white filter -webkit-filter: grayscale (100%); if div-block p2 reduced in size height , synchronize scrolling achieve transition effect of color content in black-white. however, site try write designed mobile devices , ios have problem dynamic position scrolling. alternatively can use iscroll, slows work... so idea came cut div-block id="p2" using webkit-mask mask , fix webkitmask relative page. more detail in gif-animation: http://outsins.com/mask.gif <div id="scroll" style="-webkit-overflow-crolling:touch;left:200px;width:500px;height:500px;"> <div id="p1" style="position:absolute;width:500px;height:1000px;z-index:1;-webkit-filter: grayscale(100%);"> text </div> <div id="p2" style="position:absolute;width:500px;height:1000px;z-index:2; color: blue;-webkit-mask:url(heart...

php - Lazy loading specific entities in Doctrine 2 -

i have quite trivial question/problem, haven't found satisfiable answer. i have simple entity in doctrine 2 specifying configuration options (just id, name , value). during rendering different pages throughout code, i'm requesting different configuration options name, results in query each 1 of requests. but need values in template. want somehow squeeze different calls 1 query, execute , fetch options i've requested. cannot build custom dql because don't know options each page want (and building every combination seems stupid hell me). i thought naive implementation of weird lazy loading, turns out don't have knowledge in field. there possibility doctrine automatically? thanks time. what problem? if don't want call database query in every request, cache queries in redis, memcached, apc etc... doctrine out of box support eager, lazy , lazy loading related entities another.

php - ReferenceError: data is not defined or 403 Forbidden -

and thank in advance reading this. i'm new in php , jquery. i've managed few forms in php worked, , feel big need (because of how webpage shaping) make them work jquery. i'm trying not right. form: <form action="<?php echo htmlspecialchars($_server["php_self"]);?>" method ="post" id="form_add"> <br> <div class="add_field" id="title_div">title:<input typee="text" class="add_text" maxlength="100" name="title" id="title"></div> <br> <div class="add_field">discription:<input typee="text" class="add_text" maxlength="1000" name="discription" id="discription"></div> <br> <div class="add_field" id="content_div">content:<textarea class="add_text" maxlength="65535" name="content" id=...

c - How to add a border around a matrix? -

i have problem need process matrix toroid calculating sum of neighbours, have thought way: add border around matrix elements represent outline of matrix.to more specific, if had matrix: 1 2 3 4 5 6 7 8 9, after adding border this: 9 7 8 9 7 3 1 2 3 1 6 4 5 6 4 9 7 8 9 7 3 1 2 3 1 bolded numbers represent initial matrix.note corners of border opposite corner of initial matrix(e.g. :the corner adjacent a 11 (whose value 1) a 00 ,(whose value 9),the same a 33 ,the corner opposing a 11 in initial matrix ). far have come algorithm, pretty works fine, except rightmost column, or think.yes aware algorithm not have complexity, it's best come , have no memory/time restriction on problem.any suggestions error might be?(n number of lines, m number of columns (i=1; i<n+1; i++) { (j=1; j<m+1; j++) { b[i][j]=a[i][j]; } } for(i=1; i<m+1; i++) { b[0][i]=b[n][i]; ...

asp.net mvc 4 - MVC Bootstrap forms styling issue -

Image
i'm having small issue bootstrap mvc form. margin form-group doesn't seem working when add razor. appreciated. this form doesn't take styling properly @using (html.beginform("contact", "home")) { @html.antiforgerytoken() @html.validationsummary(true) <form class="form-horizontal" role="form"> <div class="form-group"> <label for="formgroupinputlarge1" class="col-sm-2 control-label">name</label> <div class="col-sm-10"> @html.textboxfor(m => m.name, new { @class = "form-control", placeholder = "fullname", tabindex = 1 }) @html.validationmessagefor(m => m.name) </div> </div> <div class="form-group"> <label for="formgroupinputlarge2" class="col-sm-2 control-label">email</label> <div class="col...