Posts

Showing posts from February, 2011

sqlite - Android: column '_id' does not exist -

i getting error illegalargumentexception: column '_id' not exist when using simplecursoradapter retrieve database, , table indeed have _id column. noticing common problem, have tried work around given of solutions online none of them work. cursor query: simplecursoradapter madapter = new simplecursoradapter(this, r.layout.quoterow, mycursor, new string[]{"_id", "quote"}, new int[]{r.id.quote}); although should mention original did not include _id column, added try , solve problem. has got ideas might solve problem? your database doesn't have have column called '_id' simplecursoradaptor need have 1 returned. can alias. an example have table columns... uid,name,number to query simplecursoradapter, database rawquery ... select uid _id,name,number my_table this works fine , supplies necessary '_id' column simplecursoradapter. edit: far understand _id field used unique key make sure data cursor handles ...

html - Responsive web design : "How to resize a background image according to browser window size using CSS"? -

i creating site products images re-size according browser window size i wrote media queries used 1 big image , re-sized in different window size but have 1 image used in background , how can re-size it? want support in browser in ie7 , 8. html <div></div> css div{ background: url("http://canadianneighborpharmacy.net/images/cnp/discount_20.png") no-repeat scroll 0 0 transparent; position:absolute; width:45px; height: 45px; } my live code here :- http://jsfiddle.net/jamna/ddxbq/19/ here have main "product image" resizing according browser window size(in fiddle didn't write code resizing product image yet,i showing image want resize ) have "save-money label" image in background of "span" want re-size simultaneously product image. for can use background-size property like : body{ background-size:cover; -moz-background-size:cover; -webkit-background-size:cover; } there other properties contain ...

iphone - Memory leak using class member -

i use class member called "soapresults" when connecting webservice. use parser parse xml results (it json result inside web service). - (void) parser:(nsxmlparser *) parser didstartelement:(nsstring *) elementname namespaceuri:(nsstring *) namespaceuri qualifiedname:(nsstring *) qname attributes:(nsdictionary *) attributedict { nsstring *attname = [[nsstring alloc]initwithformat:@"%@result",methodname]; if ([elementname isequaltostring:attname]) { if (!soapresults) { soapresults = [[nsmutablestring alloc] init]; } elementfound = yes; } [attname release]; } now soapresults retain member , released in dealloc. tried release in connection fail/pass did not succeed. tried not alloc @ empty results.... appriciated edit: memory leaks inside parser: -(void)parser:(nsxmlparser *) parser foundcharacters:(nsstring *)string { if (elementfound) { [soapresult...

unit testing Python objects with pytest -

i've method returns list of objects meet criteria result = find_objects(some_criteria) print("%r" % result) >> [<my_object.my_object object @ 0x85abbcc>] i write pytest verify operation of find_objects() def test_finder(testbed): result = testbed.find_objects(some_criteria) assert result [<my_object.my_object object @ 0x85abbcc>] so far, pytest pointing left angle-bracket (<) , declaring "syntaxerror" i'm thinking if work, fail in future when 'my_object' stored in location. if have multiple instances, how confirm correct number of them reported? in context, pythonic way verify output of method returns objects? js you can try: assert isinstance(result, my_object.my_object) you try comparing on string representation (which you're doing, except missing quotes.) isinstance docs might want take @ repr docs idea of what's happening in print statement. angle brackets mean isn't plu...

openxml - Contacting Microsoft with questions on Open XML -

what best way reach live microsoft developer on phone can answer technical questions standardized openxml formats? i have paid msdn support contract. wanted use 1 of phone tickets production-related questions eligible. various reasons, i'm not interested in online support. if wrong place ask question, i'd appreciate pointer in right direction. i've been on phone microsoft , frankly rely on stackoverflow more microsoft support. phone support paid for. 1 of ways you're going free phone support find microsoft-employee-friend give quickassist card. other that, forums way go. the office open xml file format implementation forum place ask questions. forewarning though - responses can incredibly slow of folks manning thread not experts on open xml instead try read ecma spec answer questions. if push hard enough, may have luck though. (you'll see me on there both " otaku " , " terlo "). the other place ask questions "sponsore...

java - Get username of client who connected to web server -

here's scenario. code running on web server in ad domain. client has connected me. how client's username, without having client fill out form in browser? must use java technologies on web server side. edit: i ended using spring security negotiate filter described @ below link. there tutorial available. using request.getprincipal().getname() within servlet gives username. http://waffle.codeplex.com/ you need set spring security kerberos extension - out of box way you're describing in spring security 3. supports spnego negotiation, requires amount of setup on server (and knowledge of how spnego , kerberos works). there's not documentation - mike's sample applications ships 1.0m2 great, , cover of common scenarios, including automated spnego authentication. the key thing spnego set custom authenticationentrypoint - you'll need custom spring bean follows: <bean id="kerbentrypoint" class="org.springframework.security.ext...

c# - Can I compare two arbitrary references in a way that can be used in a CompareTo method? -

i'm writing implementation of icomparable<t>.compareto(t) struct. i'm doing member-wise comparison (i.e. d = a.compareto(other.a); if (d != 0) { return d; } etc.), 1 of members of class (let's call y ) doesn't implement icomparable or have other reasonable way of comparing want compare references (in case know instances of y unique). there way of doing that yield int suitable use in comparison method? it's not meaningful compare references looking order relationships. it's meaningful equality.

c# - Connecting to MySQL from Microsoft Visual Web Developer 2008 -

the mysql database located on local computer , can't figure out how connect it. dropped sqldatasource object onto page , i'm trying create new connection can't figure out how it. please! i've downloaded connectors .net have no idea them =s thank you! this question has been answered before: asp .net - configure sqldatasource use mysql .net connector don't forget add using mysql.data.mysqlclient to class.

java - Optimistic locking and org.hibernate.StaleObjectStateException: -

i'm experimenting optimistic locking. i have following class: @entity public class student { private integer id; private string firstname; private string lastname; private integer version; @version public integer getversion() { return version; } //all other getters ommited. } now i'm fetching 1 of students , try update properties concurrently. thread t1 = new thread(new myrunnable(id)); thread t2 = new thread(new myrunnable(id)); t1.start(); t2.start(); and inside of myrunnable: public class myrunnable implements runnable { private integer id; @override public void run() { session session = hibernateutil.getsessionfactory().opensession(); session.begintransaction(); student student = (student) session.load(student.class, id); student.setfirstname("xxxx"); session.save(student); session.gettransaction().commit(); system.out.println(...

javascript - Facebook verb pending approval -

i'm getting stuck how publish facebook verb + object. in particular, know single application has feature implemented? all verbs pending approval. when try issue: fb.api('me/daparadarseapp:use' + '?minita=http://daparadarseapp.com/pocstreamlinepublish.html','post', function(response) { if (!response || response.error) { alert('error occured'); alert( dump( response ) ); } else { alert('post successful! action id: ' + response.id); } }); i get: 'error' ... 'message' => "unknown path components: /daparadarseapp:use" 'type' => "oauthexception" what doing wrong? use beta of js-sdk long verbs still pending. <script src="http://connect.beta.facebook.net/en_us/all.js"></script>

php - Displaying sub-categories in sidebar when parent category selected -

what i'm trying achieve in wp 3.1.x using wp_nav_menu function, have menu such as: -- category 1 -- category 2 -- category 3 -- category 4 -- category 5 -- category 6 but when you're on 'category 2' displays as: -- category 1 -- category 2 -- sub category 1 -- sub category 2 -- sub category 3 -- category 3 -- category 4 -- category 5 -- category 6 ps. i'm not looking css hide/show functionality, can achieved easily. pps. possible solution extending walker_nav_menu class? if subclass walker_nav_menu class can override display_element function , conditionally remove item's children before looped through. if (!$element->current && !$element->current_item_ancestor && isset( $children_elements[$id])) { unset( $children_elements[ $id ] ); } this remove children of item not current, need check item's type if want categories. complete walker this: https://gist.github.com/954627

mysql - Preventing SQL Injection in C -

i writing c application takes user input , few database queries. aware of risks here of sql injection , wish prevent it. ideally use parameterized queries, have been unable find functionality in c far. constructing queries such: char *query; asprintf(&query, "update sometable set somefield='%s';", userinput); if unable this, must need filter user input. how should filtering done? enough remove 's , "s? (valid inputs cannot contain them). if so, easiest way of doing in c? i believe want use prepared statements , parameter binding. not directly interpolate user data queries. see mysql manual info on this.

Why doesn't this PHP regular expression extract the url from the css value? -

i want extract url background css property "url('/img/hw (11).jpg') no-repeat". tried: $re = '/url\(([\'\"]?.*\.[png|jpg|jpeg|gif][\'\"]?)\)/i'; $text = "url('/img/hw (11).jpg')"; preg_match_all($re, $text, $matches); print_r($matches); and gives me : array ( [0] => array ( ) [1] => array ( ) ) here correct regex. ".*" in middle of regex greedy. also, try replacing square brackets paranthesis. note since using single quotes around string not need escape double quotes. $re = '/url\(([\'"]?.[^\'"]*\.(png|jpg|jpeg|gif)[\'"]?)\)/i';

Update Git submodule to latest commit on origin -

i have project git submodule. ssh://... url, , on commit a. commit b has been pushed url, , want submodule retrieve commit, , change it. now, understanding git submodule update should this, doesn't. doesn't (no output, success exit code). here's example: $ mkdir foo $ cd foo $ git init . initialized empty git repository in /.../foo/.git/ $ git submodule add ssh://user@host/git/mod mod cloning mod... user@host's password: hunter2 remote: counting objects: 131, done. remote: compressing objects: 100% (115/115), done. remote: total 131 (delta 54), reused 0 (delta 0) receiving objects: 100% (131/131), 16.16 kib, done. resolving deltas: 100% (54/54), done. $ git commit -m "hello world." [master (root-commit) 565b235] hello world. 2 files changed, 4 insertions(+), 0 deletions(-) create mode 100644 .gitmodules create mode 160000 mod # @ point, ssh://user@host/git/mod changes; submodule needs change too. $ git submodule init submodule 'mod' (ssh://...

jsf - Ways to override context-param in web.xml during or after deployment in JBoss AS 6 -

in current jsf 2 project, 1 setting in web.xml <context-param> <param-name>javax.faces.project_stage</param-name> <param-value>development</param-value> </context-param> and value should set production instead development on deployment in jboss as. are there simple ways override or modify web.xml entry during or after deployment? update: found this article explains files in jboss as5 deployers directory. author writes: there times when want configuration apply web applications, jboss has global versions of these files located in deployers directory so global-level configuration of web.xml, file deployers/jbossweb.deployer/web.xml can used. check if these files can override values or add values application-level web.xml if know if deployers/jbossweb.deployer/web.xml overrides values in application level web.xml , please leave message here ;) if using maven can filtered copy of web.xml , set value...

jms - How do I create an MDB that listens to Oracle AQ queue under JBoss AS? -

i need listen oracle aq queue in java ee application runs under jboss 5.1. i managed create regular jms client using oracle's jms client library, since java ee application, i'd use mdb. i can't find documentation on this, , can't find resource adapter lets me using jca. can tell me what's required work? this jboss community posting outlines how this. not sure exactly rar use, oracle db install contains these: product\11.2.0\dbhome_1\oc4j\j2ee\home\connectors\ojms.rar product\11.2.0\dbhome_1\oc4j\j2ee\home\connectors\oracleasjms\oracleasjms.rar this stackoverflow question links extensive blog on topic well.

audio - MATLAB audiorecorder and wavwrite -

while reading website of mathworks learned discouraging usage of wavrecord function, because it's going deprecated soon, decided use audiorecorder instead. fine, play function playing recorded audio, when use wavwrite function write wav file it's not sounding well, noticed duration not set properly. i showing program, please suggest me how make correct. thank you. fs = 44100 bits = 16 recobj = audiorecorder(fs, bits, 1); %# get(recobj) %# collect sample of speech microphone, , plot signal data: %# record voice 5 seconds. recobj = audiorecorder; disp('start speaking.') recordblocking(recobj, 5); disp('end of recording.'); %# play recording. play(recobj); %# store data in double-precision array. myrecording = getaudiodata(recobj); %disp(size(myrecording)); %# plot waveform. plot(myrecording); wavwrite(myrecording, fs, bits,'sample01_6k'); %#wavplay(myrecording,fs); you creating recobj twice, , second time create it, create defaul...

objective c - Help to find the point where method is triggered -

i use ttmessagecontroller in project. display modally. navigation bar has default 2 buttons, 1 dismiss composer , other send message. the problem after user clicked on "send" view gets closed automatically. here method ttmessagecontroller.m file closes view - (void)cancel:(bool)confirmifnecessary { if (confirmifnecessary && ![self messageshouldcancel]) { [self confirmcancellation]; } else { if([_delegate respondstoselector:@selector(composecontrollerwillcancel:)]){ [_delegate composecontrollerwillcancel:self]; } [self dismissmodalviewcontroller]; } } so [self dismissmodalviewcontroller]; closes view. method called in code send method. can not see why view closes since there no cancel call in send method. please have @ source: https://github.com/facebook/three20/blob/master/src/three20ui/sources/ttmessagecontroller.m do find anything? you can set symbolic breakpoint in xcode, halt whenever -dismissmodalviewcontrol...

c# - How does VNC continuously repaint windows? -

how vnc send repaint messages windows when user not active? i implement in c sharp - i've had @ printwindow , sendmessage methods , none of them achieve same thing vnc (tested capturing images , black) vnc full picture. what techniques using , can implemented in c sharp windows repaint even when user not active (i.e. rdp closed, minimised or similar). thanks all you use technique used video games, consists in redrawing permanently window during cpu idle time. i found c# implementation here . you have adapt needs.

web services - Embedding images in flash cs4 using as3 -

i want embed images in flash cs4 according description. description value coming webservice. for example-> if description "fair" have display fair.png image or if "heavyrain" have display heavyrain.png image , on.. how proceed. can me out in advance. sushma import mx.core.bitmapasset; [embed("assets/fair.png")] const fair:class; [embed("assets/cldy.png")] const cldy:class; [embed("assets/sunny.png")] const sunny:class; [embed("assets/fog.png")] const fog:class; var desc:string = new string(); if(desc == "fair"){ var fairimg:bitmapasset = new fair(); temperatureimageid.addchild(fairimg); //temperatureimageid id of graphic symbol } else if(desc == "cloudy"){ var cloudy:bitmapasset = new cldy(); temperatureimageid.addchild(cloudy); }else if(desc == "sunny"){ var sunny:bitmapasset = new sunny(); ...

c# - Winforms: Problems validating a cell in a datagridview -

i want validate winforms datagridview cell cellvalidating . if value not set correctly user set errortext , use e.cancel , cursor remains in cell. problem now, error-symbol (and error text ) not displayed (in cell). when delete e.cancel cell looses focus , error-symbol displayed. how can achieve cell remains in edit mode , error-symbol displayed too? if (...) { this.datagridviewx.rows[e.rowindex].cells[e.columnindex].errortext = "errortext"; e.cancel = true; } else { this.datagridviewx.rows[e.rowindex].cells[e.columnindex].errortext = ""; } the behaviour seeing due painting issue , not due error icon not being shown. happening when set cell's error text icon displayed text box of cell in edit mode painted on icon, hence no icon shown user! you have 2 options fixing - 1 use row's error text instead of: this.datagridviewx.rows[e.rowindex].cells[e.columnindex].errortext = "errortext"; e.cancel = true; you have: t...

ruby on rails - Devise redirect after login fail -

all questions i've found related successful login helper after_sign_in_path_for(resource) i have login form in index of site, , when login fails redirects "users/sign_in" but how can redirect "site#index" when login fails? create custom_failure.rb in lib directory, with: class customfailure < devise::failureapp def redirect_url your_path end def respond if http_auth? http_auth else redirect end end end in devise initializer, include: config.warden |manager| manager.failure_app = customfailure end make sure rails loadin lib files, in application.rb : config.autoload_paths += %w(#{config.root}/lib) don't forget restart server. i don't think there's easier way this. luck.

multithreading - Android: How to work with background thread? -

i've developed application takes content internet , shows accordingly on device's screen . program works fine , little bit slow . takes 3-4 seconds load , display content . put code fetches content , displays in background thread , while program doing functions , display progress dialog. me ? learn how put code in background thread. my code public class activity1 extends activity { private progressdialog progressdialog; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); new asynctask<integer, integer, boolean>() { progressdialog progressdialog; @override protected void onpreexecute() { /* * executed on ui thread before doinbackground(). * perfect place show progress dialog. */ progressdialog = progressdialog.sh...

Is the hasOwnProperty method in JavaScript case sensitive? -

is hasownproperty() method case-sensitive? there other alternative case-insensitive version of hasownproperty ? yes, it's case sensitive (so obj.hasownproperty('x') !== obj.hasownproperty('x') ) extend object prototype (some people call monkey patching ): object.prototype.hasownpropertyci = function(prop) { return ( function(t) { var ret = []; (var l in t){ if (t.hasownproperty(l)){ ret.push(l.tolowercase()); } } return ret; } )(this) .indexof(prop.tolowercase()) > -1; } more functional: object.prototype.hasownpropertyci = function(prop) { return object.keys(this) .filter(function (v) { return v.tolowercase() === prop.tolowercase(); }).length > 0; };

php - Accessing POST data in Facebook cavas app -

so i've got simple form in canvas / iframe facebook app, , i'm trying pass along values post. reading on s.o. , fb's latest docs, understand it, data send via post form can accessed on receiving end $_request object. i read on thread on s.o. in order post forms work need pass along input named "signed_request" value current signed_request (i have signed request working ok otherwise...all login , authentication stuff working fine). isnt mentioned anywhere in official fb docs. so problem comes in $_request object signed request, , bunch of other session stuff. form inputs found. the way can read them set method of form "request" isn't real form method. takes of inputs , sends them args in url. horrible. here's sample page canvas app form i'm using try debug (leaving out authentication stuff): <form enctype="application/x-www-form-urlencoded" method="post" target="_top" id="my_form" action=...

c++ - GetCharWidth32 and Point Size issue -

currently have following function attempt character widths specific characters in string. returns same values font regardless of point size. know in logical units. multiplier need take account out of logical units , pixels? thanks! double utils::getformattedcharwidth(char thechar, gdiplus::font* pfont, rectf& rectarc, graphics& graphics) { double textwidth = 0; hdc hdc = null; dword outline = 0; //= getlasterror(); hdc = graphics.gethdc(); outline = getlasterror(); lpint lpbuffer = new int; /*abc *abc = new abc[256]; for(int icon = 0; icon < 256; icon++) { (&abc[icon])->abca = 0; (&abc[icon])->abcb = 0; (&abc[icon])->abcc = 0; }*/ dword dsize = 0; setmapmode(hdc,mm_text); hgdiobj holdfont = selectobject(hdc, pfont); outline = getlasterror(); //outline = getlasterror(); //dword d = getglyphoutline(hdc, thechar, ggo_metrics, lpg, dsize, lpvbuffer, lpm); dword d = getc...

php - Linux SED search replace multiple per line -

i have doosey here. new linux shell bare me... i need replace whole bunch of php super globals in clients website php function made clean superglobals xss attacks. here original code might like: echo $_request['hello1'] . ' , ' . $_request['hello2']; i need this: echo myclass::myfunction($_request['hello1']) . ' , ' . myclass::myfunction($_request['hello2']); the main issue, need search/replace on over 100 files! yikes! so solution (in linux shell): sudo sed -i 's/\$_request[.*\]/myclass::myfunction(&)/g' *.php this works great as-long-as 1 instance of "$_request" occurs per line... multiple instances, screws , this: echo myclass::myfunction($_request['hello1'] . ' , ' . $_request['hello2']); i pulling hair out! any linux shell experts out there can hope? try sed command: sed -i.bak 's/\$_request\[\([^]]*\)\]/myclass::myfunction(\1)/g' *.php o...

html - Why is Chrome generating unnecessary huge margins? -

web site in progress http://www.asstatauka.us.lt in firefox looks fine, chrome , other webkit internet browsers generating margins @ bottom , on right side. can inspect code , advice me on change avoid problem. appreciate. many thanks! div#top-header { overflow: hidden; } div#cart-top { right: 0; } add css file accordingly.

cordova - Javascript QR code reading libraries -

i wish use qr codes in phonegap -based mobile app. there several ways generate qr codes using javascript . i'm using jerome etienne's jquery-based solution . i'm looking pure javascript solution or set of phonegap plugins camera-enabled platforms read qr encoded data in image. so far i've found a demo lazarsoft . there other solutions? this current go library barcode scanning: https://github.com/wildabeast/barcodescanner now official cross-platform barcodescanner cordova / phonegap https://github.com/phonegap/phonegap-plugin-barcodescanner

flash - DisplayObjectContainer into Flex component... how? -

i'll re-write question clearer. i'm trying class file flash builder. everything in class sits inside sprite called maincontainer . i'm trying `maincontainer' hold graphics class flex application. this proving problem many various ways of doing (it seems going numerous google searches). first off declare mxml canvas image inside (as read work): <mx:canvas x="268" y="10" width="756" height="680" id="canvas"> <mx:image id="spritelayer" x="268" y="0" width="756" height="700" scalecontent="false" autoload="true"> </mx:image> </mx:canvas>} ok, plan pass image reference of spritelayer class i'm trying run: import includes.spirograph; public var spiro:spirograph = new spirograph(spritelayer); unfortunately ever passes null spirograph class: function spirograph(canvas...

Silverlight 4 MVVM DataGrid AND Child Window Pass Data back to Parent Window -

i need help. have silverlight application parent form has search button when clicked loads modaldialog has 3 text boxes, 2 button(for searchin , resetting) , datagrid (telerik gridview, can change grid not problem). enter search criteria on 1 of buttons, last name, , records particular lastname loaded on grid. need able select row on grid , having done so, details of selected row should updated on controls on parent window (there no grid on parent window, data entry form). using mvvm. how acheive while keeping true mvvm pattern? have seen alot of stuff on passing data parent child none on child parent/calling window. any help, , simple code example, highly appreciated. been on whole 3days , aint figuring out yet. francis. i've done in mvvm light toolkit using messaging. uses called "pubsub", means "publish message, subscribe message" i use command in gridview of modal window. here's xaml that: <i:interaction.triggers> <i:eve...

c++ - std::cin input with spaces? -

#include <string> string input; cin >> input; the user wants enter "hello world". cin fails @ space between 2 words. how can make cin take in whole of hello world ? i'm doing structs , cin.getline doesn't seem work. here's code: struct cd { string cdtitle[50]; string artist[50]; int number_of_songs[50]; }; cin.getline(library.number_of_songs[libnumber], 250); this yields error. ideas? you have use cin.getline() : char input[100]; cin.getline(input,sizeof(input));

django - Open file in Python -

my cwd ~/desktop/development/python/djcode/mysite, , want open file on desktop. syntax open files in different directory? (for example, if file in cwd use open('file'). thank you. use relative paths? ../../../../file

haskell - Function "who am I" accessible from function and usable as key? -

i use collection of function names data.map keys, , have key each function automatically available within function. willing consider "unsafe" operations, if necessary. my specific programming problem this: i've been developing simple parser library textual transformations, use in particular preprocessing , grooming of haskell code. has virtue of being small enough hack, constructs not requiring explicit monadic notation. instead, grammars read verbatim formal descriptions. in particular, i've entered lexical structure of haskell2010 once , idea of modifying grammar in various ways different applications. creating labels corresponding each grammar construct, , passing these labels each construct. use these labels keys data.map. allows me provide post-processing various labels, in different applications of grammar. the details of code don't matter; gist of question should clear, similar application describe here. here (draft) fragment of grammar haskell201...

facebook - Test open graph actions -

is there way test open graph verbs , actions right now? i not able submit actions , objects approval. mean won’t able test flows until timeline releases? your app's developer , tester accounts should able publish actions far i'm aware

C++ | Syntax Error: Identifier 'i' -

hey guys, i'm pretty sure else has had problem too, couldn't find related problems. stupid typo or something, i'm not able figure out >.< what's wrong code, error: error c2061: syntax error : identifier 'i' #include <iostream> #include <string> using namespace std; class mahinluokka { public: void setnum(int); int getnum(); private: int mahi_num; }; int main() { int i; { cout << "insert number between 1-100" << endl; cin >> i; } while > 100 || < 0; mahinluokka mahi; mahi.setnum(i); cout << mahi.getnum() << endl; mahi.setnum(5); cout << "mahi_num set 5" << endl; cout << mahi.getnum() << endl; // end int x; cin >> x; return 0; } void mahinluokka::setnum(int number) { mahi_num = number; } int mahinluokka::getnum() { return mahi_num; } ...

php - Trying to locate Codeigniter function executed in the view file -

i'm trying find below query coming from. below executed in view file resource_update.php cannot find add_resource function resource controller... is there reason why? $this->resources->add_resource($desc_arr, $desc_limit, $new_clients); check if "resources" library or model. don't think ever need call controller view (which again loaded controller). i.e., how resources loaded? $this->load->library('resources'); or $this->load->model('resources'); other lack of sleep, see no reason why should not find function way. :) if bothering - try changing ide phpdesigner, netbeans etc. have cool way of finding function definition , code hinting. cheers!

script# - Newbie How do I send Json information using scriptsharp to a web service -

i have modified sample demo try send json object rather string. web site see string of value [object] rather json text. need change. namespace demoscript { // [imported] // [ignorenamespace] public sealed class person { public string firstname; public string lastname; } [globalmethods] internal static class hellopage { static hellopage() { // add script runs on startup script loaded // page element hellobutton = document.getelementbyid("hellobutton"); person p = new person(); hellobutton.addeventlistener("click", delegate(elementevent e) { inputelement nametextbox = document.getelementbyid("nametextbox").as<inputelement>(); p.firstname = nametextbox.value; p.lastname = "surname"; xmlhttprequest xhr = new xmlhttprequest(); // xhr.open(httpverb.get, "/helloservice.ashx?name=" + nametextbox.value.encodeuricomp...

html - MVC embed links on page from database -

i'm trying make simple blog page. , main problem right want able embed example youtube video. when post loads database link displayed instead of being embedded. below partialview displays posts. @foreach (var item in viewbag.posts) { <div class="posts"> <p> <b>@item.topic</b></p> <p> <@item.text</p> <p> @item.postdate - @item.alias</p> </div> <hr /> } the item.text embedded link held. there way solve this? thanks beforehand. you can html helper: @html.raw(item.text)

vb.net - How to fill up the AutoCompleteCustomSource -

how fill autocompletecustomsource list query results using data reader in vb.net ? an example code needed. edit 1: this have tried , not working private sub cbemployeeno_click(byval sender object, byval e system.eventargs) handles cbemployeeno.click cbemployeeno.autocompletecustomsource.clear() dim myselectquery string = "select * employeetable " & cbsearch.text & " '" & cbemployeeno.text & "' , status '" & cbstatus.text & "'" dim myconnstring string = "data source=" & application.startuppath & "\database\simpledb.db3" dim sqconnection new sqliteconnection(myconnstring) dim sqcommand new sqlitecommand(myselectquery, sqconnection) sqconnection.open() try dim sqreader sqlitedatareader = sqcommand.executereader() dim m integer while sqreader.read m = 1 sqreader.fieldcount() - 1 if (not sqreader.isdbnull(m)) if cbsearch...

android dictionary using trie -

i want build android dictionary app using trie. m new platform, how possibly start things... plz can me..... the android developer site great place start from: http://developer.android.com/guide/basics/what-is-android.html after read basics, start tutorial: http://developer.android.com/resources/browser.html?tag=tutorial if have specific question after that, when start implementing application, welcome ask.

c++ - How to use qmake file with google test and shared library -

i started makefile generate dependencies of c++ files. c++ project using google test. later, started qt project uses qmake , links shared library old makefile builds. needless say, old makefile complicated now. i make qmake file can following: build shared library list sources build google test (optionally, accept separate makefile this) build qt executable different list of sources linking first shared library all builds should have debug , release versions output different directories can point me in right direction making *.pro file that? i'm not clear on how things multiple targets in qmake. here current makefile using (clearly mess): gtest_dir = /home/matt/lib/gtest-1.5.0 gmock_dir = /home/matt/lib/gmock-1.5.0 src_dir = /home/matt/documents/myproject qtinc := -i/usr/share/qt4/mkspecs/linux-g++ -i/usr/include/qt4/qtcore \ -i/usr/include/qt4/qtgui -i/usr/include/qt4 test_srcs = test/testrunner.cpp test/celltest.cpp test/puzzletest.cpp \ test/sing...

Disable Rails SQL logging in console -

is there way disable sql query logging when i'm executing commands in console? ideally, great if can disable , re-enable command in console. i'm trying debug , using "puts" print out relevant data. however, sql query output making hard read. edit: found solution, since setting logger nil raised error, if other code tried call logger.warn instead of setting logger nil can set level of logger 1 . activerecord::base.logger.level = 1 # or logger::info to turn off: old_logger = activerecord::base.logger activerecord::base.logger = nil to turn on: activerecord::base.logger = old_logger

c++ - Function returns std::wstring = NULL; -

i have trying make wrapper winapi function getwindowtext . function returns std::wstring don't know how handle error happen. return null know it's wrong. std::wstring getwindowtext(hwnd handle) { const int size = 1024; tchar wnd_text[size] = {0}; hresult hr = ::getwindowtext(handle, wnd_text, size); if(succeeded(hr)) return std::wstring(wnd_text); else return null; } as alternative exceptions return string reference in argument list , indicate sucess returning true or false i.e. bool getwindowtext(hwnd handle, std::wstring& windowtext) { const int size = 1024; tchar wnd_text[size] = {0}; hresult hr = ::getwindowtext(handle, wnd_text, size); if(succeeded(hr)) { windowtext = wnd_text; return true; } else return false; } another alternative avoids reference argument return instance of class wraps value lets know whether va...

hibernate - ColdFusion ORM Caching and LogSQL -

ive been playing orm caching in past few days , 1 thing confusing me lot sql still logged (when have logsql = true) console caching enabled. makes me think caching not working, think hibernate doesnt create sql since sees object in cache, maybe hibernate generates sql before checking ehcache. my code below incase picks missed. application.cfc this.ormsettings.secondarycacheenabled = "true"; this.ormsettings.cacheprovider="ehcache"; this.ormsettings.logsql=true; then books cfc component persistent="true" entityname="books" table="db_books" cacheuse="transactional" lazy="true" and lastly code im using call. = entityloadbypk("books","1"); writeoutput(a.getname()); from i've read , experienced first hand, sql transferred on wire dbms logged regardless of whether coldfusion orm (hibernate) generating jit, or pulling cache. if anything, run few benchmarks identify whe...

numbers after comma in Java -

how n numbers after comma in java? ... double numb = 123.45; void lastnumber(int n){ // here } ... (in example n = 2, 2 numbers after comma) a bit ugly: public long getfraction(double num, int digits) { int multiplier = powers_of_ten[digits]; long result = ((long) (num * multiplier)) - (((long) num) * multiplier); return result; } where powers_of_ten array of precomputed powers of ten (0=1, 1=10, 2=100, 3=1000, etc.)

Netbeans and creating JUnit tests -

i using netbeans 7.0.1 web project have imported existing sources. have added junit library project. in netbeans tutorials online version < 7 says create junit test given existing class righ-clicking on source file in project, select menu "tools" , there should option create junit test. option not appear me. there seem bean old bug report/request functionality, describing not seem have been resolved mentioned late 2011-05-09 on netbeans bugzilla list (link related on bugzilla ). on bugzilla suggested explicitly create folder /test/unit/src in project, still after when try create junit test existing class rightclick project -> new -> other -> junit, "no tests root folder found in selected project" (i tried changing foldername tests well). can explicitly set location in configuration file , there way of getting expected functionality allowing me righclick source file , select "junit test" create junit stub selected class ? if right ...

css - How do I make the divs inline? -

i using wrapper pretty confused. want 2 resultbox div s in line submit div . take here: http://jsfiddle.net/qtvwr/ what doing wrong? i'm not familiar css. part of problem there issues html. here's start: make sure div s closed. remove float s css add display:inline-block; remove inline styles html. correct .wrapper class .wrapper1 (matching html) so, more want, assume: .wrapper1 { height:70px; width: 800px; background: #ffffff; border: 1px solid grey; color: #bdbdbd; } .resultbox { width: 300px; background: #ffffff; color: #bdbdbd; display: inline-block; } .submit { height:15px; width: 32px; margin-top:10px; background: #ffffff; border: 1px solid; color: #bdbdbd; display: inline-block; } and html <div class="wrapper1"> <div class="resultbox" style="" > <div class="locationresult" style="" form ...

php - How do I separate my executable files from my library files? -

i still haven't gotten answer i'm happy with. please submit answers if have nice system python or php projects. i'm having management issue php , python projects. both have 2 kinds of code files: files should run in console or web browser, , files should included other files extend functionality. after projects grow large namespace or module trees, starts getting disorienting "executable" files , library files lay side side same file extensions in folders. if php , python pre-compile languages, files main function. for example, picture have namespace com.mycompany.map.address contained multiple .py or .php files depending on project. contain models different kinds of addresses , tons of functions working addresses. in addition, contain executable files runs terminal, providing user tools searching addresses, , perhaps adding , removing addresses database or such. i want way of distinguish such executable files tons , tons of code files in namespace t...

c# - Using TimeZoneInfo to convert between UTC/Specified TimeZone not working -

all of our date/time data in our database stored in utc time. i'm trying write function convert utc time user's preferred time zone (they can select timezone in profile has nothing local settings on computer , timezone have selected dropdown of available choices. this function in context of devexpress aspxgridview event (the third party control not relevant question thought i'd mention it): datetimeoffset utctime = (datetimeoffset)e.value; timezoneinfo desttimezone = helper.gettimezoneinfo(); datetime modifieddate = timezoneinfo .converttimefromutc(utctime.datetime, desttimezone); e.displaytext = string.format("{0} {1}", modifieddate.tostring("g"), desttimezone.abbreviation()); helper.gettimezoneinfo() returns timezoneinfo class corresponds 1 user selected, or defaults "pacific standard time" if have not chosen one. this works fine until switch system clock (which...

php - Function gets printed twice -

i made function, same result printed twice. idea why? function? can't find wrong it. $valid array. function validoutput($output, $valid, $name, $mirror){ foreach($valid $e) { if(strpos($output, $e) != false) { echo '<br />' . $name . '<br />'; echo '<textarea cols=100 rows=10>'; echo '[tab: mirror' . $mirror . ']'; echo $output; echo "</textarea>"; } } } please tell me if see wrong it, thanks. edit: $valid = array("facebook", "fbcdn", "megavideo", "video", "videoweed", "4shared"); $valid has 2 elements substrings of $output can show sample inputs? maybe explain motivation behind $valid parameter is?

php - Determine when a new customer registers from within custom module (Magento) -

i working on module allow customer not sign our webstore, give them ability register site via web service. how determine, within module, when customer registering can send appropriate information off other site? magento has event system dispatches events registered observers when occur. allows want. take @ customer_register_success event ( app/code/core/mage/customer/controllers/accountcontroller.php : 322 ) more on event/observer pattern in magento: http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method

iphone - Save content of UIWebView -

i working on app , need save content of uiwebview. i use stringbyevaluatingjavascriptfromstring:@"document.getelementsbytagname('html')[0].innerhtml" html of uiwebview, problem method not save full content of webpages. so question how save full content of webpage including images , css i think there thread topic here: iphone uiwebview download complete page css , images hope helps.

Best practice for determining objects type in Javascript -

if have instance of object in javascript, seems can difficult find actual type, ie var point2d = function point2d(x, y) { return { x: x, y: y } } var p = new point2d(1,1); typeof p // yields 'object' not 'point2d' one way around found make object own prototype, , can gets name calling prototype.constructor.name, var point2d = function point2d(x, y) { return { x: x, y: y, prototype: } } new point2d(1,1).prototype.constructor.name // yields 'point2d' would ok way of doing (what pros/cons?) or there better practice missing out on? thanks. first need fix how building class, since tripping in js pitfalls , doing weird stuff: function point2d(x, y){ //our constructor/initialization function //when run, 'this object have //point2d.prototype prototype this.x = x; this.y = y; //don't return value here! doing overrides //the default "return this" want. } //you can put ...

java - Keeping search result consistent across multiple transactions -

i have implement requirement java crud application users want keep search results intact if actions affects criteria returned rows matched. confused? ok. let me give familiar example. in gmail if advanced search on unread emails, presented list of matching results. click on entry , go search list. happens have read entry hasn't disappeard original result set. line has changed bold normal. i need implement exact same behaviour application designed in such way transaction persisted first , ui requeries db keep in sync. complexity of application , size of database prevents me doing simple in memory caching of matching rows , making changes both in db , in memory. i'm thinking of solving problem on database level creating intermediate table in oracle database holding pointers matching records , requerying records keep ui in sync data. ideas? in oracle, if open cursor, results of cursor static, regardless if transaction inserts row appear in cursor, or updates or ...

iphone - How can I sent an array of strings into an UIActionSheet varargs init method? -

i have action sheet options vary depending on circumstances. there enough different button titles construct array of button titles first, can't figure out how convert varargs format. i want this: nsmutablearray *buttontitles = [nsmutablearray array]; if (condition1) { [buttontitles addobject: @"do action 1"]; } if (condition2) { [buttontitles addobject: @"do action 2"]; } if (condition3) { [buttontitles addobject: @"do action 3"]; } if (condition4) { [buttontitles addobject: @"do action 4"]; } uiactionsheet *actionsheet = [[[uiactionsheet alloc] initwithtitle: nil delegate: self cancelbuttontitle: @"cancel" destructivebuttontitle: nil otherbuttontitles: buttontitles] autorelease]; now if had instead: uiactionsheet *actionsheet = nil; if (condition1 && condition2 && condition3 && condition4) { actionsheet = [[[uiactionsheet alloc] initwithtitle: nil delegate: self cancelbutton...

random - Reset Mersenne Twister -

i assumed answer simple @ moment seems alluding me. i'm using mersenne twister (implementation here http://www.bedaux.net/mtrand/ ) generating random numbers. i need able generate same sequence of "random" numbers twice, straight after each other in same program. i'm using same void seed(const unsigned long*, int size); function same set of values in hopes reset generator , allow me generate same values again. specifically: unsigned long init[4] = {0x123, 0x234, 0x345, 0x456}, length = 4; irand.seed(init, length); just tested , working. i wondering if has had problem before. or knows i'm doing wrong. unsigned long init[4] = {0x123, 0x234, 0x345, 0x456}; int length = 4; mtrand_int32 irand(init, length); irand.seed(init, length); // resets i've tested modifying mtrand test program reset after 5 numbers of output , results clear.

Functional javascript samples with Jquery, Guru of functional js -

are there open source proejcts or guidelines of using javascript in functional programming way. @ open source projects using of underscore.js, wu.js, osteele [dot] com or functional js library there best practices using functional javascript. can recomment blogs of functional javascript guru. as you've revised, osteele dot com good. here have other useful links you: eloquent javascript, chapter 6: functional programming high order javascript