Posts

Showing posts from March, 2013

javascript - Observe every rendering (even conditionals) in EmberJS -

i want function running after rendering in emberjs has happened (globally), after "switch" in {{#if}}-{{else}}-block. subscribing render event with ember.subscribe("render", { before: function (name, timestamp, payload) { }, after: function (name, timestamp, payload) { // function call } }); works quite not called after rerendering via if-else-switch. so want listen rendering globally , noticed @ end of it. best regards martin

c++ - OpenCV: can projectPoints return negative values? -

i'm using cv::projectpoints correspondent pixels of vector of 3d points. the points near each other. the problem points correct pixels coordinates other strange negative values -22599... is normal cv::projectpoints return negative values or bug in code? void singlecameratriangulator::projectpointstoimage2(const std::vector< cv::vec3d >& pointsgroup, const double scale, std::vector< pixel >& pixels) { cv::vec3d t2, r2; decomposetransformation(*g_12_, r2, t2); cv::mat imagepoints2; cv::projectpoints(pointsgroup, r2, t2, *camera_matrix_, *distortion_coefficients_, imagepoints2); (std::size_t = 0; < imagepoints2.rows; i++) { cv::vec2d pixel = imagepoints2.at<cv::vec2d>(i); pixel p; p.x_ = pixel[0]; p.y_ = pixel[1]; if ( (p.x_ < 0) || (p.x_ > ((1 / scale) * img_1_->cols)) || (p.y_ < 0) || (p.y_ > ((1/scale) * img_1_->rows))) { cv::ve

python 2.7 - Is there a way to go back and edit the information the user entered? -

i have simple code written in python 2.7 ask users information, , exports information .csv file. once user inputs data, there way them go , edit entered after pressing enter? here have far: def writer(): import csv open('work_order_log.csv', 'a') f: w=csv. writer(f, quoting=csv.quote_all) while (1): correct=true employee=true workorder=true item=true qty=true process=true date=true time=true while correct: correct=false employee=false workorder=false item=false qty=false process=false date=false time=false employee=raw_input("1. enter name:") workorder=raw_input("2. enter work order number:") partnumber=raw_input("3. enter item number:") qty=raw_input("4. enter quantity:") process=raw_input(

java - Can able to view httpservletrequest data in browser tools? -

is there way see data getting through httpservletrequest in browser tools ? firebug or chrome dev tools ? httpservletrequest.getservletrequest().getheader("email"); i'm getting null values , application guy saying there data passing , i'm not getting data. see data in browser, because http. i have check system.out.println()... eventhough way ? thanks the httpservletrequest object never directly accessible client (all of java code executes server side). either use solution @sotirios delimanolis described in comments, or add temporary server-side code write relevant information httpservletrequest output. there no other way access object client-side. have rely on information being sent client (e.g. looking @ headers in wireshark), or send information client explicitly (explicitly format , write output). added: if don't want clutter page debugging info, can generate dump comments in html, or generate javascript directly prints messages js

Grails 2.2.4 + webflow: method name must not be null -

after upgrade grails 2.2.1 2.2.4, have following error dealing webflow redirect action: method name must not null. stacktrace follows: java.lang.illegalargumentexception: method name must not null @ org.springframework.util.assert.notnull(assert.java:112) @ org.springframework.util.reflectionutils.findmethod(reflectionutils.java:151) @ grails.plugin.cache.web.proxyawaremixedgrailscontrollerhelper.retrieveaction(proxyawaremixedgrailscontrollerhelper.java:41) @ org.codehaus.groovy.grails.web.servlet.mvc.abstractgrailscontrollerhelper.executeaction(abstractgrailscontrollerhelper.java:226) @ grails.plugin.cache.web.proxyawaremixedgrailscontrollerhelper.executeaction(proxyawaremixedgrailscontrollerhelper.java) @ org.codehaus.groovy.grails.web.servlet.mvc.abstractgrailscontrollerhelper.handleuri(abstractgrailscontrollerhelper.java:197) @ grails.plugin.cache.web.proxyawaremixedgrailscontrollerhelper.handleuri(proxyawaremixedgrailscontrollerhelper.java) @

html - Grouping elements in css and displaying one below other -

i need id3 displayed below id2 instead of being displayed on side? how can accomplish in using css? html <div class="main" ></div> <div id="id1">im in div1</div> <div id="id2">im in div2</div> <div id="id3">im in div3</div> <div></div> css #id1{ background-color:green; width:30%; height:200px; border:100px; float:left; } #id2{ background-color:red; width:20%; height:100px; border:100px; float:left; } #id3{ background-color:yellow; width:10%; height:300px; border:100px; float:left; } http://jsfiddle.net/w9xpp/ the best way not use floats. reason use them make things horizontal other things. if want things fit puzzle, @ masonry.js

python - Making a list in user-defined functions -

i'm trying understand error of: float object has no attribute here simplified version of code: def apple(): = input("first: ") b = input("second: ") list1 = [0..a]; list2 = [0..b]; print list1, list2 here how error given >> apple() >> attributeerror: 'float' object has no attribute 'a' since poster asked error specifically: i believe in line list1 = [0..a]; the python interpreter takes expression 0..a , , parses float 0. followed call a attribute of 0. , dot means in context. as has been mentioned already, create range, use range(0, int(a)) instead.

c - Memory questions and functions -

hope you're having great summer! i'm revising exams , have come couple of questions on past paper stuck , appreciate help/explanation can provide! :) here questions; 1.) function power() should implement function n* 2^p (the output of printf() line should 5*(2^2) = 20 ). complete body of function power() using shift operator. why sensible use shift operator instead of available power function in math.h ? #include <stdio.h> int power(int n, int p) { << code goes here >> } main () { printf("%d*(2^%d) = %d\n",5,2,power(5,2)); } 2.) memory organized in regions called text, data, stack , heap. program below defines variables a , b , c . in memory region content of each variable reside? #include <stdio.h> #include <stdlib.h> int = 5; int func1(int x) { int b=5; } main { char * c; c = (char*) malloc (a+1); func1(a); return 0; } i have couple more questions ask see how these goes! i've n

android - Making an ImageView inside my PagerAdapter go fullscreen - How to? -

i'm testing app sort of gallery managed create using pageradapter can't make images show on fullscreen. here screenshots: view1 on screen http://imgur.com/tvvfs2v , transition view1 view2 http://imgur.com/h6rhxfn what want remove white borders , action bar, make image fullscreen. here's code: sstest.java package com.exp.viewpagersstest1; import android.app.activity; import android.os.bundle; import android.support.v4.view.viewpager; import android.view.menu; public class sstest extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_sstest); viewpager ssviewpager = (viewpager) findviewbyid(r.id.ss_view_pager); imageadapter ssadapter = new imageadapter(this); ssviewpager.setadapter(ssadapter); } @override public boolean oncreateoptionsmenu(menu menu){ // inflate menu; adds items action bar if

Compiling Objective-C on Linux -

this question has answer here: ide objective-c on linux 4 answers game programming on objective-c , linux 4 answers how can program in objective-c under linux? there compiler or ide avaiable allows me program in language? there's great website called gnustep . have api's objective c on linux. download & installation instruction page here . yes, question duplicate way. check links provided josh caswell above find more detailed answers.

How do I inherit from a generic class in java? -

i have class following public class foo<idtype extends writablecomparable<idtype>, edata extends writable> { public foo(); public foo(idtype foo; idtype bar){ this.foo = foo; this.bar = bar; } private idtype foo; private idtype bar; } now 1 of usage of class following: elist = new arraylist<foo<stringtype, emptytype>>(); so works fine: now want extend class add 1 more field private string foobar; now, instance of have 3 fields. two of them foobar.foo //base class foobar.bar //base class foobar.foobar // new variable added now, usage still same: elist = new arraylist<foobar<stringtype, emptytype>>(); i tried simple extension: public class foobar extends foo{ private string foobar; public foobar(string foobar){this.foobar = foobar;} } but when use i error: elist = new arraylist<foobar<stringtype, emptytype>>(); arraylist<foobar><stringtype,emptytype>> cannot

iphone - Scroll position in Text View object on detail view doesn't reset when returning -

i have information in master view uses uitableview object , detail viewcontrailer comes after push user selection it. my challenge scrolling in uitextview object, doesn't go top of scrolling area on detail view. the user chooses detail object list in master view controller, , brings in detail viewcontroller. scrolls within uitextview object - dogscrollinginfotextview- on view, going farther down upper lines don't show anymore. return master view controller, , selects different row. upon returning detail view, new object's uitextview object (dogscrollinginfotextview) still positioned previous view left it. the object being passed uitextview in detailviewcontroller, looks in master view controller self.detailviewcontroller.dogscrollinginfo = dog.whatmakesdogspecial; in original class definition, property declared this @property (strong, nonatomic) nsstring *whatmakesdogspecial; the object used transfer within detailview controller class view declared this

php - Password reset email html -

i want send email user when he/she forgets password. email should have link page user can enter new password. link send them? mean should put username parameter in url , if how can hide parameters displaying in url. know there other questions have answers couldn't understand them. new programming. help. i using random generated string, let 32 characters long, generated , saved in database, in users table, have column called notaproved. send e-mail user link in witch 32 chars string parameter. engine under link takes string, searches database same , resets password, sets notaproved 0. use same field permission indicator if e-mails has been confirmed when user have registered.

hibernate - HQL insert ... select with parameters -

i need execute batch insert select statement: query query = em .createquery( "insert entitya (a,b,entity_field) select t.a, t.b, :entity_field entitya t ..."); query.setparameter("entity_field ", entity); field entity_field not primitive type in entitya getting java.lang.illegalargumentexception: org.hibernate.queryexception: number of select types did not match insert. is there way that? when put in select field not primitive type it's decomposite in properties. have query this: insert (a, b, entity_field) select t.a, t.b, entity_field.field1, entity_field.field2,...., entity_field.fieldn when insert put primary key of entity, can use primitive type. i hope, clear ;) have nice day

Java- Adding unique values to Hashmap -

ok, here issue....i have list<short>letterlist has example: "1,2,3,4,5,6,7,8,9,10" what im doing im iterating on list passing value method returns value: so: string value = null; for(short foo : letterlist) { value = getsomevalue(foo) //returns letter or b or c } what im trying hashmap this: key: a, value 1,5,7 key b, value: 2,3,4 key c, value: 6,8,9,10 not these values specifically, point im not sure how have tried creating map <set<string>, list<short> any suggestions appreciated java has no built-in multimap, can either simulate multimap ( map<string, list<short>> ) or try out guava example: https://code.google.com/p/guava-libraries/

Windows Azure mobile services, server side scripts: data -

i have added tables database in in windows azure via entity framework not able access these tables through server side scripts (mobile services custom api)and not appear through "mobile services: data" section. have add these tables , set permissions on them manually though portal access these via scripts etc? sure there documentation on somewhere have been chasing tail trying find it. the table appears there todoitem table created default. a bit of direct on great you need move schema of mobile services app , add tables, see: http://blogs.msdn.com/b/jpsanders/archive/2013/05/24/using-an-existing-azure-sql-table-with-windows-azure-mobile-services.aspx

asp.net - Custom sort file name string array -

i'm retrieving string array of files , custom sort them substring in file name...using c# **.net 3.5. below working with. <% string[] files = system.io.directory.getfiles("...path..." + pagename + "\\reference\\"); files = string.join(",", files).replace("...path...", "").replace("\\reference\\", "").replace(pagename, "").split(new char[] { ',' }); foreach (string item in files) { response.write("<a href=" + pagename + "/reference/" + system.io.path.getfilename(item) + " target='_blank'>" + item.replace("_", " ").replace(".pdf", " ") + "</a>"); } %> i'm c# noob, , don't know go here. basically, i'm looking substring in file name determine order (e.g., "index",&quo

php - How to retrieve parameters from url with a '.' -

i trying retrieve user's email address after have logged in google via openid. the url is: 00.000.000.000/loginwithgoogle.php?openid.ns=http%3a%2f%2fspecs.openid.net%2fauth%2f2.0&openid.mode=id_res&openid.op_endpoint=https%3a%2f%2fwww.google.com%2faccounts%2fo8%2fud&openid.response_nonce=2013-08-12t20%3a52%3a27zozizkca486sfiq&openid.return_to=http%3a%2f%2f24.255.213.250%3a50005%2floginwithgoogle.php&openid.invalidate_handle=absmpf6dnmw&openid.assoc_handle=1.amlya9xt63izbhulzg8cil5xkie9bfgiv6dq_5xbjhzqjvnh4h5yrm4l2hstrxyj&openid.signed=op_endpoint%2cclaimed_id%2cidentity%2creturn_to%2cresponse_nonce%2cassoc_handle%2cns.ext1%2cext1.mode%2cext1.type.email%2cext1.value.email&openid.sig=xk06wakpupdu4jvglz0v%2f1ztmza%3d&openid.identity=https%3a%2f%2fwww.google.com%2faccounts%2fo8%2fid%3fid%3daitoawm70uatpuqujkll10schqjgxveppfsmi48&openid.claimed_id=https%3a%2f%2fwww.google.com%2faccounts%2fo8%2fid%3fid%3daitoawm70uatpuqujkll10schqjgxvep

objective c - NSManagedobject copywithzone unrecognised selector -

i have got error thrown on runtime in line of code: [numberformatter setcurrencysymbol:[theobject valueforkey:kfieldcurrency]]; kfieldcurrency constant defined follows: #define kvaluecurrency @"currency" printing value of theobject provides output: printing description of theobject: <nsmanagedobject: 0x7836bf0> (entity: customvalue; id: 0x78373d0 <x-coredata://84240925-2d7d-485e-ad9d-8dd48f602c00/customvalue/p5> ; data: { contract = "0x78e4a20 <x-coredata://84240925-2d7d-485e-ad9d-8dd48f602c00/contract/p3>"; currency = "0x7839810 <x-coredata://84240925-2d7d-485e-ad9d-8dd48f602c00/currency/p5>"; datetimevalue = nil; ischangeablebyuser = 1; islisted = 1; listname = geldwert; numvalue = 10; numberofdigits = 0; stringvalue = nil; tagname = geldwert; type = 5; }) the error message is: -[nsmanagedobject copywithzone:]: unrecognized selector sent instance 0x7c1c930 a

Use chrome.storage in script loaded by webrequest blocking -

hello, have problem extension. block script webrequest.onbeforerequest when trying use chrome.storage console return error uncaught typeerror: cannot read property 'local' of undefined my code: background.js chrome.webrequest.onbeforerequest.addlistener( function(details) { if( details.url == "http://o1.t26.net/js/application.js?2.0.4" ) return {redirecturl: chrome.extension.geturl("load.js") }; }, {urls: ["http://o1.t26.net/*.js?2.0.4"]}, ["blocking"]); load.js chrome.storage.local.get('test', function (h){ console.log(h.test); }); manifest.json { "content_scripts": [{ "matches": [ "http://www.agust.in/*", "http://agust.in/*" ], "js": ["test.js"], "run_at": "document_start", "all_frames": true } ], "description": "test", "icons": { "16": "icon_one.pn

map - Best approach for redrawing weighted 2-D graph when weights change (MDS maybe)? -

i'll try describe problem simplest possible. assume have map plot points cities within map. cities connected line segments representing roads, there's graph line segments represent euclidean distance each road (these original weights). i need make new graph line segments representing actual road lengths (new weights), while trying as possible keep original geometry unmodified. i'm thinking metric multidimensional scaling way go, maybe there's simpler.

javascript - How to get index (or value) of DropDownButton selection -

i have downdownbutton i've populated array containing project names , ids. list shows project name, i'd project id. variable "projects" looks this: [object { name="project a", id="1325"}, object { name="project b", id="5241"}, object { name="project c", id="3224"}] this code creates menuitem button correctly, how set variable projid in onclick event? for (i = 0; < projects.length; i++) { menuprojects.addchild(new menuitem({ label: projects[i].name, onclick: function () { projid = ?; } })); } i've tried using "projid= projects[i].id;", gives me error since 3. what's correct syntax this? -- edit -- this how got work using both cookie's , merrick's answers. for (i = 0; < projects.length; i++) (function (x) { menuprojects.addchild(new menuitem({ label: projects[i].name, onclick:

Git Branch Bash Variable Shortcut -

i trying create bash variable can use refer current branch in git: $branch. when adding: branch=$(git symbolic-ref --short -q head) bash_profile , keep getting: fatal: not git repository (or of parent directories): .git when start new terminal. furthermore, echo $branch not print out branch name, git symbolic-ref --short -q head would. i'd able use not print out branch name (i have in prompt) things like: git push origin $branch which branch on depends on directory in. if have 2 git work trees, ~/a , ~/b , typing cd ~/a can put on 1 branch , typing cd ~/b can put on branch. so trying set $branch in .bash_profile isn't going work. need update $branch every time change work trees, , after command can change branch of current work tree. the simplest thing not set variable. instead, make alias: alias branch='git symbolic-ref --short -q head 2>/dev/null' and use this: git push origin $(branch) or if you're old-school: g

PHP MySQL connections -

is possible have 2 types of mysql connection on php page? currently there $link = mysql_connect , $mysqli = new mysqli connections accessed via 2 seperate include files in php. they both pull data down mysql database if both in same php page, second connection doesn't work. am missing obvious? mysql $link = mysql_connect("localhost", "root", "root", "abc"); if(!$link) { die('there problem connection database. please contact survey administrator.'); } mysql_select_db("root"); $query = "select * tresults"; $result = mysql_query($query); $total = mysql_num_rows($result); $query1 = "select * trespondent"; $result1 = mysql_query($query1); $total1 = mysql_num_rows($result1) - 1; $percent = number_format(($total * 100) / $total1); mysql_close($link); } mysqli $mysqli = new mysqli("localhost", "root", "root", "abc"); /* check connectio

functional programming - Receiving wrong data via TCP Erlang -

i'm trying receive data via tcp socket. when run code below output: localhost^v^a^@, aware need convert data if sending using binary, since sending list thought have been received same? why host string show correctly other data doesn't? any appreciated, thanks. cell_process(port, x, y)-> host = "localhost", data = [host,port,x,y], {ok, socket} = gen_tcp:connect(host, 22, [list, {packet, 0}]), ok = gen_tcp:send(socket, data), ok = gen_tcp:close(socket). server_process(clientlist)-> {ok, listening_socket} = gen_tcp:listen(22, [list, {packet, 0}, {active, false}]), {ok, socket} = gen_tcp:accept(listening_socket), case gen_tcp:recv(socket,0) of {ok,message}-> io:fwrite(message); {error,why}->io:fwrite(why) end. data = [host,port,x,y] is iolist,not list. gen_tcp:send convert data [<<"localhost">

php - Insert POST data to table and POST array to seperate table -

i trying submit data form 2 separate tables. here's error: inserts table 1 fine table2 array data goes database " array ". here fields going table1: $start = $_post['start']; $end = $_post['end']; $customer = $_post['customer']; $manufacturer = $_post['manufacturer']; $rep = $_post['rep']; $notes = $_post['notes']; my array fields going table2: item[] description[] pack[] any appreciated. below code have developed far: if ($start == '' || $end == '') { $error = '<div class="alert alert-error"> <a class="close" data-dismiss="alert">×</a> <strong>error!</strong> please fill in required fields! </div>'; } else { $sql = "sele

php - MySQL data does not appear in tooltip -

i want show mysql data inside tooltip. here code: <?php $abfrage = "select * tester"; $ergebnis = mysql_query($abfrage); while($row = mysql_fetch_object($ergebnis)){ $name=$row->name; $bech=$row->beschreibung; } ?> <a href="" title="<?=$name?> <?=$bech?>">test link</a> it shows me empty tooltip nothing inside. if print 2 variables, mysql data appear. there mistake in code? thanks. this in conjunction seth mcclaine's answer. echo values using: <?php echo $name; ?> <?php echo $bech; ?> instead of <?=$name?> <?=$bech?> the use of short tags not recommended this. reformatted code: <?php $abfrage = "select * tester"; $ergebnis = mysql_query($abfrage); $row = mysql_fetch_object($ergebnis); $name=$row->name; $bech=$row->beschreibung; ?> <a href="" title="<?php echo $

php - How to replace any thing between http:// and first slash / after http://? -

i got url string want replace between http:// , first slash / (in example want replace proxy-63.somesite.com video2.de.secondsite.net ). 1 tell me how can done ?thanks note: data between http:// , first slash after dynamic cant use replace function! http://proxy-63.somesite.com/sec(dfgghdfdgd987435392429324343241k)/video/600/500/12345678_mp4_h264_aac_2.m3u8 replaced : http://video2.de.secondsite.net/sec(dfgghdfdgd987435392429324343241k)/video/600/500/12345678_mp4_h264_aac_2.m3u8 the original url can different each time, preg_match find root. $url = 'http://proxy-63.somesite.com/sec(dfgghdfdgd987435392429324343241k)/video/600/500/12345678_mp4_h264_aac_2.m3u8'; preg_match('@^(?:http://)?([^/]+)@i', $url, $domain); $host = $domain[1]; $newurl = str_replace($host, 'video2.de.secondsite.net', $url); echo $newurl;

MySQL stored procedure return result before end of procedure -

is possible return result of select statement in stored procedure, before procedure done running? example: create procedure 'testproc'() begin //do stuff select 'column' table'; //do more stuff end is possible return result of select statement , have procedure keep doing it's thing afterwords? thanks what kind of stuff wanting keep doing after select? maybe insert select query temp table, continue doing other stuff, select @ end? temp table values still if returned mid routine still continue doing "other stuff." edit below comment: me should handled application doing following -break current stored procedure 2 parts call 1st insert stored procedure code takes first part of string , inserts database. return id application the application takes id received back, , calls second stored procedure(time consuming one) , passes 2 parameters. id , rest of string. the database continues rest of insert while application conti

php - Uncaught exception 'MongoException' with message 'Invalid object ID' -

i had php code working nicely, after updated mongo (2.4.4) , mongo driver php (1.4.2), code started generate fatal error. the line generates error one $something = new mongoid($some); it generates error: fatal error: uncaught exception 'mongoexception' message 'invalid object id' surely, can roll updates, there idea how can fix without rolling back? most error because of wrong $some providing. have pass correct mongoid new mongoid() constructor. so new mongoid('51e1eefc065f908c10000411') ok, new mongoid('-6') generate error. i using try catch handle this. try { $something = new mongoid($some); } catch (mongoexception $ex) { $something = new mongoid(); } so think this documentation little bit outdated , should changed.

c# - How do I add a loop to my code so the code keeps going until the user types '!'? -

i have no idea doing hard enough am. feel free correct code, me add loop or start on scratch. here's problem trying make console based application asks user type lowercase letter keyboard. if character entered lowercase letter, display “ok”; if not lowercase letter, display error message. program should continue until user types ‘!’. here's have far: if (char.islower(c)) { console.writeline("ok"); } else if (char.isupper(c)) { console.writeline("the character not lowercase letter."); } else if (char.isdigit(c)) { console.writeline("the character not lowercase letter."); } else { console.writeline("the character not lowercase letter."); } console.readkey(); this code should work. loop until user enters exclamation point. while (true) { var inputcharacter = console.readkey().keychar; if (inputcharacter == '!') { break; } if (char.islower(inputcharacter)) {

jquery - Viewing HTML of external pages -

what have far this: <!doctype html> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("button").click(function(){ alert($("p").html()); }); }); </script> </head> <body> <button>return content of p element</button> <p>test text</p> </body> </html> what display content of page. have html file looks this: <html> <head> </head> <body> <p>this text</p> </body> </html> how go viewing page's html? if alert part testing , you're trying grab element page 2 , display contents on page 1, can use $.load() . if on page 1 had: <p id="page1paragraph"></p> <script> $(document).ready(function() { $(

svn - TortoiseSVN: got warning message when update file -

i have used tortoisesvn check out source code server, today changed 1 file: theme.css on local computer, instead click commit , clicked update , afterwards, got warning message, exclamatory mark added on file: theme.css , , got 3 more files: theme.css.mine, theme.css.r3588, theme.css.r3656 , in theme.css , saw @ beginning there <<<<<<< .mine , , @ end there >>>>>>> .r3656 , happened here? , should now? this standard conflict handling svn, means file tried update has changes on conflicted version on server. adds <<<<< , >>>>> carots around areas in conflict. need use conflict merge tool (tortoisesvn comes 1 can download , use others if like). right click conflicted file , choose option edit conflicts, make edits resolve conflicts , save new final file doesn't contain conflict symbols.

recursion - Minimizing cheating of students -

given matrix of size m * n, place k students in such way cheating in exam minimized what thought : with brute force approach , create possible combination of students placements , return 1 minimum cheating score, while cheating score defined sum of manhattan distances between each 2 students. the time & space complexity of approach bad, better solution ? 1) geometric intuition -- perhaps try placing first 4 @ outer corners of square, spiral inwards there? this approx work "pythagorean distance", maybe can adapt "manhattan distance" equivalent of inward spiralling path & place students linearly along that. 2) or, place students sequentially @ next cheating-minima; then, once students placed, perturb locations achieve "overall minima". i 2) best approach.

Disable a PHP Plugin on mobile Screens with Code? -

i have plugin called "wp float", want disable when detects small screen size, lets smaller 400px. there line of php code can paste in 1 of plugin's files make happen? these files plugin: wp-float/wp-float(.)php wp-float/readme(.)txt wp-float/js/jquery.hoverintent.minified(.)js wp-float/js/jquery.easing(.)js wp-float/js/wp-float-button(.)js wp-float/js/jquery.floater.2.2(.)js wp-float/js/button-wpfloat(.)php what paste , in file? thanks as nicolas said, there's no way access client screen size on server side unless have sent information client side, javascript example. but, headers brings nice information. so, if you're looking disable for, let's say, mobile devices, can assume won't have big screen, can try reading headers of request browser's agent, lets say, in php: if (preg_match('/iphone|android|blackberry|nokia/i'),$_server['http_user_agent'])) echo "looks small screen device...";

c++ - How to read from input file (text file) and validate input as valid integer? -

i'm writing program needs read text file , check first line of text file number between 0 10. have come couple of solutions there still problem: how read file: const string filename= argv[1]; ifstream fin(argv[1]); if(!fin.good()){ cout<<"file not exist ->> no file reading"; exit(1); } getline(fin,tmp); if(fin.eof()){ cout<<"file empty"<<endl; } stringstream ss(tmp); first used atoi: const int filenum = atoi(tmp.c_str()); if(filenum<1 || filenum>10){ cout<<"number of files incorrect"<<endl; //exit(1); } if first line character, change 0 want call exception , terminate program. then used isdigit entry string , not work string. used each character in string still not work. stringstream ss(tmp); int i; ss>>i; if(isdigit(tmp[0])||isdigit(tmp[1])||tmp.length()<3) {} #include <iostream> #include <fstream> #include <

html - Drop Down Nav List -

i want drop down list top apear inline aswell in same place. if on over each list change text. http://868rcacs.ca/test.php right have drop down list working. when hover on admin list apear right below , not far left. there way fix without using individual classes or id's? add following styles: nav{ position:relative; } nav li ul { display: none; position: absolute; left: 10px; } this ensures layout doesn't break , want. don't forget thank me if works ;-) kidding!

Allow users to automatically forward statuses to facebook from Android app permently -

so have social app built android allows users post status updates (on service) , want give users ability have statuses forwarded facebook automatically similar how twitter allows automatically post tweets fb , after looking @ documentation , googling can find example of means post single spam-ish type status causes webview dialog pop every time. how 3rd party fb client apps pull off? (the ones @ bottom of post says "posted tweetdeck" ect.

ajax - Is there any way to update div according to failure and success of form remote in grails? -

i using form remote submit form. if data saved means want update list div. if failed means want refresh error div. there options in formremote of grails ? yes, formremote have options onfailure , onsuccess , oncomplete . <g:formremote name="savedata" url="[controller: 'book', action: 'byauthor']" oncomplete="jquery('#completedivid').html(data)" onsuccess="jquery('#successdivid').html(data)" onfailure="jquery('#failuredivid').html(data)"> ... </g:formremote>

database - import dump.sql file into postresql -

i new postgresql. have file name dump.sql. want import postgresql database. created database using create database_name . used psql database_name < /downloads/web-task/dump.sql . after running command shows not output. assume did not import dump.sql. how can import file postgresql db? we have determined in chat trying import dump.sql file within psql prompt, couldn't work... data imported.

datatable - Converting result of data table into tree using C# -

Image
i have dataset contains 4 columns. name, key, parentkey, level. need convert datatable tree structure. attaching image give idea want do. efficient way convert datatable object can use generate tree structure. please help. please note: data can come in order in datatable. possible sort datatable on first level column , on parentkey column? think, if can that, easy convert output tree structure. i have added class mimic dataset & have sorted data within datatable. namespace sortdatatable { public class program { private static void main(string[] args) { datatable table = new datatable(); table.columns.add("name", typeof (string)); table.columns.add("key", typeof (string)); table.columns.add("parentkey", typeof (string)); table.columns.add("level", typeof (int)); table.rows.add("a", "a1", null, 1); tab

codeigniter - The form get submit without login and select fields -

this first post. developed site http://careerzap.com in codeigniter , found there auto posting in site. don't know how stop this. url can check issue http://www.careerzap.com/ask/question/128 as can see by: , category: blank set these mandatory. means username , login required, , category select box can choose category in question post. you can post question here ... please me have no idea how stop this.. thanks nk

linux - How to Post Url in data of a curl request -

i trying post 2 parameters using curl. path , filename curl --request post 'http://localhost/service' --data "path='/xyz/pqr/test/'&filename='1.doc'" i know wrong in this. have use urlencode. tried many things still no luck. please give example how can post url in data of curl request. perhaps don't have include single quotes: curl --request post 'http://localhost/service' --data "path=/xyz/pqr/test/&filename=1.doc" update: reading curl's manual, separate both fields 2 --data: curl --request post 'http://localhost/service' --data "path=/xyz/pqr/test/" --data "filename=1.doc" you try --data-binary: curl --request post 'http://localhost/service' --data-binary "path=/xyz/pqr/test/" --data-binary "filename=1.doc" and --data-urlencode: curl --request post 'http://localhost/service' --data-urlencode "path=/xyz/pqr/test/&quo

loops - Python, if 'word' is in link print link else if '2ndword' in link print that one -

so have made python spider gets links given site , prints out 1 contains 'impressum' in itself. wanted make elif function prints out link contains 'kontakt' in istelf if 1 'impressum' not found in links. code looks this: import urllib import re import mechanize bs4 import beautifulsoup import urlparse import cookielib urlparse import urlsplit publicsuffix import publicsuffixlist url = "http://www.zahnarztpraxis-uwe-krause.de" br = mechanize.browser() cj = cookielib.lwpcookiejar() br.set_cookiejar(cj) br.set_handle_robots(false) br.set_handle_equiv(false) br.set_handle_redirect(true) br.set_handle_refresh(mechanize._http.httprefreshprocessor(), max_time=1) br.addheaders = [('user-agent', 'mozilla/5.0 (x11; u; linux i686; en-us; rv:1.9.0.1) gecko/2008071615 fedora/3.0.1-1.fc9 firefox/3.0.1')] page = br.open(url, timeout=5) htmlcontent = page.read() soup = beautifulsoup(htmlcontent) newurlarray = [] link in br.links(text_reg

php - Renew webpage when coordinates are received from android phone. -

i trying develop 1 project , need implement renew feature. try explain have in mind. user login members area , press button "get location", request coordinates send android phone. have done already. android phone send coordinates after time, these coordinates stored in server, mysql database. need refresh members area page new coordinates displayed. is there way implement this? if there is, give me directions should use?

php - Is it possible to change the default redirect message in Symfony? -

i'm using controller redirect users after have changed website's language. return $this->redirect($this->generateurl($_redirectto), 301); the problem is, message "redirecting /path/" shows up, don't want to. possible change message? the method controller::redirect() in fact, creating new redirectresponse object. default template hard-coded response here workarounds. in example, use twig template, hence need @templating service, can use whatever want render page. first, create template 301.html.twig acme/foobundle/resources/views/error/ content want. @acmefoobundle/resources/views/error/301.html.twig <!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="refresh" content="1;url={{ uri }}" /> </head> <body> redirected {{ uri }} </body>

c# - exception on accessing dictionary from list -

using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace test { class program { static void main(string[] args) { list<object> list = new list<object>(); list<dictionary<string, object>> dict = new list<dictionary<string, object>>(); dictionary<string, object> master = new dictionary<string, object>(); master.add("list", list); master.add("dict", dict); list<object> mydict = (list<object>)master["dict"]; // exception console.write("count: ", mydict.count); } } } it throwing exception on bold line. why behaviour , how shall access element? sumanth because there no list<object> under dict key var mydict = (list<dictionary<string, object>>)master["dict"];

jsf - Dialog element of primefaces not working -

i trying use dialog element of primefaces not working. have tried same code provided in primefaces site. code not working. <h:panelgrid columns="1" cellpadding="5"> <p:commandbutton id="basic" value="basic" onclick="pf('dlg1').show();" type="button" /> <p:commandbutton id="modaldialogbutton" value="modal" onclick="pf('dlg2').show();" type="button"/> <p:commandbutton id="effectsdialogbutton" value="effects" onclick="pf('dlg3').show();" type="button" /> </h:panelgrid> <p:dialog id="basicdialog" header="basic dialog" widgetvar="dlg1" appendtobody="false"> <h:outputtext value="resistance primefaces futile!" />

java - Using a char when creating a new object -

i have student class need have grade character when creating object. how write in object parameters? if use quotes thinks it's string, , if write grade a, thinks it's variable. parameters are: string name string adress integer birthdate integer age string course char grade string school student student1 = new student("john", "random street 1", 891117, 23, "java", a, "hig" ); chars wrapped within single quotes ' student student1 = new student("john", "random street 1", 891117, 23, "java", 'a', "hig" );