Posts

Showing posts from April, 2012

ruby on rails 3 - Following rspec exception handling, getting 'NoMethodError' for 'expect' -

confused why rspec method isn't working. looking @ answer here: how use rspec's should_raise kind of exception? , have tried combinations proposed reason, i'm still getting nomethoderror. here exception exception encountered: #<nomethoderror: undefined method `expect' #<class:0x007fa5bd8e4120>> here method: describe "admin should not accesible" expect { user.new(name: "example name", email: "email@example.org", password: "foobar", password_confirmation: "foobar", admin: "true") }.should raise_error(activemodel::massassignmentsecurity::error) end i got error earlier know method doing want do: 1) user admin should not accesible failure/error: hey = user.new(name: "hello", email: "hey@hey.org", password: "foobar", password_confirmation: "foobar", admin: "true") activemodel::massassignmentsecurity::error: can't mass-assign protected attribute...

powershell - select -first 1 on a large file -

i trying run following command on large text file. however, it's slow ((cat largefile.txt | select -first 1).split(",")).count() is alternative fast way in powershell? seems command scan whole file no matter what. to first x number of lines in text file, use –totalcount parameter: ((get-content largefile.txt -totalcount 1).split(",")).count

c# - OpenGL Multidimensional Array Penalties -

i've been trying decide best way store information in vbo's opengl. i've been reading how matricies stored single-dimensional arrays because of performance penalties of using multi-dimensional arrays. i wondering, extend storing information in vbo's? make more sense store vertex information within vbos in single or multidimensional arrays? before bunch of answers saying depends on i'm storing, i'm talking things traditionally considered multidimensional arrays (maps, grids, etc....). what type of performance hits looking @ using multidimensional arrays if any? the question invalid, makes no sense. buffer objects blocks of memory stored , managed opengl. it's not c# array or c# multi-dimensional array. it's block of memory transfer data into. the vertex data put buffer object must conform glvertexattribpointer allows. how achieve in c# , whatever api use.

BigQuery: Dataset "Not Found" on table load with REST API -

i trying load csv file bigquery using python script modelled on python sample code here: https://developers.google.com/bigquery/docs/developers_guide but i'm running following error when try load table rest api: {'status': '200', 'content-length': '1492', 'expires': 'fri, 01 jan 1990 00:00:00 gmt', 'server': 'http upload server built on jun 14 2012 02:12:09 (1339665129)', 'etag': '"tcivyoj9qvkabuej5memf9we85w/-mxyhudjvvydxcebr8fxi6l_5rq"', 'pragma': 'no-cache', 'cache-control': 'no-cache, no-store, must-revalidate', 'date': 'fri, 06 jul 2012 22:30:55 gmt', 'content-type': 'application/json'} { "kind": "bigquery#job", "etag": "\"tcivyoj9qvkabuej5memf9we85w/-mxyhudjvvydxcebr8fxi6l_5rq\"", "id": "firespotter.com:firespotter:job_d6b99265278b4c0da9c3033acf39d6b2",...

android - How do I detect if a touch event has landed within an EditText? -

i can find getx(), , gety() both return float. how detect if coordinates of touchevent e.get(), e.gety() within boundaries of edittext ui element? notice getx() , gety() floats getheight(), , getwidth() int. not going comparisons ... what want do? if want detect if edittext touched, add ontouchlistener edittext... or onclicklistener. edit: if want detect outside, can detect touch event in containing view, , then, given have edittext view: rect edittextrect = new rect(); myedittext.gethitrect(edittextrect); if (!edittextrect.contains((int)event.getx(), (int)event.gety())) { log.d("test", "touch not inside myedittext"); } or add touch listener both edittext , container, , return false in 1 of edittext, way intercepted , not forwarded parent. so, touches detect in listener of parent, not belong edittext.

php - json decode and encode - iterate through multi dimensional array and remove key value if equals certain value -

basically json output -output php. [{"attr":{"id":"node_2","rel":"default"},"data":"c:","state":"closed"},{"attr":{"id":"node_3","rel":"drive"},"data":"d:","state":"closed"}] so because rel equal default {"attr":{"id":"node_2","rel":"default"},"data":"c:","state":"closed"} i need remove array. i have thought of maybe using foreach($arr $key => &$item) { if ($value['rel'] == 'default'{ unset($arr[$key]); this however, wont work reason. have no idea if method best way, or whether there better way achieve this. need decode , encode it. you can use json_encode , json_decode parse json jesse bunch said. after decoded json posted, returned object. call on object have things bit diffrent. $a...

php - why can't I overlay text on the bottom part of the page using fpdfi? -

background: i'm developing application involves taking existing pdf form , overlaying text on top of it. pdf version 1.3. i'm using fpdfi class (written in php) can found here: http://www.setasign.de/support/manuals/fpdi/ i using fpdfi extension of tcpdf class found here: http://www.tcpdf.org/index.php i use line of (php) code looks this: $this->setxy(25, 250);$this->cell(0, 8.6, $data['my_data_to_overlay']); where $this refers instance of fpdfi class, setxy function tells coordinates wish place text (x,y), , cell function tells text want displayed , how large , such. page height 279.4 (all units here in mm) the problem: if set y coordinate higher 250 (even @ 251), text placed on next page instead of near bottom of current page expected. other coordinates above line @ 250 display properly, @ top edge of page. why can not overlay text near bottom of page? doing wrong? also of note: margins page set 0 , headers , footers disabled. disable auto page br...

java - Signing data in Android and Verifying it in python -

i have written following code sign data in android: import java.security.keyfactory; import java.security.keypair; import java.security.keypairgenerator; import java.security.privatekey; import java.security.publickey; import java.security.signature; import java.security.spec.rsapublickeyspec; import android.app.activity; import android.os.bundle; public class testactivity extends activity { /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); try{ string m ="this message"; system.out.println(m); keypairgenerator keypairgen = keypairgenerator.getinstance("rsa"); keypairgen.initialize(1024); keypair kp = keypairgen.generatekeypair(); privatekey prikey = kp.getprivate(); publickey pubkey = kp.getpublic(); keyfactory keyfactory = keyfactory.getinstance("rsa"); rsapublickeyspec publickeyspec = keyfactory.getkeyspec(pubkey, rsapublickeyspec.cla...

What physical characteristics would be suited for android's OS to run smoothly? -

do think smartphone characteristics able stand android os? - 100 mb storage - -64 mb ram - processor pnx-4910 ////edit--_ old version/ stable version?? android 2.1+ requires @ least 92mb of ram. see: http://static.googleusercontent.com/external_content/untrusted_dlcp/source.android.com/en/us/compatibility/2.1/android-2.1-cdd.pdf so hope pre 2.1 version. theoretically, might able 1.6 or earlier work on it, arm926 chip inside pnx-4910 not going withstand whole lot of load.

qt - How to compile the header file with Q_OBJECT macro in Xcode? -

i create c++ project in xcode links against qt framework. hello world program works well. when add class derived qobject , add q_objcet macro, there link error. the class myobject.h #ifndef myobject_h #define myobject_h #include <qtcore/qobject> class myobject : public qobject { q_object public: myobject(); }; #endif myobject.cpp #include "myobject.h" myobject::myobject() { } i know should use moc compile myobject.h first , add generated moc_myobject.cpp xcode project. in microsoft visual studio, can configure header file compiled moc custom tool. , add generate cpp file vs project. but xcode. question is: there equivalent mean in xcode compile header file including q_object macro? here's how in xcode 6: select target , in build rules make new custom rule. set "process" drop down "source files names matching" , type in *.h next that. set "using" drop down "custom script:" , in script type close this: /path/to/...

php - dynamic Page control in codeigniter -

in ci project, use full dynamic page control. so, i̢۪ve 2 controller methods, load php files. model control̢۪s queries based on url segments. page output generated automatically in views php file depending on url , results of database, except index.php file. is right way? controller public function index() { $data['title'] = "index"; $data['nav'] = $this->content_model->get_index_nav(); //todo $this->load->view('templates/header', $data); $this->load->view('templates/nav', $data); $this->load->view('templates/nav_pict', $data); $this->load->view('pages/aktualis', $data); $this->load->view('templates/footer', $data); } public function view($page) { $page = 'content'; $this->load->helper('text'); $this->load->helper('url'); $page = lcfirst(convert_accented_characters(urldecode($page))); if ( ! file_exists('application/views/pages/'.$page....

Does the order of expressions or predicates make any difference in the join condition for outer joins in standard SQL? -

so i'm having bit of frustrating day. fired contract had been working past few weeks because did not "mesh team." 2 examples cited: 1) yesterday asked delete data sql server database except baseline system data. requestor (not boss) had 8 scripts had used task few months ago. apparently no 1 has ever thought script out data model or system data. this person had established pattern of over-complicating things, trying understand reasons task , end goal. struggled understand why got sorts of vague errors required these scripts "remove , re-add constraints". i quite willing necessary , talked several minutes it. obvious reasons thought seeking understand why thing. decided faster herself rather spend time explaining me , went other work without thinking more it. somehow interpreted negatively. 2) several weeks ago during first week asked work on merging data system. given 600+ line script of sql snippets appeared important along oral tirade of complaints poo...

stl - C++ List of objects are only copies -

i find myself needing keep 2 lists of objects performance reasons (speed on memory). i'm using object pointers such as std::list<myclass*> m_list1; std::list<myclass*> m_list2; i add objects list by myclass* myobject = new myclass(); m_list1.push_back(myobject); m_list2.push_back(myobject); the problem i'm facing changes make m_list1 not affecting m_list2 , copies , not real deal. what correct way store these won't copies? not using pointers isn't option these allocated on heap. std containers copy values passed in, since passed in pointers, pointers copied. therefore still pointing same object. problem must somewhere else. perhaps post specific code think exhibiting behavior?

objective c - UITableView reloadData causes UITextField to resignFirstResponder -

i have textfield set change tableview's datasource each letter that's entered (and call reloaddata). but reason, every time letter entered, keyboard dismissed. anyone know why? your text field resigning because reloaded cells sent -resignfirstresponder message due fact survival not guaranteed after reload. see related question more.

validation - violation of "Unique Particle Attribution" -

when want validate xsd file, got error cos-nonambig: "my xsd file":layout , "my xsd file":layout (or elements substitution group) violate "unique particle attribution". during validation against schema, ambiguity created 2 particles. and refers me tag <xs:complextype name="pagetype"> <xs:choice> <xs:element type="main:layouttype" name="layout" minoccurs="0" maxoccurs="1"/> <xs:group ref="main:widgetsgroup" maxoccurs="unbounded" minoccurs="0"/> </xs:choice> <xs:attribute type="xs:string" name="name"/> <xs:attribute type="xs:string" name="layout"/> <xs:attribute type="xs:string" name="datamodel"/> <xs:attribute type="xs:string" name="domain"/> </xs:complextype> what problem? , how fix it? i've solved inserting widgetgroup content...

jsp - How to get Data from Mysql to be in Value of text in servlet -

how data mysql in value of text in servlet i try code not working while(rs.next()){ out.println("<form action=\"userpage\" method=\"post\">" + " <input type=\"text\" name=\"id_customer\" value=\"<%=rs.getstring(1)%>\">" + "</form>"); } you should have create separate view (.jsp) instead of producing dynamic content of html in servlet . first of create list<t> represent database result in servlet or model class , assign list object request (request scope) via request.setattribute() method. public class customer { private int id; ..... public void setid(int id) { } public int getid() { return id;} } in servlet, list<customer> listofcustomer=new arraylist<customer>(); //code populate listofcustomer database request.setattribute("list",listofcustomer); request.getrequestdispatcher("/show.jsp").forward(request,response); the view sho...

uiimageview - Put UILabel text inside a tooltip-like UIImage -

Image
i have been searching various ways put text on image. tried things this already, shows label separate object along image. i want text on image (something transparent label text visible, don't know how objective c it). this because image talking custom tooltip, , text variable, can't statically put there. uiimageview - put uilabel text inside tooltip-like uiimage - stack overflow stack overflow questions developer jobs documentation beta tags users current community help chat stack overflow meta stack overflow communities sign up or log in customize list. more stack exchange communities company blog tour start here quick overview of site center detailed answers questions might have meta discuss workings , policies of site learn more stack overflow company business learn more hiring developers or posting ads log in sign up learn, share, build eac...