Posts

Showing posts from June, 2015

flex4 - Restrict editing a column in a datagrid -

good evening stackoverflow...i have problem see. want able restrict input of user ("0-9"),i know how implement in text input since has restrict function. question how can implement restrict in datagrid? please me..thnx create item editor text input component , restrict it. don't forget set column editable="true"

Loop, which continuos on change; C# -

i making power managment monitor notebook , want program show every change in power status. so, made while(true) loop (of course) shows non changed status. if tell me how make loop showing change in power status i'll appreciate much! i hope you've understood problem! well, tried compare old , new value isn't happening. here's code: using system; using system.windows.forms; using system.threading; namespace simplepmmonitor { class pmmonitor { static void main(string[] args) { console.writeline("simple battery monitor"); console.writeline("<c> copyright 2001 circuit design corporation"); console.writeline("<c> copyright 2011 simple corporation"); console.writeline("\nmonitoring started...\n"); powerstatus pwr = systeminformation.powerstatus; powerstatus oldpwrstat = systeminformation.powerstatus; datet...

c preprocessor - How to define a define in C? -

is possible write #define defines #define ? for example: #define fid_strs(x) #x #define fid_stre(x) fid_strs(x) #define fid_decl(n, v) static int fidn_##n = v;static const char *fids_##n = fid_stre(v) but instead: #define fid_decl2(n, v) #define fidn_##n v \ fids_##n fid_stre(v) fid_decl works fine creates 2 static variables. possible make fid_decl2 work , having define 2 defines? no; preprocessing performed in single pass. if want or need more advanced behavior, consider using tool preprocess source, m4. further, # in replacement list (at beginning of #define fidn... parsed # (stringize) operator: operand of operator must named macro parameter, define not.

How do you create an Android SMS intent? -

i want unit test sms broadcast reveiver's onreceive method don't know how create sms intent. onreceive method looks this: @override public void onreceive(context context, intent intent) { if (intent.getaction() .equals("android.provider.telephony.sms_received")) { stringbuilder sb = new stringbuilder(); bundle bundle = intent.getextras(); if (bundle != null) { smsmessage[] messages = getmessagesfromintent(intent); } } } private smsmessage[] getmessagesfromintent(intent intent) { smsmessage retmsgs[] = null; bundle bdl = intent.getextras(); try { object pdus[] = (object[]) bdl.get("pdus"); retmsgs = new smsmessage[pdus.length]; (int n = 0; n < pdus.length; n++) { byte[] bytedata = (byte[]) pdus[n]; retmsgs[n] = smsmessage.createfrompdu(bytedata); } } catch (exception e) { log.e("getmessages", "fail", e); } return retms...

stl - in C++, how do you code a class ADT--like std::vector or std::stack--that takes a data type in <> as argument and constructs the object accordingly? -

ie. want code class adt can used this: myadt <type> objecta; in same way use vector like: vector <type> avector; i'm guessing maybe has templates , overloading <> operator, how take data type argument? let's have class implements adt using hard-coded typedef t : class adt { public: typedef int t; adt(); t& operator[](size_t index); const t& operator[](size_t index) const; size_t size() const; ... private: t* p_; size_t size_; }; (you have work out internal storage , member functions appropriate actual adt). to change can specify t done std::vector etc.: template <typename t> <-- specification of t moved here class adt { public: <-- typedef t removed here adt(); t& operator[](size_t index); const t& operator[](size_t index) const; size_t size() const; ... private: t* p_; size_t size_; }; usage then: ad...

split - PHP: Text explode() problem -

i have problem explode() function. use function explode strings "name: replica" in string has 2 or more colons ( ":" ) , there problem because script is: example: " name: replica:replica2:replica3 " $explode = explode(":", $string); $query = "insert `table` (`field_1`, `field_2`) values ('".$explode[0]."', '".$explode[1]."')"; and need solution problem. because when split string after first colon ( ":" ) second part must last part. regards, george! p.s. - sorry english. i think want use 'limit' (third) argument explode() : list($attribute, $value) = explode(":", $string, 2); that make sure 2 results. http://php.net/manual/en/function.explode.php

Control zoom level of WinForms using mouse sroll wheel and Ctrl in VB.NET -

if have winform, may know how can control zoom level of font in application (as application window obviously) using ctrl + mouse scroll wheel? see there delta in scroll wheel event, not sure how works. there code sample can into? thanks help! you'll have handle keydown , keyup event in order determine whether or not ctrl key being held down. value should stored @ class-level because used other subroutines besides keydown , keyup events. you write code handle form's mousewheel event. scrolling downwards (towards you) causes negative value delta property of mouseeventargs . scrolling upwards reverse. value of delta property 120. microsoft's reason value follows: currently, value of 120 standard 1 detent. if higher resolution mice introduced, definition of wheel_delta might become smaller. applications should check positive or negative value rather aggregate total. in context you'll check sign of delta , perform action. here sample code...

ios - Pausing an UIImageView animation -

i doing uiimageview animation so: //////progressbar start progressbar.animationimages = [nsarray arraywithobjects: [uiimage imagenamed:@"1.png"], [uiimage imagenamed:@"2.png"], [uiimage imagenamed:@"3.png"], [uiimage imagenamed:@"4.png"], [uiimage imagenamed:@"5.png"], [uiimage imagenamed:@"6.png"], [uiimage imagenamed:@"7.png"], [uiimage imagenamed:@"8.png"], [uiimage imagenamed:@"9.png"], [uiimage imagenamed:@"10.png"], [uiimage imagenamed:@"11.png"], [uiimage imagenamed:@"12.png"], ...

Passing get parameter from javascript to php destroys formatting -

i format text javascript asigning + every emtpy space this var ft = text.replace(/ /g,"+"); then pass ft php script via jquery ajax argument. but print $_get['text']; gives me text empty spaces instead +. any ideas? you should familiar concept of url encoding . php's urldecode function run against $_get variables default, if want see raw input, use rawurldecode : $encoded = array_map('rawurldecode', $_get); echo $encoded['text']; //blah+blah

ruby on rails - How to change values overriding the 'to_json' method? -

i using ruby on rails 3 , override to_json method. at time use following code in order avoid export important information. def to_json super( :except => [ :password ] ) end if want change value using method, how can do? for example, capitalize user name :name => name.capitalize on retrieving this @user.to_json if want render :json => @user in controller rails 3, can override as_json in model: class user < activerecord::base def as_json(options={}) result = super({ :except => :password }.merge(options)) result["user"]["name"] = name.capitalize result end end here's post differences between to_json , as_json .

android - Toggling View background -

i have view object on activity , i'd change background resource of view. more specifically, i'd toggle it. so i'll need logic this: if (myview.getbackgroundresource() == r.drawable.first) { myview.setbackgroundresource(r.drawable.second); } else { myview.setbackgroundresource(r.drawable.first); } the issue here being there no getbackgroundresource() method. how can obtain resource view using background? i don't think view remembers resource using after gets drawable resource. why not use instance variable in activity, or subclass view , add instance variable it?

Java PDF manipulation, replacing text based on pattern matching, with hyperlink -

does know of best way take pdf document, , replace subs strings match pattern ( [a-z][a-z][a-z] ' ' [0-9][0-9][0-9][0-9]|[a-z] ), , replace hyperlink of same string going same string. i plan allow user view pdf document (which list of classes can take degree), , allow user click class, inorder add list. i understand can add hyperlinklistener jeditorpane, , assuming work on hyperlinks in pdf (i hope) i looking pdfbox , itext, far stuck on how replace text. *i plan pull pdfs url, , format hyperlinks on fly (no need export file either). looking forward feed back. i found example http://pdfbox.apache.org/apidocs/org/apache/pdfbox/examples/pdmodel/replacestring.html by incorporating pattern matcher in code, able update text , replace strings match pattern strings based on string replacing.

c# - Mutability of the Enumerator struct -

i have problem following code: public static void restoretoolstripmenuitem(toolstripmenuitem item, list<string>.enumerator enumerator ) { item.text = enumerator.current; enumerator.movenext(); if (item.hasdropdownitems) { var itemswithoutseparators = item.dropdownitems.oftype<toolstripmenuitem>(); foreach (var child in itemswithoutseparators) { restoretoolstripmenuitem(child, enumerator); } } } after restoretoolstripmenuitem called recursively, enumerator reseted (current property points first element of collection). can worked passing enumerator ref. wondering, why case? enumerator struct. caused problem, mutability of enumerator struct? yes, it's changing state of structure causes that. if pass structure value, using copy of in method, , 1 in calling code not change.

mysql - Handling custom user fields with possibility of grow and shrink -

this question how do, idea etc. i have situation user can create many custom fields can of type number, text, or date, , use make form. have make/design table model can handle , store value query can done on these values once saved. previously have hard coded format 25 user defined fields (udf). make table 25 column 10 number, 10 text, , 5 date type , store label in if user makes use of field. map other table has same format , store value. mapping done know field having label not efficient way, hope. any suggestion appreciated. users have permissions creating number of udf of above types. can used make forms again n numbers , have save data each form types. e.g. let's user created 10 number 10 date , 10 text fields used first 5 of each make form1 , 10 make form2 saved data. my thoughts on it: make table1 [id,name(as udf_xxx xxx data type),userlabel ] table2 map form , table1 [id(f_key table1_id), f_id(form id)] and make 1 table of each data type [ id(f_key of ...

apk - Android - cache installation problem -

i wondering if it's possible delete file, has been downloaded url connetion autoupdate right after installation? *.apk should not available public, deleting sd card when app starts next time, there other (better) way of dealing right after installation? thanks edit: instalation of apk menu.mprogressdialog.dismiss(); intent install=new intent(intent.action_view); install.setdataandtype(uri.fromfile(new file(ctx.getcachedir()+"/app.apk")), "application/vnd.android.package-archive"); ctx.startactivity(install); try saving @ context.getcachedir() . it's not visible other apps (or non-root users). be sure delete possible (next time user starts app, or listen package_installed broadcast) avoid filling user's phone's internal memory! good luck tom

Can't find C# class template file in Visual Studio folder -

i trying create visual studio 2010 add-in when run adds class opened solution's first project using envdte . i've managed create add-in, reference opened solution , reference first project. then want create class , , i've found following code: string templatepath = sol.projectitemstemplatepath(prjkind.prjkindcsharpproject); templatepath += @"\csharpaddclasswiz.vsz"; the path points template file not exist. everywhere try file, it’s stated “you find in microsoft visual studio 10.0\vc#\csharpprojectitems” here’s entire content of folder in installation of visual studio 2010: http://i.stack.imgur.com/yfsmw.png in fact i’ve searched file, , *.vsz in entire hard drive, , nothing found. i have 2 questions: 1) did install visual studio incorrectly, file not available in visual studio folders? 2) how can file, if copy of it? i realize having copy of , shipping in add-in mean in future, people generate classes old template, rather updated ones...

python - How to set the color of a single cell in a pygtk treeview? -

i have pygtk treeview couple of columns. during runtime add new rows. each cell contains string. normaly, use gtk.cellrenderer each row, want set background color of each cell, according value inside cell. i tried couple of solutions, seems have create cellrenderer each cell, set text attribute , background color. seems little oversized, asked myself if there nicer solution problem. suggestions? you can define background , foreground treeview cells in fields of treeview data source. setup foreground , background attributes treeview columns values corresponding data source fields. below small example: import gtk test_data = [ { 'column0' : 'test00', 'column1' : 'test01', 'f': '#000000', 'b': '#ff00ff' }, { 'column0' : 'test10', 'column1' : 'test11', 'f': '#ff0000', 'b': '#c9c9c9' }, { 'column0' : 'test20', '...

Mysql auto increment help -

i have table fields id,title,no,url. i want auto increment id field the table has 1000 records in already assigned ids now want auto increament records newly inserted .i do not want auto increment present 1000 records . is there way can this??? alter table tablename modify id integer (11) auto_increment;

osx - How to estimate CSS text file size reduction when compressing with gziped -

i'm writing mac app analyse css files , estimate size reduction when minified. estimate reduction in size obtained http compression using gzip. how can that? there library can me? you better off doing minification , gzipping , presenting difference. time work not significant enough estimate other means. if analyzing 1000s of files @ once, user have expectation operation take bit of time complete.

delphi - How might I find out the source of long delays on resizing the main form? -

i have d2006 app contains page control , various grids, etc on tabs. when resize main form (which ripples through , resizes on form aligned something), experience long delays, several seconds. app freezes, idle handler not called , running threads appear suspend also. i have tries pausing execution in ide while happening in attempt break execution while in troublesome code, ide not taking messages. obviously i'm not expecting point me @ errant piece of code, i'm after debugging approaches might me. have extensive execution timing code throughout app, , long delays don't show in of data. example, execution time of main form onresize handler minimal. if want find out what's taking time, try profiler. sampling profiler answer question pretty easily, if you're able find beginning , end of section of code that's causing trouble , insert outputdebugstring statements around narrow down profiling.

windows - Hooking or Monitoring Service Creation -

i @ end of rope here. have been trying 3 weeks information. before continue want know not writing malware here. writing binary analysis tool monitors behavior of malware. what trying accomplish either hook or monitor createservicew , createservicea. reason want know process invoked createservice , binary is being registered service call. i tried writing hook zwrequestwaitreplyport intercept lpc message, writing proxy dll advapi32.dll, , writing inline hook createservice function. none of these approaches have yielded results though. proxy dll promising in testing, didn't work when official dll in system32 replaced proxy (bsod). inline hook work if gain write access mapped area of memory dll lies in. regardless time running out , desperately in need of alternative. i have looked @ setwindowshookex , seems plausible might able intercept messages sent process services.exe ...but not certain. can point me in direction...i'm begging you. "the inline...

mysql - ODBC update using ASP.NET forms -

how pass karthik@domain.com , kars@domain.com using asp.net forms (textbox) ? string myconstring = "driver={mysql odbc 3.51 driver};" + "server=localhost;" + "database=new_db;" + "uid=root;" + "password=password;" + "option=3"; odbcconnection myconnection = new odbcconnection(myconstring); odbccommand cmd = new odbccommand("update awm_create set referral_email='karthik@domain.com' email='kars@domain.com'" , myconnection); myconnection.open(); cmd.executenonquery(); you have add 2 asp.net textbox controls web form , upon postback (using ispostback flag) can pull email address textboxes in pageload event... i.e. like: private void page_load() { if(page.ispostback) { // add validation here text boxes if need... string refemail= txtreferralemail.text.trim(); string email = txtemail.text.trim(); //then can this: var sql = string.format("upda...

sql - mySQL (and MSSQL), using both indexed and non-indexed columns in where clause -

the database use mysql maybe later mssql. my questing how mysql , mssql takes care indexed , nonindexed columns. lets have simple table this: *table_id -auto increase. id, indexed . *table_user_id -every user has unique id indexed *table_somotherid -some data.. *.... lets have lot!! of rows in table, number of rows every user add table small (10-100) and want find 1 o few specific rows in table. row or rows specific user(indexed column). if use following clause: ..... table_user_id= 'someid' , table_someotherid='anothervalue'. will database first search indexed columns, , search "anothervalue" inside of rows, or how database handle this? i guess database increase lot if have index every column in tables.. think, enough index columns decrease number of rows ten maybe hundred? database optimizers work on cost basis on indexes looking @ possible indexes use based on query. in specific case see 2 columns - table_use...

parsing - Simple Grammar for Lemon LALR Parser -

i've been stuck since while now. want parse simple as: likes: word1 word2 .. wordn hates: word1 word2 .. wordn i using lemon+flex. @ moment grammar looks : %left likes moods hates info. %syntax_error { std::cout << "syntax error!" << std::endl; } final ::= likes_stmt. final ::= hates_stmt. likes_stmt ::= likes list(a). { data *data=data::getinstance();data->likes.push_back(a);} hates_stmt ::= hates list(a). { data *data=data::getinstance();data->hates.push_back(a);} list ::= likes_stmt value(a). { data *data=data::getinstance();data->likes.push_back(a);} list ::= hates_stmt value(a). { data *data=data::getinstance();data->hates.push_back(a); } list(a) ::= value(b). {a=b;} but works first 2 words. doing wrong , in recursive definition ? heads appreciated :) @crozzfire, ira provided correct answer original question, consider voting it. let me answer question additional requirement separate parsed val...

Capture result from a function in C (cmd1 | cmd2) -

let cmd1 print on stdout. how can capture cmd1 in c such cmd1 | cmd2 works. i.e cmd1{ fprintf(stdout, "hello"); } cmd2 : should take "hello" , print "hel". to enable pipeline operation, cmd2 should read stdin . for example, since fgets() reads stdin , can like: #include <stdio.h> int main() { char buf[1024]; while (fgets(buf, sizeof(buf), stdin)) { printf("%.*s\n", 3, buf); } return 0; }

html - Why don't the modern browsers support PUT and DELETE form methods? -

i finished building restful api 1 of latest apps. built simple admin interface scaffolding class enumerate resources , build simple forms , tables edit, create, delete etc. for updating , deleting resources, class outputs form methods of put , delete, pretty simple: <form action="/posts/xxxxxxx" method="delete"> <input type="submit" value="delete" /> </form> and <form action="/posts/xxxxxxx" method="put"> <input type="text" name="username" value="nikcub" /> <input type="text" name="fullname" value="nik cubrilovic" /> <input type="text" name="email" value="nikcub@email.com" /> <input type="submit" value="update" /> </form> very simple. if javascript detected, intercept form , use xmlhttprequest submit back. javascript supports other http methods, why do...

nhibernate - Does StructureMap have scoping corresponding to NInject's DefinesNamedScope/InNamedScope? -

the problem i'd solve sharing isessionprovider between ixyzrepositories (where isessionprovider holds current nhibernate isession). i'm tweaking "setting session per presenter" recipe nhibernate 3 cookbook , , keep structuremap (brownfield project). i think have create custom lifecyle that, although not sure trying accomplish... to create custom lifecycle, have implement ilifecycle interface , use in registration. here example can at: http://blog.mikeobrien.net/2010/01/creating-structuremap-lifecycle-for-wcf.html .

javascript - Stopping chrome from changing cursor to a globe while dragging a link -

i have standard link such as: <a href="/test">test</a> in chrome, clicking , dragging on link result in cursor changing arrow dragging globe. globe can dropped on url or bookmarks bar. i trying implement drag-and-drop filesystem interface in javascript. files , folders marked in "a" tags. when click drag one, globe icon appears , breaks javascript event (in case, jquery's mousemove). any ideas on how prevent chrome converting dragged links globe? edit : using well-placed event.preventdefault()'s resolve issue. try use event.preventdefault() in onmousedown <a href="/test.js" onmousedown="event.preventdefault()">test</a>

winapi - Add custom colors to TfontDialog in Delphi 7 -

how can add values color box in tfontdialog? or please tell me components can select font custom color? use delphi 7. thanks. i found way... how can show tcolordialog when color box changed on itemindex = 0? procedure tform1.fontdialog1show(sender: tobject); const idcolorcmb = $473; smycolorname: pchar = 'clmoneygreen'; cmycolor: tcolor = clmoneygreen; begin senddlgitemmessage(fontdialog1.handle, idcolorcmb, cb_insertstring, 0, integer(smycolorname)); senddlgitemmessage(fontdialog1.handle, idcolorcmb, cb_setitemdata, 0, colortorgb(cmycolor)); end; i think works: interface tfontdialog = class(dialogs.tfontdialog) const idcolorcmb = $473; protected procedure wndproc(var message: tmessage); override; procedure doshow; override; end; ... implementation procedure tform1.formcreate(sender: tobject); begin fontdialog1.execute(); end; { tfontdialog } procedure tfontdialog.doshow; const smycolorname: pchar = 'custom...'; cmycolor:...

java - BETWEEN query with JPA and Metamodel -

i trying write between query jpa 2. integer zipcode = 50000; criteriabuilder builder = getentitymanager().getcriteriabuilder(); criteriaquery<territory> query = builder.createquery(territory.class); metamodel m = getentitymanager().getmetamodel(); root<territory> root = query.from(territory.class); // zipcode between startzipcoderange , endzipcoderange predicate condition = builder.between(zipcode , root.get(territory_.startzipcoderange), root.get(territory_.endzipcoderange)); the final line not compile because zipcode not of type expression. possible convert zipcode expression? if so, how that. you can use root.get(territory_.zipcode) 1st parameter of between function if, territory have zipcode attribute. see comments on answer more details.

PHP/PEAR database-to-oop mapping engine? -

last week have spend on creating dynamic db-to-oop mapping engine in php. works pretty well. define db, make php classes same names, call 1 method, generates sql, fetches result, , creates appropriate objects it. you can apply different query filters, automatically joins parent tables, translation tables (for multi-language db), value tables (which don't have classes on php side), has build-in filter validator (so valid sql passed db) etc. etc. etc. it nothing revolutionary, careful table/class naming gets job done pretty well. later on, opened cpanel , had @ pear modules, , can see there many modules deal databases. i'm new pear, haven't used before. can tell me if there module similar, described above? make things clear, i'm not looking proxy generator, generate code classes, dynamic mapper, pretty on-fly . http://www.doctrine-project.org/ you're looking for? orm?

openwrap and r#6.0 -

i have updated resharper plugin r#6. my references no longer being picked wrap cache. i have set references manually. is there can do? the master branch of openwrap (2.0) has support resharper 6. to use private build of openwrap, test latest yourself: to code, can following: if have pulled code openwrap: cd path\to\openwrap git pull origin master otherwise git clone http://github.com/openrasta/openwrap path\to\openwrap cd path\to\openwrap then build: o build-wrap o update-wrap openwrap -sys

asp.net - How to turn around GridView? -

is possible display rows columns in gridview in such way first column has fields description? or maybe there control fits requirement better? a nice tutorial on pivot tables ado.net can found here through process. also build own, using repeater . can find example of using repeater here .

prototype programming - Javascript: Is it possible to inject new functions into a base 'class/object' that will be available in all sub-'classes/objects'? -

i trying add new property class in existing javascript framework (wireit). the base class called container , want containers have guid property. container sub-classed imagecontainer, formcontainer etc. if extend container have guid, guid available in imagecontainer, formcontainer etc.? how this? examples? the way prototypical oo works when : look property on object, imagecontainer it properties on object, if can't find on prototype ( imagecontainer.prototype ) if can't find on next prototype ('container.prototype') and next prototype ('object.prototype') until prototype chain empty in case returns undefined . this means if add property guid container.prototype.guid = 42; all objects container.prototype in prototype chain share property. if not want property shared it's difficult add unique guid objects container.prototype in prototype chain. you can use .isprototypeof check whether object has prototype in chain. exa...

How do I expedite this Excel VBA macro? -

i know little bit of vba looking smarter ways (the ways people work!!). here trying do. have deal data has year | month | day | hour | minute | data1 | data2.... | datan each in separate column , has thousands of rows. number of "data" columns defined user during run time (at least 1 , max 100). data may have time step eg every minute, 5 mins, 10 mins, each hour, daily , on. user specifies output data interval greater input data interval. so, macro supposed write data in interval specified user. data in each column in between output time step has added togther. see following 2 tables: input: yr mth day hr min data_1 data_2 2010 2 7 8 0 1.01 2.01 2010 2 7 8 5 1.02 2.02 2010 2 7 8 10 1.03 2.03 2010 2 7 8 15 1.04 2.04 2010 2 7 8 20 1.05 2.05 2010 2 7 8 25 1.06 2.06 2010 2 7 8 30 1.07 2.07 2010 2 7 8 35 1.08 2.08 2010 2 7 8 40 1.09 ...

php - Doctrine Update query with a sub-query -

i'm trying execute query, similar following one, using doctrine dql: doctrine_query::create() ->update('table a') ->set('a.amount', '(select sum(b.amount) table b b.client_id = a.id , b.regular = ? , b.finished = ?)', array(false, false)) ->execute(); but rises doctrine_query_exception message: "unknown component alias b" is restriction using sub-queries inside 'set' clause, can give me help? thanks in advance. i'm not sure if there's restriction on remember fighting sometime ago. got working with: $q = doctrine_manager::getinstance()->getcurrentconnection(); $q->execute("update table set a.amount = (select sum(b.amount) table b b.client_id = a.id , b.regular = 0 , b.finished = 0)"); see if trick. note automatic variable escaping doesn't executed query it's not dql.

c# - How to set Z index when using WPF DrawingContext? -

how set z-index drawing object when using drawingcontext.drawxxx() methods? the object drawn last have higher z index. can't change index of drawn objects. way draw in order. if using wpf (as placed tag), can use, example, canvas control. create shapes need like polyline obj = new polyline(); //... // ... set properties of obj and add them canvas uielementcollection: yourcanvasname.children.add(obj); //or yourcanvasname.children.insert(i, obj); first items of collection have higher z index. advantages in way: no need redraw on window changes, can anytime move objects , change order.

php - var_dump outputting string('**') "array" -

i using foreach loop , var_dump var_dump following code outputs strange. how rid of pre-prended sring() , quotation marks? $dir = 'url/dir/dir/'; $images_array = glob($dir.'*.jpg'); $images = array(); foreach ($images_array $image) { $images[] = str_replace($dir, '', $image); } var_dump(implode(',', $images)); output: string(51) "image1.jpg,image2.jpg,image3.jpg,image4.jpg" that's var_dump - prints datatype , length. if want output string use echo implode(',', $images);

android - Row color based on contents in the ListView of my RSS reader -

i android newbie , have built simple rss reader application based around free ibm android rss tutorial. change background color of each row if category of row equal particular string. i wrote following "for loop" discovers category of each item , runs if statement should category equal "news". @ moment background colour of entire listview gets changed feed supplied news category. does out there feel helping out beginner? for(int = 0; < feed.getitemcount(); i++) { if (feed.getitem(i).getcategory().equals("news")) { listview.setbackgroundcolor(0x77ee0044); } } you're going need inside getview() method of adapter. before return view in getview(), can call setbackgroundcolor() on view or use 1 of other setbackgroundfoo() methods. edit - given code, when create adapter, try: arrayadapter<rssitem> adapter = new arrayadapter<rssitem>( this,android.r.layout.simple_list_item_1,feed.getallitems(­))...

web services - Using a JAX-WS client, how do you get the SOAP header from a response? -

using jax-ws client, how soap header response? i'm guessing can using handlemessage method of soaphandler , feel i'm missing more obvious, straight-forward way. in soaphandler can soap message(getting header). straight-forward way. if want can code example you.

In Android, how do I smoothly fade the background from one color to another? (How to use threads) -

i've been playing android programming on , off couple of weeks, , i'm trying work seems simple, think missing something. what trying have background fade from, say, white black smoothly. i've tried few things, none of seem work. the first thing did using loop , setbackgroundcolor method linearlayout, changing r, g, , b values 0 255. doesn't work. i can one-of settings changes, when loop nothing last value. think happening ui locking while loop in progress , unfreezing when loop ends. i've tried putting delays in loop (ugly nested loop delays , thread.sleep), no avail. can give me pointers how working? need second thread change color? i've got vague idea of threads, although have never used them. my sample code showing trying follows: main.xml is: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" ...

c# - What "where" clause will make this Generic Method work? -

consider admittedly contrived generic definition: private void foo<t,basetype>(propertyinfo prop, basetype o1, basetype o2) { t value1 = (t) prop.getvalue(o1, null); t value2 = (t) prop.getvalue(o2, null); if (value1 != value2) console.writeline("not equal"); } prop guaranteed propertyinfo basetype. i getting compile error @ if() statement: operator '!=' cannot applied operands of type 't' , 't' while in "general case" understand error message valid, in case, want routine of standard types: system.int64, system.string, etc of support == , != operator. i assume can fixed "where" clause, icomparable , iequalable don't help. do know correct "where" clause is? frank since system.int64, system.string, etc .. list implement icomparable , use where t : icomparable and use compareto() instead of != for eg. code compile private void foo...

perl - Why don't I see race conditions when my processes are writing to file? -

i use parallel::forkmanager module fetching pages. below relevant code snippet: use parallel::forkmanager; open file,">myfile" or die "cann't open file$!"; $pm = new parallel::forkmanager(5); foreach $data (@all_data) { $pid = $pm->start , next; #doing fetching here , result on parsed_string print file $parsed_string; $pm->finish; # terminates child process } could expain why results ok , don't overlap 1 other there more 1 process writing same file ? give race. printing single line doesn't create resource contention. output program more of expect? use parallel::forkmanager; open file, '>', 'myfile' or die "cann't open file$!"; select file; $|++; $pm = parallel::forkmanager->new(5); foreach $data ( 0 .. 100 ) { $pid = $pm->start , next; #doing fetching here , result on parsed_string print file "1. "; sleep 1; print file "printing ...

php - Creating If/Else based on URL of page -

basically i'm trying create if/else statement based on url of current site im on. if/else statement going echo list based on alphabetical range. in other words, if url starts letters between (a-g) want echo 1 thing, , if starts letters (h-z) want echo else. script used on many websites. thanks <?php $uri = strtoupper(isset($_server['request_uri']) ? $_server['request_uri'] : '/cli'); if(ord($uri[1]) <= ord('g')) echo "echo 1 thing"; else echo "echo else";

c# - Entity Framework 4.0 Function Import - Why does it not show up as a method in my object context? -

i have stored procedure i've mapped in entity framework model (trying first one), , i've specified function import. stored procedure returns data set result, mapped complex type in function import. i'm using vs.net 2010. i think i've done of typical stuff required, i.e. http://msdn.microsoft.com/en-us/library/bb896231.aspx . there no model errors either. is there else need in order able call function import? has else had similar issue they've created function import returns complex type, yet didn't show callable function objectcontext? if not, there may recommend in order further investigate? edit: i'm executing stored procedures directly entity framework direct execution method, http://msdn.microsoft.com/en-us/library/ee358758.aspx . nice part still auto-maps complex types me. although love use function import approach... thanks it not show method on objectcontext on derived generated class. if using objectcontext directly must call ...

function as method argument in jquery without writing the entire function definition -

from understand, in jquery, when method requires function argument can't invoke predefined function this: $('#target').click(myfunction()); ...because "myfunction()" parsed , replaced value returned function...which no longer function.you have put entire function definition, in anonymous function: $('#target').click(function() { alert('handler .click() called.'); }); ...so, there way of invoking function it's required argument? you understand correctly. true not in jquery, how javascript works. when function needed argument, have give function argument, , not result of invocation. can use this: $('#target').click(myfunction); but alert need anonymous function because passing argument.

sql - Combine 2 rows to the same column -

hey query right alter procedure [ssrs].[volumecustomers] @userid int select casetypename, count(caseno) casecount, 'open' indicator orders.apcase ac (nolock) join orders.casetype ct (nolock) on ct.casetypeid = ac.casetypeid join workflow.workflowhistory wh (nolock) on wh.entityid = ac.caseid , tableid = dbo.gettableid('apcase', 'orders') , wh.active = 1 inner join workflow.workflowstep ws (nolock) on ws.workflowstepid = wh.workflowstepid , ws.nextstepid null (ac.active =1 , ac.createddate >= dateadd(day,-7,getdate()) , ac.createddate < getdate()) group casetypename union select casetypename, count(caseno) casecount, 'closed' indicator orders.apcase ac (nolock) join orders.casetype ct (nolock) on ct.casetypeid = ac.casetypeid join workflow.workflowhistory wh (nolock) on wh.entityid = ac.caseid , tableid = dbo.gettableid('apcase', 'orders') , wh.active = 1 join workflow.wo...

MPI - receive multiple int from task 0 (root) -

i solving problem. implementing cycling mapping, have 4 processors, 1 task mapped on processor 1 (root), , 3 others workers. using cyclic mapping, , have input several integers, e.g. 0-40. want each worker receive (in case 10 integers each worker), counting , save it. i using mpi_send send integers root, don't how multiply receive numbers same process (root). send int buffer size fixed on 1, when there number e.g. 12, bad things. how check length of int? any advice appreciated. thanks i'll assume you're working in c++, though question doesn't say. anyway, let's @ arguments of mpi_send: mpi_send(buf, count, datatype, dest, tag, comm) the second argument specifies how many data items want send. call means " buf points point in memory there count number of values, of them of type datatype , 1 after other: send them". lets send contents of entire array, this: int values[10]; (int i=0; i<10; i++) values[i] = i; mpi_send(values, 1...

jquery - redirect to a url after sliding up content -

i have code: $(".removeall").dblclick(function () { $(this).parent().slideup(); }); what want happen now, using jquery, redirect main.php after done this should trick: $(".removeall").dblclick(function(){ // slideup function takes 2 parameters, 'speed' animation, , // callback method called once animation done. $(this).parent().slideup("fast", function(){ window.location = "/main.php"; }); }); you can read more slideup method here .

ruby on rails - "Maybe IRB bug!" -

Image
what mean -- "maybe irb bug!"? tell me potential root cause of exception? note text "maybe irb bug!!" printed after stack trace part of exception output. this message means irb detected cause of stack trace being inside irb's own code, not in code entered executed. , depending on did before that, triggered bug in irb. a stack trace or segfault of tool (as opposed error in user-code) considered bug of time. tool should never die on user data, fail gracefully , meaningful error messages. 1 see here attempt 1 of :)

java - Date text box should be always 1st date current month.? -

i want javascript or java program should give date 1st of current month. there tech? you can use calendar java date date = new date(system.currenttimemillis()); cal = calendar.getinstance(); cal.settime(date); cal.set(calendar.day_of_month, 1); now every want calendar object day of week (sat, sun, .... ) int weekday = cal.get(calendar.day_of_week); and javascript can use: var thefirst = new date(); thefirst.setdate(1); setdate sets day of month date object (from 1 31) . can whatever want thefirst, day of week.

asp.net - gridview header that contains a div -

is possible put div inside header cell? thanks. if it's template field, have <asp:templatefield> <headertemplate> <div> div contents </div> </headertemplate> </asp:templatefield>

database - Data model for a C# winform application -

i'm writing winform program following data model: the data structure described set of class , subclass once store data, i'm serializing class xml file. when software running data must accessed fast (the data model accessed between 50 , 60 per second. i plan move data storage xml file lite database. my question following: realistic use database not storage, during program execution? face loss of performance? if don't need update data regularly, read it, best keep in memory. we know little app, cannot give better advice here. maybe in case enough keep xml in xpathdocument structure, can perform fast searches using xpath queries. another option be, if data key/value pairs, read xml dictionary , search dictionary in app. but reading database, light one, hardly faster. counter-case can think of read-optimized fast nosql-db such mongodb. money on in-memory data structure optimized searching.

Memory problem in NSXMLParser (iPhone) -

hi i'm trying parse xml , use currentelementvalue inside code expiredate. code. if([elementname isequaltostring:@"utlop"]) { nsdate *now = [nsdate datewithtimeintervalsincenow:0]; nsdateformatter *dateformat = [[nsdateformatter alloc] init]; [dateformat setdatestyle:nsdateformattershortstyle]; int numberofdays = [currentelementvalue intvalue]; nsdate *expiredate = [now addtimeinterval:60*60*24*numberofdays]; nsstring *expirestring = [dateformat stringfromdate:expiredate]; nslog(@"expirystring :%@", expirestring); //add values vare envare.utlop = expirestring; envare.enhet = enhet; envare.isdirty = no; //add vare [appdelegate addvare:envare]; //releasing [dateformat release]; [envare release]; envare = nil; [currentelementvalue release]; currentelementvalue = nil; [expirestring release]; expirestring = nil; this results in memory leak, im new objective c can't fi...

c++ - Array of sse type: Segmentation Fault -

today tried initialize array of sse type __m128d. unfortunately didn't work - why? impossible create arrays of sse types (since register types?). following code segfaults @ assignment in loop. __m128d* _buffers = new __m128d[32]; for(int i=0;i<32;i++) _buffers[i] = _mm_setzero_pd(); regards + boom you must use _mm_malloc() or _aligned_malloc(), depending on what's preferred function name on compiler. __m128[di] in combination new bad mojo.

symfony1 - symfony 1.4: How to get the assignated id (in the db of course..) of an embedded form's object? -

how assignated id (in db of course..) of embedded form's object? it's 1:m relation. sf 1.4 javi try this: echo $form->getembeddedform('your_embedded_form_name')->getobject()->getid();

Google app engine datastore tag cloud with python -

we have unstructured textual data in our app engine datastore. wanted create 'one off' tag cloud of 1 property on subset of datastore objects. after around, can't see framework allow me without writing myself. the way had in mind was: write map (as in map reduce) function go on every object of particular type in datastore, split text string words for each word increment counter use final counts generate tag cloud third party software (offline - suggestions here welcome) as i've never done before, wandering if firstly there framework around me ( please ) of if not approaching in right way. i.e please feel free point out gaping holes in plan. feed tagcloud , pytagcloud 2 possibilities. feed tagcloud generator gadget google app engine might fit needs. unfortunately, it's undocumented. fortunately it's rather simple, though i'm not sure how well-suited needs. it operates on feed, , appears flexible, if have feed of site, might n...

How to escape strings in bash script -

i running bash script calls mysql. password ist not correctly transmitted, guess have escape special chars, hash or dollar sign? #!/bin/bash user=myuser pass="#mypass$" # ... call mysql using "..." correct thing do, $ needs escaped ( \$ ) if isn't followed "invalid" character. need make sure have variable in quotation marks well, in: somecommand -p "$pass"

firefox extension global variable -

how can save values event function global variable in firefox extension or there better way? code: var bs = { onload: function() {...}, onpress: function(e) {...}, onmenuitemcommand: function(e) {...}, ontoolbarbuttoncommand: function(e) {...}, }; window.addeventlistener("load", function () { bs.onload(); }, false); document.addeventlistener("keypress", function(e) {bs.onpress(e); }, false, true); tried initialize before "var bs" variable reset. best, us found solution, if declare variable this: window['variablename'] = ""; you can access in functions.

javascript - Backbone.js: Existing View events continue to fire -

in view, have events fire onclick of element. unfortunately, when create new view model, existing events of first model/view pair continue fire. ends happening save() continues use existing model instead of new 1 , can never create new model , use model without refreshing page. i'm new backbone.js, there way save() existing model remove view? if i'm not making sense, please let me know. any appreciated! much. $(function() { var game = backbone.model.extend({ defaults: { begun: false, currentplayer: 1 }, play: function() { console.log(this.id); var player = (this.get('currentplayer') == 1) ? 2 : 1; this.save({ 'currentplayer': player, 'begun': true }); } }); var gamelist = backbone.collection.extend({ model: game, localstorage: new store('game'), existing: function() { return this.filter(function(game){ return game.get('begun'); }); }, u...

android - How to play media file -

i using following code play audio file. have tested audio file on android phone player & playing quite loud. when trying play same audio file following code , feeble. there problem code ? can increase volume of media file changing value ? while testing , volume of android device has been put maximum value. kindly provide inputs/sample code. in advance. public void playalertsound() { mediaplayer player = mediaplayer.create(this, r.raw.beep); player.setlooping(false); // set looping player.setvolume(0.90f, 0.90f); // begin playing selected media player.start(); // release media instance system player.release(); } try player.setvolume(1.0f, 1.0f); instead; or leave off line entirely. can try scaling value past 1.0, although that's not recommended.

jsf - How to set -Dorg.apache.el.parser.COERCE_TO_ZERO=false programmatically -

this question similar to: jsf: integer property binded inputtext in ui set 0 on submit but not satisfied solution. contexts same: have web form requiring integer value. if textbox left empty, want integer field 'null' instead el parser automatically sets id field '0'. i can fix problem setting jvm parameter in local tomcat vm: -dorg.apache.el.parser.coerce_to_zero=false however, not work our client's machine. possible set/change jvm parameter "in-code". update: i've found being requested if else has other workaround, hear too. https://issues.apache.org/bugzilla/show_bug.cgi?id=48813 update 2: can't change value '0' 'null' because application should treat '0' actual id. need know @ runtime whether id textbox left empty or not. you can set system properties programmatically using system#setproperty() . system.setproperty("org.apache.el.parser.coerce_to_zero", "false"...

javascript - Jquery UI: clone the widget -

i need dynamically create jquery ui widget. idea have widget hidden , use function clone() create them.. result this: example what's wrong? thank in advance help. this known problem . associated jquery ui feature request can found here . this feature require cooperation jquery ui widgets (through modifications init() methods). dev team not seem interested in implementing now, though might in future.

mysql - where to find Drupal 7 DB schema? -

i have query in drupal 6 select term_data.tid tid, term_data.name term_data_name, term_data.vid term_data_vid, term_data.weight term_data_weight term_data term_data left join term_node term_node on term_data.tid = term_node.tid inner join node node_term_node on term_node.vid = node_term_node.vid how can migrate 1 drupal 7 schema? have this, it's not working select taxonomy_term_data.tid, taxonomy_term_data.vid, taxonomy_term_data.name taxonomy_term_data left join taxonomy_index on taxonomy_term_data.tid = taxonomy_index.tid inner join node on taxonomy_index.vid = node.vid the problem taxonomy_index.vid doesn't exist. i haven't found drupal 7 database schema documentation, idea? please $terms = db_select('term_data', 'td') ->fields('td', array('tid', 'name', 'vid', 'weight')) ->leftjoin('term_node', 'tn', 'td.tid = tn.tid') ->join('node',...

c# - Delete application files after it runs -

i'm busy creating custom uninstall application. i know how delete application programmaticly after has run. i'm using standard winform app coded in c# we have application uses clickonce deployment. wish create uninstall function that. have uninstall working fine, need delete uninstall application well. should single exe file needs deleted, after it's done thing. i not wish have remaining file left on user's machine i think question asked here . have use movefileex api, which, when given movefile_delay_until_reboot flag, delete specified file on next system startup. here have sample: internal enum movefileflags { movefile_replace_existing = 1, movefile_copy_allowed = 2, movefile_delay_until_reboot = 4, movefile_write_through = 8 } [system.runtime.interopservices.dllimportattribute("kernel32.dll",entrypoint="movefileex")] internal static extern bool movefileex(string lpexistingfilename, string lpnewfilename, mo...

Drupal 6, how to publish node from code -

how publish node php code? tried simple query db_query("update {node} set status = 1 nid = %d", $nid); doesn't work. scenario: default nodes unpublished. i'm altering edit-node form add textfield. if user enters right code node become published. adding submit function in form_alter , in function checking code , if it's right trying update node status published. <?php // load node object $node = node_load($nid); // set status property 1 $node->status = 1; // re-save node node_save($node); ?> also, saw comment of using $form['nid']['#value']. sure variable holds node id value? executing code on submit handler of form, means using like: $form_state['values']['nid'] value of $form['nid'] element. example: <?php function mymodule_myform() { $form = array(); $form['nid'] = array( '#type' => 'textfield', '#title' => 'node id publish' ); ...

ruby on rails - problem when uploading photos to Amazon s3 using paperclip -

my model: has_attached_file :avatar, :styles => { :thumb => "65x65>" }, :storage => :s3, :s3_credentials => "#{rails_root}/config/s3.yml", :bucket => "doweet-image", :path => ":attachment/:id/:style.:extension" when i'm uploading image amazon s3, , putting on view: <%= image_tag(current_user.avatar.url(:small))%> the photo not show up, , when i'm copy link src photo is: http://s3.amazonaws.com/doweet-image/avatars/1/small.jpg?1311356386 and when going link i'm getting there error: this xml file not appear have style information associated it. document tree shown below. <error> <code>accessdenied</code> <message>access denied</message> <requestid>152ebfc9033e6633</requestid> <hostid> iw3zwxucc6jjpajig+pbvqqbliln4dmty4voovo5cvkch3o/mn3vdawxbi6zd5np </hostid> </error> go s3 bucket , make sure folder has read access...

Join on two different Objects: Linq -

i have trouble on joining iobjectset<t> ienumerable<int> , t has type int property. can join objects of kind. how ever if convert iobjectset list can join them. ideas on reason why happens? 1 experienced this? you're going have bring collection in memory. can't join across database , collection in memory, ef query provider mad @ you.

c# - Queueing framework solution -

i address such issue: have html form (like register form) submission sends email. send part of page request. obvious drawbacks: makes request longer sometimes smtp server down, or timeouts , emails not sent when working php used solution based on queue - had been putting object/xml queue host, , kind of client checked queue. if queue task sucessfully handled removed task queue. wonder, there similar implementation on windows / .net platform ? thanks,paweł there robust queuing offered msmq easy use in .net. accessing message queues might place start.

c++ - error: invalid use of 'Config::testMap' -

here code: #include <iostream> #include <string> #include <map> #include <stdexcept> #include <boost/ptr_container/ptr_vector.hpp> struct teststruct { std::string str1; int var1; }; struct config { // map typedef std::map< std::string, boost::ptr_vector<struct teststruct> > testmap; }; void foo(config& config) { if (config.testmap.empty()) { std::cout << "it worked!" << std::endl; } else { std::cout << "it didn't work!" << std::endl; } return; } int testmain(void) { config config; foo(config); return; } int main(void) { try { return testmain(/*argc, argv*/); } catch(std::exception& err) { std::cerr << "error running program: " << err.what() << std::endl; return 1; } catch(...) { std::cerr << "program fail...