Posts

Showing posts from April, 2013

vb.net - What is the equivalent to "ByRef" in Java? -

this question has answer here: is java “pass-by-reference” or “pass-by-value”? 73 answers i'm working on translating code visualbasic java , i've encountered snag when using byref keyword in vb. doesn't exist in java! how should simulate byref call in java? edit: clarify don't know vb, byref identifies variable in parenthesis after calling function , makes when variable changes inside of function, change higher called opposed byval value of variable remembered. changing byval variable in method not affect variable called. you can't. in java passed value, including object references. create "holder" object, , modify value inside method. public class holder<t> { t value; public holder(t value) { this.value = value; } // getter/setter } public void method(holder<foo> foo) { foo.setvalu

Grails show my URL in controller -

i pulling components of url. used request.getrequesturl() , url looks wrong: it's missing id, example. i'm getting this:: ..//apka/grails/aaa/edit.dispatch" but need this: ..//apka/grails/aaa/edit/34" do have solutions? you can information require request.forwarduri , grails specific addition usual httpservletrequest. result you're getting request.requesturl result of url mapping mechanism, , kind of "canonical form" /grails/controller/action.dispatch . forwarduri went in url mapping mechanism, i.e. uri user requested.

mysql - Laravel 4 Method Improvement -

i have index method: public function index() { // in view, there several multiselect boxes (account managers, company names , account types). code retrives values post method of form/session. $company_names_value = input::get('company_names_value'); $account_managers_value = input::get('account_managers_value'); $account_types_value = input::get('account_types_value'); // if there has been no form submission, check if values empty , if assign default. // essentially, of records in table column required. if (is_null($company_names_value)) { $company_names_value = db::table('accounts') ->orderby('company_name') ->lists('company_name'); } if (is_null($account_managers_value)) { $account_managers_value = db::table('users') ->orderby(db::raw('concat(first_name," ",last_name)')) ->select(d

php - Chat using nodejs+socket.io and mysql -

so want develop chat system based on nodejs , socket.io, have made prototype , works, thing stuck in mind how store chat messages in database. i guess not idea store message when user hits enter button, because live chat have 1000 user in 30-60 min. the question when store data in database, because don't think storing right away when user hits enter work on long term? the chat works on same idea facebook. if not saving messages @ moment, how plan save them when want to? the messages sent have been delivered client , server no longer has them, , can't use client store them in database. you need store messages user sends them.

image processing - How to read a BMP file in Visual C++ and extract width, Height and data with a example -

iam new c++ pro in image processing using matlab iam looking header file (ex: cimg.h )which can read bmp , retrieve length width , 2d array similar 'imread' function in matlab... not allowed use opencv opengl an example tia

debugging - (solved) c++ fix syntax debug with *lec=fopen(); -

i working on c++ code friend know better do, , code has bug, i'd fix this, since couldn't figure out how... edit compiler stops @ line 59 where: file *ecr("result.txt","wt"); written. there many other things fix, fixed until 49 (59 ;) ) blocked again... thanks! edit (again, sorry) message: c:\users\ad\desktop\python\josh\josh\color\3d\solution_to_array.cpp||in function 'int main()':| c:\users\ad\desktop\python\josh\josh\color\3d\solution_to_array.cpp|59|error: expression list treated compound expression in initializer [-fpermissive]| c:\users\ad\desktop\python\josh\josh\color\3d\solution_to_array.cpp|59|error: cannot convert 'const char*' 'file* {aka _iobuf*}' in initialization| c:\users\ad\desktop\python\josh\josh\color\3d\solution_to_array.cpp|82|error: expected initializer before '<' token| c:\users\ad\desktop\python\josh\josh\color\3d\solution_to_array.cpp|82|error: expected ';' before '<

Oracle dba_tab_cols query -

hi possible retrieve primary key , unique key using dba_tab_cols query? is there query allows me retrieve of following fields? column name data type primary key null/not null unique key default value extra both primary , unique keys can span more 1 column, wouldn't belong in dba_tab_columns . you'd need @ dba_constraints , dba_cons_columns information. this starting point, maybe: select owner, table_name, column_name, data_type, primary_key, nullable, unique_key, data_default ( select dtc.owner, dtc.table_name, dtc.column_id, dtc.column_name, dtc.data_type, dtc.nullable, dtc.data_default, case when dc.constraint_type = 'p' , dcc.column_name = dtc.column_name dc.constraint_name end primary_key, case when dc.constraint_type = 'u' , dcc.column_name = dtc.column_name dc.constraint_name end unique_key, row_number() on (partition dtc.owner, dtc.table_name, dtc.column_id order null) rn dba_tab_colum

remove special character [ ] in array java -

in program have following string of array, when process program output have square bracket [], need without square bracket []. suggestion in how remove them? private final static string[] l0 = {"az","fh md br", "inr gt cn", "bl gs st st", "mae nw get", "pam ml rm", "comr lab pl mt hs", "za"}; public static string sfuffle() { list<string> shuffled = new arraylist<string>(arrays.aslist(phrasestring)); collections.shuffle( shuffled ); system.out.println(shuffled);// added have output return shuffled + "\n"; } output: [az, mae nw get, bl gs st st, fh md br, za, comr lab pl mt hs, inr gt cn, pam ml rm] my desired output be: az, mae nw get, bl gs st st, fh md br, za, comr lab pl mt hs, inr gt cn, pam ml rm just use substring() : string str = shuffled.tostring(); return str.substring(1, str.length() - 1) + "\n"; by popular demand, i'

c# - View cached data in ASP.NET MVC -

is there third party tool or in visual studio lets see cached objects? for example, action caching data (varied parameters) , want see cached objects , attributes (like parameter values sent action when data cached). you can find more answers might desire on stackoverflow question: how display content of asp.net cache? basically can create page view cached items application. after that, can customize , ui pump needs , objectives. if need debug, can use ringer's solution displayed on comments.

java - Facebook restfb using jsonObject stopped getting likes count -

i using restfb number of likes in specific post, , working well. somehow, morning stopped working, , didn't change in code. problem on following line: posts.get(i).getjsonobject("likes").getstring("count")) after retrieving posts page, when trying number of likes post has, this: com.restfb.json.jsonexception: jsonobject["count"] not found. i used graph api explorer see if search working , check if "count" appeared on results, , does: "likes": { "data": [ { "name": "kobi parfait", "id": "100000605529126" }, { "name": "john foley", "id": "100002480987029" }, { "name": "camilla slima", "id": "1267755442" }, { "name": "augustine paz", "id": &qu

How can I renew a Users Facebook Access Token? -

if user loggs app facebook account access token valid 2 months. happens if 2 months exceed , user loggs app again? new 2 month access token automatically? your user have go through normal authentication process did when first installed application. during process, facebook detect application has been installed , refresh access token. so, directly answer question: yes , receive new access token.

rows - Change all records at once. Update one field with same input mysql -

i trying change input 1 field of records though can't figure out. appreciated. i trying change them using: select * `users` set 'password'='newpassword'; update proper command changing values in mysql - example: update `users` set password='new_password_string' password not null

iphone - Convert GMT NSDate to device's current Time Zone -

Image
i'm using parse.com store values: these gmt values. how convert these device's current time zone , nsdate result? nsdate represented in gmt. it's how represent may change. if want print date label.text , convert string using nsdateformatter , [nstimezone localtimezone] , follows: nsstring *gmtdatestring = @"08/12/2013 21:01"; nsdateformatter *df = [nsdateformatter new]; [df setdateformat:@"dd/mm/yyyy hh:mm"]; //create date assuming given string in gmt df.timezone = [nstimezone timezoneforsecondsfromgmt:0]; nsdate *date = [df datefromstring:gmtdatestring]; //create date string in local timezone df.timezone = [nstimezone timezoneforsecondsfromgmt:[nstimezone localtimezone].secondsfromgmt]; nsstring *localdatestring = [df stringfromdate:date]; nslog(@"date = %@", localdatestring); // local timezone is: europe/london (gmt+01:00) offset 3600 (daylight) // prints out: date = 08/12/2013 22:01

php - calling database to check for errors in a web app -

i'm building web app check errors in our mobile app has web interface. i'm having trouble calling database through php. in mobile app called in objective c by: -(bool)login:(nsstring *)username password:(nsstring *)password{ // create new sbjson parser object nsstring * passwordtoserver = [self sha1:[nsstring stringwithformat:@"removed security", password]]; nsstring * authtoken = [self sha1:[nsstring stringwithformat:@"%@%@%@", securestring, username, passwordtoserver]]; nsdata* data = [nsdata datawithcontentsofurl: [nsurl urlwithstring:[nsstring stringwithformat:@"%@/%@%@", serverurl, @"api/login/", authtoken]]]; // json nsstring nsdata response nsstring *json_string = [[nsstring alloc] initwithdata:data encoding:nsutf8stringencoding]; if([json_string isequal:@"error"]){ loggedin = false; return false; } else{ //get campagns how call server using php if have serverurl, securestring , passw

ios - How to add a UIView to the entire UICollectionView -

i have uicollectionview custom layout. shows items in grid (2 columns) , has multiple sections. works perfect. now, want add uiview @ top of uicollectionview. note: not view per section. view entire uicollectionview. what best approach achieve this? keep in mind uicollectionview shows custom uiview each section. actually, want can uitableview tableheaderview.

html - How to resize the box but still put text inside it at center? -

in following html: <div class='title'><h2>title</h2></div> i want resize box, wrote following: .title { display: block; border-radius: 12px; border: 1px solid; } however, resultant box looks bit big, hence tried resize it. .title { height: 90%; } however, if tried write above code, resultant box isn't affected settings. .title { height: 100px; } this worked. however, text inside no more on center, tried make @ center. .title h2 { vertical-align: middle; } however, doesn't work. so how can resize box still have text inside intact? also, why first height setting doesn't work second does? thanks. try applying: ( working jsfiddle ) .title h2 { margin:0px; line-height:100px; /* change fit needs */ } vertical-align not best approach in case.. update: use this jsfiddle instead, uses vertical-align wanted , don't need apply line-height of h2 .. secret making parent display:table; , child

OpenLayers: transform GPS coordinates to EPSG:25832 -

i want gps coordinates button click , change them epsg:25832 format center map. here have coded far: jquery('#btngps').click(function() { if (navigator.geolocation) { navigator.geolocation.getcurrentposition(success); } else { alert("not supported!"); } }); function success(position) { alert(position.coords.longitude + ',' + position.coords.latitude); var srs_map = new openlayers.projection("epsg:25832"); var srs_lonlat = new openlayers.projection("epsg:4326"); var center = new openlayers.lonlat(position.coords.longitude,position.coords.latitude); var test = center.transform(srs_lonlat,srs_map); alert(test); } finally map object: map = new openlayers.map('map',{ controls: [ new openlayers.control.navigation(), new openlayers.control.panzoombar(), new openlayers.control.scaleline(), new openlayers.control.key

google plus - Adding a review box to site that posts to G+ Local page -

i wondering if possible add review box site automatically post google+ local page, , in turn show google review. i want simple functionality of leaving comment , star rating site avoid having travel page. is functionality available? i have found slight shortcut adding query parameter ?review=1 end of url automatically brings review box once google places page loads, , have customized message try , entice click feel easier make on leave review more successful be. i'm sorry don't have functionality.

javascript - How to place labels on opposite Y axis in Highchart without a second series -

Image
i have following chart set in highcharts : // initialize chart when document loads. $(document).ready(function() { $('#results').highcharts({ chart: { type: 'bar' }, title: { text: '' }, xaxis: [{ categories: [ 'injustice: gods among ★', 'tekken tag tournament 2 ★', 'super smash bros. melee ★', 'persona 4 arena', 'king of fighters xiii', 'dead or alive 5 ultimate', 'street fighter x tekken ver. 2013', 'soulcalibur v' ], }], yaxis: { allowdecimals: false, title: { text: 'votes' } }, series: [{ data: [ {y:1426,color:'#29a329'},{y:823,color:'#29a329&#

php - Email verification -

i'm creating newsletter subscription app. want implement email verification prevent spam/bot signups (well, @ least can delete them afterwards). i've been struggling confirmation key though of simpler solution: user clicks submit -> inputed database (verified = 0) user receives generic email ("click me verify") -> verified page (verified = 1) would work? there potential issues might come up? if problem spam bots, should use captcha: http://www.google.com/recaptcha against of them. your solution good, if want prevent random user using site, problems solves user must put effort in it. also if want save bandwidth, can realy go in email checking: http://www.serviceobjects.com/blog/hot-topics/email-validation-whitepaper/ hope helps

Add styles above scripts inside Meteor app <head> tag -

i'm new , loving meteor. but, of course, every framework nice features has flaws. meteor, seems flaw amount of client-side scripts have loaded app rolling. because of this, relatively empty meteor app can take bit longer render i'd like. feel makes site seem it's broken first 6 seconds. i know remove dependencies save time. i'm sure things bit better compressed outside of production mode well, in case doesn't when app finished, i'd able give user indication page working. one way thought of doing add background style while scripts loading. problem seems add head tag in meteor gets loaded after 20 or scripts. is there way put style tags above meteor's script tags , have styles render before scripts load , start processing? it appears adding css files "client" directory , leaving link tags out of head tag completely, stylesheets load before scripts, solving problem. let lesson me.

java - How to pass parameter on jpa query generated by netbeans -

following code generated netbeans while binding jtable netbeans gui editor. serverdetailsquery = java.beans.beans.isdesigntime() ? null : f1softsmscpuentitymanager.createquery("select s serverdetails s "); and changed query using editing select s serverdetails s order id desc this working fine. want pass parameter on query filter record shortcode : select s serverdetails s s.shortcode : filtershortcode order id desc short code text field , there button filter record if user types shortcode , clicks button. relevant code @suppresswarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="generated code"> private void initcomponents() { bindinggroup = new org.jdesktop.beansbinding.bindinggroup(); f1softsmscpuentitymanager = java.beans.beans.isdesigntime() ? null : javax.persistence.persistence.createentitymanagerfactory("f1softsmscpu").createentitymanager();

asp.net mvc - Websecurity.CreateUserAndAccount on Azure doesn't work -

i have method registers new user using websecurity.createuserandaccount(model.username, model.password) problem in userprofile model have added guid key. on local machine populates empty guid when call method. on azure however, following error: system.data.sqlclient.sqlexception (0x80131904): cannot insert value null column 'key', table 'scheduler.dbo.userprofile'; column not allow nulls. insert fails. now, i've tried generate new guid in constructor of model, manually have set{} generate new guid , same error. when try use createuserandaccount overload like: websecurity.createuserandaccount(model.username, model.password, new { key = guid.newguid() }); i following syntax error (run time): incorrect syntax near keyword 'key'. i've spent part of morning trying figure out , can't. way of above methods still result in empty guid 00000000-0000-0000-0000-000000000000 , overload gives me syntax error on local machine.

Python: Append dictionary in another file -

i working on program , need access dicionary file, know how do.i need able append same dictionary , have saved in current form other file. is there anyway this? edit: the program requires log in. can create account, , when needs save username:password entered dictionary. way had it, create account, once quit program, account deleted. you can store , retrieve data structures using pickle module in python, provides object serialisation. save dictionary import pickle some_dict = {'this':1,'is':2,'an':3,'example':4} open('saved_dict.pkl','w') pickle_out: pickle.dump(some_dict,pickle_out) load dictionary with open('saved_dict.pkl.'r') pickle_in: that_dict_again = pickle.load(pickle_in)

http - Using Postman to test my node.js program -

i'm using chrome's extension postman test node.js(express module) program. basically, want program allow user input on postman , retrieves information somewhere in program based on user input. so program takes in user input via postman(raw code), [{id:0, image:tiger.jpg}, {id:1, image:cat.jpg}, {id:2, image:dog.jpg}] then code process user input's id's only(regardless of images), , string of objects associated these 3 id's. after getting string, program send http request print objects retrieved localhost server. how able achieve using express's post , method. when use post/get? use post receive input? , use retrieve data program? below functions thinking of including.. app.post('/', express.bodyparser(), function (req, res) { someone suggested this. can tell me if whether or not function can receive input postman? noticed method might change req.body? don't understand how changes , parses input. there way many ques

bash - linux get filecontent as stdio after pipe -

i have linux command reads stdio , generates simple file per hour: myapp > ~/$( date "+%y%m%d%h.txt" ) then, because myapp can read stdio clear text files , input files zipped, use zcat read files , send them previous processing: zcat myfile.zip | myapp > ~/$( date "+%y%m%d%h.txt" ) so far, fine. problem need read variable-name file , continue process it, eg, send file content 'head' command. try: head $( zcat myfile.zip | myapp > ~/$( date "+%y%m%d%h.txt" ) ) without sucess. , don't want create variable because process can take more 1h go.. , maybe diferent filename variable in head: zcat myfile.zip | myapp > ~/$( date "+%y%m%d%h.txt" ) ) && head ~/$( date "+%y%m%d%h.txt" ) so, think best way this? thanks all. why not store first on variable? filename=$( date "+%y%m%d%h.txt" ) zcat myfile.zip | myapp > ~/"$filename" && head ~/"$filename

python - Numpy: array of indices based on array shape? -

Image
say have simple array: a = np.zeros([3,3]) >>> [ 0 0 0 , 0 0 0 , 0 0 0 ] is there utility function give me array same dimensions contains "coordinates" of each point on a ? so, ia = np.indexer(a) >>> [ (0,0) (0,1) (0,2), (1,0) (1,1) (1,2), (2,0) (2,1) (2,2) ] ? want vectorize operation using np.ndenumerate, easier if output of ndenumerate in matrix form. class glwidget(qtopengl.qglwidget): target_array = none ... def paintgl(self): glclear(gl_color_buffer_bit | gl_depth_buffer_bit) self.render() def render(self): if self.target_array none: return starting_abs_point = -(np.array(self.target_array.shape)-1)/(2*np.max(self.target_array.shape)) gltranslate(*starting_abs_point) last_rel_coords= np.zeros(3) idx, value in np.ndenumerate(self.target_array): # vectorization target! rel_coords = np.array(idx)/np.max(self.target_array.shape) step = rel_coords-last_rel_coords last_rel_coords

highcharts - Margins will not adjust to make a smaller chart? -

Image
i have following pie chart cannot figure out how margins move closer rendered pie chart itself. need squeeze smaller real estate , it's overlapping other divs fiddle-> http://jsfiddle.net/8ezm4/ <div id="container3" class="container3" style="width: 120px; height: 130px; margin: -25px 0px -80px -20px; padding-bottom: -10px; border-width:1px; border-style: solid"></div> highcharts leaves room labels , titles, etc. couple of things rid of space: set spacing , margin zero set size of pie chart it seems me 1 or other should work. but, if 1st, chart little small , if 2nd, chart little big. $('#container').highcharts({ chart: { type:'pie', borderwidth: 1, plotborderwidth: 0, spacingbottom: 0, spacingtop:0, spacingleft:0, spacingright:0, margin: [0, 0, 0, 0] }, title: { text:'' }, plotoptions: {

intuit partner platform - account's balance at a point of time in AggCat -

is there anyway obtain account's info including account's balance @ point of time? basically, need account's balance @ beginning of month , end of month accounting purposes. however, cron job update account's info @ beginning/end of month may fail various reasons, in case there no way retrieve account's balance @ beginning/end of month anymore! we not have mechanism capture value @ specific time asking provide balance each time capture transactions. if capture day later can perform reverse running balance using current balance - transactions occured between data wish display. example: august 1st: $5.00 transaction mcdonalds $3.00 transaction ralphs balance on august 2nd: $35.00 calculate balance 1st. $35 + 5 + 3= $43.00 balance @ start of month. you add debits , subtract credits , can obtain value seeking.

c# - WindowPhone 7.x | How to correctly close/pause video recording when app going to background -

when lock phone during video recording, app hung stack trace below: system.windows.dll!ms.internal.nativephotomethods.capman_disconnect(int dwseq) system.windows.dll!system.windows.media.capturesource.capturethread() + 0x2dd bytes mscorlib.dll!system.threading.threadhelper.threadstarthelper(system.threading.threadhelper t) + 0x1d bytes mscorlib.dll!system.threading.threadhelper.threadstart_context(object state) + 0xb bytes mscorlib.dll!system.threading.executioncontext.run(system.threading.executioncontext executioncontext, system.threading.contextcallback callback, object state) + 0x63 bytes mscorlib.dll!system.threading.threadhelper.threadstarthelper() + 0x2a bytes when call capturesource.stop() (on lock event phoneapplicationframe.obscured ), app hang different stack trace: mscorlib.dll!system.threading.thread.join() system.windows.dll!system.windows.media.capturesource.stopmanagedimagecapture() + 0x3e bytes system.w

android - Nullpointer at creating PendingIntent -

i nullpointer @ intent alarmintent = new intent(this, mynotification.class); have no idea how fix this.. hope might able me.. what should set alarm everyday @ 9 can set notification in mynotification class contains broadcastreceiver. below code: calling alarmmanager class (from mainactivity): alarm setalarm = new alarm(); setalarm.setrecurringalarm(); the class want set alarmmanager (alarm.class): public class alarm extends activity { public void setrecurringalarm() { log.i("alarm", "setting recurring alarm"); calendar updatetime = calendar.getinstance(); updatetime.set(calendar.hour, 7); updatetime.set(calendar.minute, 0); updatetime.set(calendar.second, 0); intent alarmintent = new intent(this, mynotification.class); pendingintent recurringdownload = pendingintent.getbroadcast(this, 0, alarmintent, pendingintent.flag_cancel_current); alarmmanager alarms = (alarmmanager) getsystemservice(context.alarm_ser

javascript - Dojo moveable with a Dojo pausable -

Image
i have div attached movable element. inside div there list of buttons accompanied scroll bar. when try drag scroll bar drag whole div around screen. in code fragment trying moveable turn off when click on scroll bar (which part of metl). i have "metid" everywhere else in div set resume dragging div around. the pause , resume not work. any resolving issue helpful, thank you. it quite difficult answer question, without seeing html markup comprising structure of relevant elements. there may better approach trying accomplish. nevertheless, i'm pointing out 1 possible issue: the drag , drop action starts, when dojo registers dragstart , mousedown , or selectstart events on drag handle. in case drag handle div id "divmenu"+threadid . of these events triggered before click event occurs, pausing moveblocker has no effect. in addition think, moveblocker event should not empty function. instead should actively 'block' relevant events bei

html - background image for navigation link -

i trying display background image behind navigation link, not displayed code: #aboutlink{ background-image: url(sidebar.png); background-repeat: no-repeat; background-position: left; background-color: transparent; display: block; margin-bottom: 160px; text-align: left; } set width , height of navigation link, otherwise image cut off , won't display fully

objective c - cocos2d sprite collision detection, one sprite sometimes has a contentSize.width of 0.000000 -

hello having trouble collision detection in cocos2d game. working on game need test if bullet hits character. using cgrectintersectsrect method see if collision happens. in simulator can see bullet pass on character nothing happens. want character disappear if bullet hits it. in code have cclog statement outputs "collision" if bullet hits character. have 2 other cclog statements output contentsize.width of bullet , character. bullet's contentsize.width should 20.0 outputs width 0. here code collision detection. -(void)testforbulletcollision:(cctime)delta{ cclog(@"bullet.contentsize.width = %f",bullet.contentsize.width); cclog(@"character.contentsize.width = %f",character.contentsize.width); if (cgrectintersectsrect([bullet boundingbox], [character boundingbox])) { cclog(@"bullet collision"); character.visible = no; bullet.visible = no; } } here code creating character. character = [ccsprite spritewithfile:@"mcharact

Modify vim's 't{char}' to have cursor land on {char} -

in standard vim, when hit t{char} in normal mode, cursor moved space before next instance of {char} right. similarly, t{char} moves cursor space after next instance of {char} left. is there way set t{char} (or t{char}) moves cursor on top of next instance/previous instance of {char}? you're looking f{char} , f{char} . see :help f .

sql server 2008 - Changing position of a row in sql -

Image
in above t-sql table total row appear @ bottom. have been wracking head against , in of other queries using order status works total alphabetically farther down list of our row values. this not case here , can't figure out how change it i'm pretty new sql , i'be been having lot of difficulty determining how phrase google search. far i've gotten results pertaining order the results of select query, unless order explicitly specified via 'order by' clause, can returned in any order. moreover, order in returned not deterministic. running exact same query 3 times in succession might return exact same result set in 3 different orderings. so if want particular order table, need order it. order clause like select * mytable t ... order case status when 'total' 1 else 0 end , status would you. 'total' row float bottom, other rows ordered in collating sequence. can order things arbitrarily technique: select * mytable t .

python - Formatting A ManyToManyField in to boxes with Django -

Image
i having trouble formatting. here's code looks right now: as can see have product field , price field each 1 of products. how can product , price in separate boxes else? here's code: class purchaseorder(models.model): product = models.manytomanyfield('product', null =true) def get_products(self): return "<br />".join("%s --- $%s" % (p.products, p.price_for_each_item) p in self.product.all()) get_products.allow_tags = true get_products.short_description = "product --- price" class product(models.model): products = models.charfield(max_length=256, null =true) price_for_each_item = models.floatfield(verbose_name = "price") def __unicode__(self): return self.products

javascript - How to use the Ember.Select value to filter JSON? -

i want filter json using ember.select value instead of hardcoding it. here's app.js app = ember.application.create({}); app.indexroute = ember.route.extend({ rendertemplate : function(controller) { this.render('myapp', { controller : controller }); }, model : function() { return app.mytemplatemodel.find(); } }); app.indexcontroller = ember.arraycontroller.extend({ filteredcontent : ember.computed.oneway("content"), last : function() { var filtered = this.get('content').filterproperty('last_name', "solow"); this.set("filteredcontent", filtered); } }); app.mytemplatemodel = ember.model.extend({ id : ember.attr(), last_name : ember.attr(), first_name : ember.attr(), suffix : ember.attr(), expiration : ember.attr() }); app.controller = ember.object.create({ selectedprogrammer : null, content : [ember.object.create(

ios - "Add to Home Screen", save state without app cache? -

i have web site i'd users able add home screen. users switch between saved "web app" , game frequently. the first problem when user comes saved "web app", displays splash screen every time though wasn't closed. undesirable. further, when users clicks on primary navigation element, switches user on safari. how app "save state" , not re-load app when coming (when hasn't been closed)? how load links clicked within same domain load within saved "app" rather loading them in safari? safari doesn't reload page when switch away app , come back, why web site saved home screen have reload when pulled front? i don't want use offline database, don't need app work while offline because needs tie live database that's changing. therefore working offline isn't intuitive because data outdated , irrelevant. therefore, don't need cacheing either (except maybe few resources don't change often). want darn thing &quo

php - Save checked values on page refresh? -

ive saved form data ajax , php, reusing data database. however way approaching different, there no database, insight great. i emailing form data, data simple checkboxes, values either 0 or 1 . when user refreshes page id keep checked values. i guess without database need use cookies, , way avoid cookies ajax , database (strictly logic, not sure if true), why asking, want simple solution. form snippet: <input name="sharks" type="hidden" value="0"> <input name="sharks" type="checkbox" value="1" id="sharks" '.$value ? ' checked="checked"' : ''.'> the php part of input shaky, id question whether value 0 or 1, if 1 checked if 0 empty. getting database easier not sure since there no database, im guessing cookies come place. sorry if last part shaky im little unsure , dont know look. using sessions: session_start(); if(isset($_post['submit'])) {

asp.net - The request failed with HTTP status 400: Bad Request ( The data is invalid. ): Code base Works on one machine but not another -

this environmental issue i'm stumped start. i'm attempting call a webservice on external server in asp.net web app while debugging in vs2008. exact same code/project works on 1 machine calling server on machine (my new one) fails 400 bad request (data invalid) error. both machines running windows 7. should looking differences in 2 machines contributing problem? edit deleting webreference in project , re-creating webreference had no effect update i went use fidler2 inpect request , response resulted in error going away. things beginning point internet proxy issue. it's internet proxy issue. suspect machine had configured manually use proxy server. turning off: control panel -> internet options -> connections tab -> lan settings button, , enabling "automatically detect settings" has fixed problem.

scala - trying to stream tweets with twitter4j3.0.3 -

i trying stream tweets twitter4j3.0.3 scala gives me these errors. here code: import twitter4j._ import ch.qos.logback.core.status.statuslistener import twitter4j.conf.configurationbuilder import ch.qos.logback.core.status object stream { def main(args: array[string]) { val cb: configurationbuilder = new configurationbuilder cb.setdebugenabled(true) .setoauthconsumerkey("1") .setoauthconsumersecret("1") .setoauthaccesstoken("1") .setoauthaccesstokensecret("1") def simplestatuslistener:statuslistener =new statuslistener() { def addstatusevent(status: status) {println(x = status.gettext)} def onstatus(status: status) { println(x = status.gettext) } def ondeletionnotice(statusdeletionnotice: statusdeletionnotice) {} def ontracklimitationnotice(numberoflimitedstatuses: int) {} def onexception(ex: exception) { ex.printstacktrace } def onscrubgeo(arg0: long, arg1: long) {} def onstallwarning(

graph - How to turn off vertical y axis bar in MATLAB plot? -

how turn off black line on vertical y-axis? i tried using following set color white appears hidden. however, using grid lines, , if turn white: set(gca,'ycolor',[1 1 1]); % sets y-axis , gridlines white color (represented '1 1 1') i found can following fix issue: plot white line y-axis ranges any other ways this? plot white line y-axis ranges

windows 7 - Have trouble installing org mode (emacs) -

i'm having trouble installing org mode. i'm new emacs , org mode. i've downloaded org mode gnu site , extracted zip file. however, unable find .emacs file set load-path (add-to-list 'load-path "~/path/to/orgdir/lisp"). could me find .emacs file? cheers emacs looks .emacs file in $home directory. open file, do: c-x c-f ~/.emacs (if curious) see home directory is, following: enter m-x eshell enter echo $home

bash - What's the difference between "here string" and echo + pipe -

wondering right use of here-string (here-document) , pipe. for example, a='a,b,c,d' echo $a | ifs=',' read -ra x ifs=',' read -ra x <<< $a both methods work. difference between 2 functionality? another problem have "read" that: ifs=',' read x1 x2 x3 x4 <<< $a does not work, x1 valued "a b c d", , x2, x3, x4 has no value but if: ifs=',' read x1 x2 x3 x4 <<< "$a" i can x1=a, x2=b, x3=c, x4=d okay! can explain this? thanks in advance in pipeline, 2 new processes created: 1 shell execute echo command, , 1 shell execute read command. since both subshells exit after complete, x variable not available after pipeline completes. (in bash 4, lastpipe option introduced allow last command in pipeline execute in current shell, not subshell, alleviating problem such pipelines). in second example, no process need here string (a special type of here document consis

datetime - How to calculate seconds in php -

i have code: $hours = floor($differenceinhours); $minutes = ($differenceinhours-$hours)*60; $seconds = ':00'; $total=$hours . ":" . $minutes .':' . $seconds; echo $total; i want know on how calculate seconds. formula? you can use second parameter of date function format number of seconds formatted time notation. number of hours larger 24, considers 1 day, you'll have take account treating hours separately. echo floor($differenceinhours) . ':' . date('i:s', ($differenceinhours - floor($differenceinhours)) * 3600); if not want treat hours separately, can use: echo date('d h:i:s', $differenceinhours * 3600); (of course, when reaches 31 days, considers month, et cetera...)

Test duplicate R package locally -

i'm looking @ trying make updates package have installed. i'd extend existing package in few ways including: adding new r source file updating namespace file modifying few other existing r source files i presume these changes require complete install test (i.e. use of namespace correct, etc). how go installing package locally while making changes considering original package installed? the thing can think of change name of package , install - there better method allows testing changes existing package?

python - Is it possible to play FLAC files in Phonon? -

i'm trying play .flac files using pyside's phonon module (on mac if makes difference) it's not available mimetype playback. there way enable or plugin need install? phonon not directly support audio formats uses underlying os capabilities. answer therefore depends on if there service registered mime type audio/flac . me there , here short example script find out: from pyside import qtcore pyside.phonon import phonon if __name__ == '__main__': app = qtcore.qcoreapplication([]) app.setapplicationname('test') mime_types = phonon.backendcapabilities.availablemimetypes() print(mime_types) app.quit()

How do I toggle <p> with a html link using only css -

i been working while trying have link show , hide paragraph below it. i need accomplish using css. paragraph must hidden on load , show once link clicked , hide again when link clicked again. how can accomplish this? <a …………………>my link</a> <p>sed ut perspiciatis unde omnis iste natus</p> i appreciate help.. short answer: need javascript. after all, that's intended for: user interaction, among other cool things. css on other hand oriented towards presentation, interaction features limited (for example, responds hover action not click action in way expect it). the idea comes mind using checkbox control click "states" , in css display based on status. html: <label><input type="checkbox">my link <p>sed ut perspiciatis unde omnis iste natus</p> </label> css: input[type="checkbox"] {display: none;} input[type="checkbox"] + p {display:none; margin-left:1em;} input

node.js - Getting 401 uploading file into a table with a service account -

i using nodejs , rest api interact bigquery. using google-oauth-jwt module jwt signing. i granted service account write permission. far can list projects, list datasets, create table , delete table. when comes upload file via multipart post, ran 2 problems: gzipped json file doesn't work, error saying "end boundary missing" when use uncompressed json file, 401 unauthorized error i don't think related machine's time being out of sync since other rest api calls worked expected. var url = 'https://www.googleapis.com/upload/bigquery/v2/projects/' + projectid + '/jobs'; var request = googleoauthjwt.requestwithjwt(); var jobresource = { jobreference: { projectid: projectid, jobid: jobid }, configuration: { load: { sourceformat: 'newline_delimited_json', destinationtable: { projectid: projectid,

java - Deserialization with gson when JSON no have variable names -

i have json bellow: { "0001":[111, "blabla", "lala", "kkk",80,20], "002":[222, "blabla", "lala", "kkk",80,40], "003":[333, "blabla", "lala", "kkk",100,20], "000":[444, "blabla", "lala", "kkk",800,60], "555":[555, "blabla", "lala", "kkk",80,20, "100":[48, "blabla", "lala", "kkk",80,20] } i'm having trouble gson deserialize. know work json have variable names defined below: { "item":"001":["id":1,"description":"bla bla"], "item":"002":["id":2,"description":"bla bla"] } then defined class same variable names of json , execute parse public class dataclass { string item; int id; string description; ge

asp.net - What will be the Sql Query to compare the value of two hyperlinks bounded within the item template of Reapeter? -

i have having repeater(repeater1) , hyper link , repeater(repeater2) in item template of repeater(repeater1).then repeater2 contain hyperlink. hyperlink of repearet1 category , hyperlink of repeater2 subcategory. as shown code <ul class="categories" id="categoryheader"> <li id="categoryitem"> <h4>categories</h4> <ul class="categories" id="categorylist"> <asp:repeater id="repcategories" runat="server" onitemdatabound="repcategories_itemdatabound"> <headertemplate> <ul> </headertemplate> <itemtemplate> <li> <asp:hyperlink id="hypercategories" runat="server"><%#eval("categoryname")%></asp:hyperlink>