Posts

mysql - Ruby on Rails maximum weird results -

i doing simple call here , i'm unsure why results erratic. foo.maximum('bar') bar looks this |bar | |----- |16 | |5 | |2 | |10 | |7 | |8 | |10 | |9 | i expect call respond maximum value 16. thing noteworthy in respect these values are, because have no way of knowing if going come in int or float, strings. getting max of character value rather numbers themselves? if can't alter database , need deal strings, in ruby instead. however, may expensive if foo table has ton of stuff in it: foo.select("bar").collect{|foo| foo.bar.to_f}.max or if wanted avoid instantiating bunch of activerecord objects, above code selecting single field: activerecord::base.connection.query("select bar foo").collect{|foo| foo.first.to_f}.max

Posted data variables not being saved by PHP script -

i'm (junior) pen tester , i'm trying make script demonstrate dangers of xss attack client. i've got php script meant log user:pass combos when victims (i.e. myself in demo) redirected malicious page i'm hosting. this part of source login: <input type="text" id="form_login_username" name="form[login][username]" value="" class="large" /> <input type="password" id="form_login_password" name="form[login][password]" value="" class="large" /> i'm new php might basic that's cause problem. here php script log details: <?php $filename = "login_details.txt"; $username = $_post["form[login][username]"]; $password = $_post["form[login][password]"]; $fh = fopen($filename, "aw") or die("cannot open file"); fwrite($fh, $username . ":" . $password . "\r\n"); fclose($fh); wi...

php - Delete several row together-array -

i want delete several row foreach , have output bool(false) not array following code. how fix it? <input type="checkbox" name="checked[]" value="1"> function delete_test() { $delete = $this->input->post('checked'); if (is_array($delete) && count($delete) > 0) { foreach ($delete $val) { $this->db->query("delete hotel_units relation '$val'"); } var_dump($delete); echo "<br>is array"; } else { var_dump($delete); echo "<br>not array"; } // output is: bool(false) not array } i can guess $this->input->post means, if checkbox called 'checked[]' need $post: $this->input->post('checked[]');

floating point - Python array multiply -

hh=[[82.5], [168.5]] n=1./5 ll=n*hh what i'm doing wrong? received error : "can't multiply sequence non-int of type 'float'" i try add float(), not solve problem; i need multiply each element in array... all **ok idea number * array, how multiply array*array, tried same number*array, have problems: edit 2:** hh=[[82.5], [168.5]] n=zip(*hh) ll = [[x*n x in y] y in hh] ??? when multiply sequence x in python, doesn't multiply each member of sequence - repeat sequence x times. that's why x has integer (it can't float). what want use list comprehension: hh = [[82.5], [168.5]] n = 1.0 / 5 ll = [[x*n x in y] y in hh]

visual studio - VS2010 - 2 projects, 1 solution - debug both under 1 instance -

what want can't unusual. in solution, have mvc3 project , webforms project. mvc3 project meat & potatoes of application- it's user interact with. 2nd project going shared "content delivery" project. it'll shared many projects. there nothing in says has webforms, it's meant static css/js/images. on top of that, i'd use built-in vs.net development server. i have tried variety of things: setting mvc project start-up project , without "always start when debugging" property set true/false ( result: can't access files in /webforms project ) setting multiple start-up projects ( result: 2 instances of development server run on different ports ) setting webforms project reference main mvc project( result: can't access files in /webforms project ) setting virtual path under properties --> build webform project ( result: can't access files in /webforms project ) my goal to: keep these 2 separate projects when run mvc ...

Multithreaded Proxy Server implemented in java -

i implementing multithreaded proxy server in java accept messages clients , forward them server acknowledge reception of message. however, i'm having trouble doing so. point out doing wrong? thanks. proxyapp: public class proxyapp { public static serversocket server = null; public static socket client = null; public static void main(string[] args) { try { server = new serversocket(6789); socket clientsocket = null; while(true) { client = server.accept(); if(client.isconnected()) { system.out.println("proxy listening client on port 6789"); } thread t1 = new proxyhandler(client); t1.start(); clientsocket = new socket(inetaddress.getlocalhost(), 6780); if(clientsocket.isbound()) { system.out.pri...

c# - Posting to a REST webservice from .NET? -

i trying hit web service using instructions here: http://help.seeclickfix.com/kb/api/creating-an-issue i came code below: string paramcontent = "api_key=afs684eas3ef86saef78s68aef68sae&issue[summary]=abetest&issue[lat]=39.26252982783172&issue[lng]=-121.01738691329956&issue[address]=111 abe st., nevada city, ca"; byte[] parambytes = encoding.utf8.getbytes(paramcontent); httpwebrequest req = (httpwebrequest)webrequest.create("http://seeclickfix.com/api/issues.xml"); req.method = "post"; req.contentlength = parambytes.length; //req.contenttype = "application/x-www-form-urlencoded"; using (stream reqstream = req.getrequeststream()) { reqstream.write(parambytes, 0, parambytes.length); } using (httpwebresponse resp = (httpwebresponse)req.getresponse()) //here! { if (resp.statuscode != httpstatuscode.ok) ...