Posts

Showing posts from June, 2013

Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

networking - tcp session in java -

i want connect morethan 1 client @ time server , communicate server clients. how server recognize each client. , how send data particular client? consider , there 3 clients a,b,c. clients connected server. server wants send message b. how done ? if understand right - need not bind socket 1 connection. client code looks that: client class: public class tcpclient { public tcpclient(string host, int port) { try { clientsocket = new socket(host, port); } catch (ioexception e) { system.out.println(" not connect on port: " + port + " " + host); } } server(host) class: public class tcplistener { public tcplistener(int portnumber) { try { serversocket = new serversocket(portnumber); } catch (ioexception e) { system.out.println("could not listen on port: " + portnumber); } system.out.println("tcpliste

cocoa touch - Objective C switch statements and named integer constants -

i have controller serves delegate 2 scrollviews placed in view managed aforementioned view controller. to distinguish between 2 scroll views i'm trying use switch statement (instead of simple pointer comparison if statement). have tagged both scroll views 0 , 1 this nsuinteger const kfirstscrollview = 0; nsuinteger const ksecondscrollview = 1; when try use these constants in switch statement, compiler says case statements not constants. switch (scrollview.tag) { case kfirstscrollview: { // stuff } case ksecondscrollview: { // stuff } } what doing wrong? this can solved through use of anonymous (though not so) enum type: enum { kfirstscrollview = 0, ksecondscrollview = 1 }; switch (scrollview.tag) { case kfirstscrollview: { // stuff } case ksecondscrollview: { // stuff } } this compile without errors.

html - Finding a word and replacing using regular expressions in javascript -

i need information finding word , replacing regular expressions in javascript. you can use \b specify word boundary. put them around word want replace. example: var s = "that's car."; s = /\ba\b/g.replace(s, "the"); the variable s contains string "that's car" . notice "a" in "that's" , "car" unaffected.

android - how to build a view like the default SMS thread view? -

the sms thread view this: ==here icon of 'someone'== someone: xxxxxx me: xxx someone: xxxxxx me: xxx ===here editbox== =button= ok, hope ugly sample above can make question more clear you. suppose, view not listview, either textview. seems textview not support scroll function. , listview hightlight list item when click it. i'm not familiar gui programming, hope can give me advance. thanks. if don't need click on each line, can still use listview android:clickable="false" , wan't highlight item. also, if choose use textview, can wrap in scrollview, make scrollable.

javascript - Is there any way to detect when a CSS file has been fully loaded? -

i've been testing lot of lazy-loaders javascript , css insert <script> , <link> tags load files. problem is, <link> tags don't fire onload it's difficult detect when they're loaded. workaround found set display: none; (in css file loaded) on dummy element , poll element check when has been set display: none. that, apart being ugly, of course works single css file. so wondering; there other way detect if css file has been loaded? thanks, lukas -- ps: found solution, it's @ bottom of page. (i'm new stackoverflow , i'm sure answer supposed @ bottom, think overseen if googleusers stuble upon page, wrote little note) edit: should noted browser support onload events on css files has improved since original answer. not supported though, answer below still has relevance. here compatibility chart , not sure how legit source though. ok, found solution. this guy http://tugll.tugraz.at/96784/weblog/9080.html inserts li

php - Is it possible to Copy images from web to your Hard Drive? -

i trying create page personal use. want is, create system through can download images local hard disk, directly providing link through localhost wamp. reason trying is, want images automatically sorted onto hard disk. form field this <form method="post" action="process.php"> <input type="text" name="url" id="url" /> <input type="text" name="category" id="category" /> <input type="text" name="subcategory" id="category" /> <input type="submit"> </form> now, in process.php //this sample... please ignore roughness of coding copy($_post['url'],$_post['category']."/".$_post['subcategory']."/somename.jpg"); // if noticed, categories , subcategories name of directory, want picture go saved.... i thinking approach wrong. how can achieve this? error warning: copy(image

linux - Find files older than X days excluding some other files -

i'm trying write shell script, linux , solaris, finds specific files older x days , deletes them. trick during process there couple of files must not deleted. for example following list of files need delete *.zip , keep *.log , *.something.* 1.zip 2.zip 3.log prefix.something.suffix finding files , feeding them rm easy, i'm having difficulties in excluding files deletion list. experimenting around discovered 1 can benefit multiple complex expressions grouped logical operators this: find -l path -type f \( -name '*.log' \) -a ! \( -name '*.zip' -o -name '*something*' \) -mtime +3 cheers, g

extjs - Ext.js Editable TreeNodes -

is possible make treenodes (i.e. folders) editable user? see there's option called editable in treenode class couldn't working or find examples on usage. my other quest place input box in nodes so, user can enter numbers each item. how can it? adding new ext.tree.treeeditor(yourtree); enough make tree editable. but can define more using other 2 contructors parameters: var te = new ext.tree.treeeditor(tree, new ext.form.numberfield({ allowblank: false, blanktext: 'a number required' }), { editdelay: 100, revertinvalid: false }); te.on("complete", function(node) { alert(node.startvalue + ' -> ' + node.editnode.text); }); there used numberfield can enter numbers in there. and can restrict edition using editable property of every treenode (yes, 1 mentioned), or using beforestartedit event of treeeditor: te.on('beforestartedit', function(ed, boundel, value) { if (ed.editnode.leaf) retur

iphone - I'm trying to get a count of records from a related entity that match a criteria -

i have entity matches has related to-many entity sets. want count of how many sets have attribute 'set_finished' set yes particular match. i'm trying with: nspredicate *predicate = [nspredicate predicatewithformat:@"any set_finished == yes"]; nsuinteger numberoffinishedsets = [[[match valueforkeypath:@"sets"] filteredarrayusingpredicate:predicate ] count]; the second line crashes error, don't understand. can shed light on me? thanks. 2010-12-20 13:17:13.814 dartscorer[2154:207] * terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[_nsfaultingmutableset filteredarrayusingpredicate:]: unrecognized selector sent instance 0x617fb20' you should use filteredsetusingpredicate: instead of filteredarrayusingpredicate since object set, not array.

Universal library for C++ strings -

please recommend me universal library c++ strings. want manipulate ascii text , unicode text in 1 build without making 2 versions of builds std::string/char , std::wstring/wchar; want convert them each other (where possible); thank much!!! just use std::wstring , then. ascii perfect subset of unicode (and iso 8859-1 latin-1 sits in middle). ascii 0x5d u+005d etcetera.

c - i can't hold old entries -

#include <stdio.h> #include <stdlib.h> void push(int p) { static int i=0; int b; int *ptr =(int *)malloc((10)*sizeof(int)); ptr[i]=p; for(b=0;b<=i;b++){ printf("%d",ptr[b]); printf("\n"); } i++; } int main() { int a; while(1) { scanf("%d",&a); push(a); } } when put new values , function not hold old entries.i wait helps. #include <stdio.h> #include <stdlib.h> void push(int p) { static int = 0; static int ptr[10]; // since not freeing memory later, // there's no need use malloc. ptr[i] = p; int b; (b = 0; b <= i; b++) { printf("ptr[%d] --> %d\n", b, ptr[b]); } printf("\n"); i++; } int main() { int a; while(1) { scanf("%d",&a); push(a); } return 0; // main() expects return something, remember? }

java - disabling children of a JPanel -

suppose have hierarchy this: jpanel panel1; jcheckbox cb1; jcheckbox cb2; jradiobutton rb1; jradiobutton rb2; ... i have condition want set individual groups of controls within panel enabled/disabled. works fine. (e.g. enable cb1 , cb2 when 1 condition true, disable them when false.) i disable , re-enable whole panel. if call panel1.setenabled(false) not work, disables panel, not affect children. if enumerate panel's children, , call setenabled(false) on each of them, work, have store child enabled state when re-enable panel. is there simpler way? you can put glass pane on panel have intercept events. http://download.oracle.com/javase/tutorial/uiswing/components/rootpane.html

cookies - ASP.NET: Does FormsCookie go away when authentication period expires? -

i'm trying establish authentication timeout expiration checking, , i'm noticing little strange. when authentication period still valid, following code give me cookie: httpcookie authcookie = context.request.cookies[".aspxauth"]; // .aspxauth name defined in web.config but when authentication period has expired, cookie no longer in cookies array, , result null. i'm trying build formsauthenticationticket object cookie, able check expired property. this: formsauthenticationticket authticket = formsauthentication.decrypt(authcookie.value); // check if authenticated session dead if (authticket != null && authticket.expired) { // send response indicating they've expired. } but if cookie goes away once authentication period has expired, can't far. there i'm doing wrong, or cookie not supposed there? , if not, how supposed build ticket check expired property? thanks much. the cookie has expiration timeout value can specify

activator - c# string to class form wich i can call functions -

on initialize class string variable in c#? found out how create class using string so have : type type = type.gettype("project.start"); var class = activator.createinstance(type); what want call function on class example: class.foo(); is possible? , if how? type yourtype = type.gettype("project.start"); object yourobject = activator.createinstance(yourtype); object result = yourtype.getmethod("foo") .invoke(yourobject, null);

php - How to have two password fields controlled by one checkbox? -

<form> <fieldset> password: <span id="capsalert">caps lock = on</span><br> <input type="password" id="pwd"> <script type="text/javascript"> document.write( '<input type="checkbox" name="masking" onclick="unmask(this.checked)"> ' + 'show password type' ); </script> <br> password2:<br> <input type="password" id="pwd2"> </fieldset> </form> <script type="text/javascript"> function chkcaps(e) { ev = (e ? e : window.event); kc = (ev.which ? ev.which : (ev.keycode ? ev.keycode : false)); sk = (ev.shiftkey ? ev.shiftkey : (ev.modifiers ? !!(ev.modifiers & 4) : false)); if( (kc >= 97 && kc <= 122 && sk) || (kc >= 65 && kc <= 90 && !sk) ) { document.getelementbyid('capsalert').style.display = 'i

How to check MySQL performance? -

i have mysql used on production server php webshop application. sometimes works slow. so, change indexes several tables. but before that, have make kind of "snapshot" of current performances (several times per day). after that, change indexes, , create new "performance snapshot". made more changes in database, , made "performance snapshot". how can make "performance snapshot"? possible use kind of tool, or ckeck logs, or...? if can me how that. thank in advance! if want buy commercial product, there mysql query analyzer otherwise, use sql profiler included mysql. the sql profiler built database server , can dynamically enabled/disabled via mysql client utility. begin profiling 1 or more sql queries, issue following command: mysql> set profiling=1; thereafter, see duration of each of queries run them.

iphone - Uiimagepickercontroller, volume overlay not work -

i'm developing app use uiimagepickercontroller. app launches first uiimagepickercontroller source type setted "camera" , user can press tabbar item launch imagepickercontroller source type on "photosavedalbums". works not default volume (the volume can set hardware buttons of iphone),with sourcetype "camera" volume disabled (and there isn't overlay bell) sourcetype "savedphotosalbum" volume works , overlay bell appears. have noticed default behavior of camera app same of application,but @ same time i've seen many others apps permits set volume in imagepickercontroller sourcetype "camera". have tried many hours,i can't found solution. ideas? can't find audio property work! the solution make visible overlay volume control use avfoundation framework instead of classic uiimagepickercontroller.

asp.net mvc - What is FormCollection argument for? Is it a dummy argument? -

up have no idea why vs provide formcollection argument default? public actionresult edit(int id) { dinner dinner = dinnerrepository.getdinnerbyid(id); if (dinner == null) return view("notfound"); else return view(dinner); } [httppost] public actionresult edit(int id, object dummy/*, formcollection collection*/) { dinner temp = dinnerrepository.getdinnerbyid(id); if (tryupdatemodel(temp)) { dinnerrepository.save(); return redirecttoaction("details", new { id = temp.dinnerid }); } else return view(temp); } edit 1: in experiment, arguments other id dummy because never used in httppost edit action method. edit 2: tryupdatemodel use formcollection behind scene? the formcollection how asp.net provides access values posted page. you use typed argument , asp.net mvc use formcollection internally crea

Can I put a Button in a RichTextBox in Silverlight 4? -

i allow users put system.windows.controls.button in system.windows.controls.richtextbox. button pre-defined thing. i figured out how this. it's called inlineuicontainer can working. although doesn't save xaml var p = new paragraph(); var inlineuicontainer = new inlineuicontainer() { child = new button() { content = "this button!" } }; p.inlines.add(inlineuicontainer); _richtextbox.blocks.add(p);

.net - How to change server time? -

i need change server time asp.net page. possible? possible or not, it's bad idea. , way can think of allowing if user account app pool executing under has serious access rights machine; bad idea. servers should sync'd time server. controlled @ os level. all sorts of funky things can happen once 1 server in mix gets out of acceptable date range. which leads question: why? update you pinvoke setsystemtime. require user app pool running under have sesystemtimeprivilege. more information , example of pinvoking here: http://bytes.com/topic/c-sharp/answers/274594-how-set-system-date-c again, bad idea(tm).

zsh - Z Shell "autoload" builtin - what is it good for? -

i have been using z shell while now, , starting curious. 1 thing have stumbled @ when writing own functions "autoload". according zshbuiltins(1) man page autoload "equivalent functions -u " (with exception), "equivalent typeset -f " (with exception). however, after looking @ autlooad use of, functions/prompts/promptinit , think have idea does. i think of autoload as, well, kind of "import" statement. but why "autoload foo" superior "source bar"? don't that. as stated in zsh documentation : a function can marked undefined using autoload builtin (or functions -u or typeset -fu ). such function has no body. when function first executed, shell searches definition using elements of fpath variable. [...] autoload allows functions specified without body automatically loaded when used ;) source takes argument script executed in environment of current session - i.e. retain changes scr

Can't delete posts in forum. (CakePHP) -

i'm using cupcake forum plugin within cakephp. there's form selecting desired posts, , submitting form delete posts. form data apparently being sent 'moderate' function within 'topics' controller using post , methods simultaneously. function first checks see if data sent in post. however, when data received, shows it's get. fellow programmer , don't want change else's internal code, can't figure out how data being sent both methods , being received get. code plugin below: --------------moderate.ctp (view)--------------------- <?php echo $form->create('post', array('url' => array('controller' => 'topics', 'action' => 'moderate', $topic['topic']['slug']))); ?> -------------topics_controller.php (controller)------- public function moderate($id) { if ($this->requesthandler->isget()){ $this->log('is get!'); } $user_i

osx - How to programatically arrange windows like in expose with Cocoa? -

i know if there way programatically arrange desktop windows similar expose in cocoa. thanks. the best can think of off top of head (somewhat clumsy, , doesn't continue show moving content, should work): draw contents of each of windows images create new windows showing images (set scale window resizing), , hide old calculate new positions each window (a first approximation scale them same size, tile them) call -setframe:animate: on of them alternately, same trick instead of using real windows, make 1 screen-sized transparent window , move calayers around in it. good luck! tricky thing well.

c# - MasterPage Load Theme -

on asp.net c#, want change theme when page load, action requiers preinit event, masterpage dont have. solution issue? thanks, one way create http module (rick van den bosch blogs)

.net - Comparing file contents in F# -

i wrote quick , dirty function compare file contents (btw, have tested of equal size): let eqfiles f1 f2 = let bytes1 = seq.ofarray (file.readallbytes f1) let bytes2 = seq.ofarray (file.readallbytes f2) let res = seq.comparewith (fun x y -> (int x) - (int y)) bytes1 bytes2 res = 0 i'm not happy reading whole contents array. i'd rather have lazy sequence of bytes, can't find right api in f#. if want use full power of f#, can asynchronously. idea can asynchronously read block of specified size both files , compare blocks (using standard & simple comparison of byte arrays). this interesting problem, because need generate asynchronous sequence (a sequence of async<t> values generated on demand, without blocking threads simple seq<t> or iteration). function read data , declaration of async sequence this: edit posted snippet http://fssnip.net/1k has nicer f# formatting :-) open system.io /// represents sequence of values '

html - Fluid Floating Elements Wrapped in Container -

i have following test code play around with: http://jsfiddle.net/b6qfy/1/ i want "left" element fixed , "right" element fluid within parent container grow , shrink browser width changes, , not wrap. seems simple, have issues getting work. my answer on question edit: here example (with borders replaced bgs)

How to increase 2MB limit on AJAX JSON response w/ ASP.NET MVC -

i having problems making ajax call when response on 2mb. response under 2mb works fine. when response on 2mb, "success" method never gets called. my application asp.net mvc2. making call using jquery ajax call: $.ajax({ type: "post", data: ajaxdata, url: ajaxurl, success: updateitems, cache: false }); in controller, using json() action result method: public actionresult getitems(....) { ... return json(packet); } when watch call in fiddler comes http 500 response. i tried setting maxjsonlength in web.config file shown here , doesn't seem make difference. any suggestions on how allow response on 2mb? thanks in advance, skip you add following web.config: <system.web.extensions> <scripting> <webservices> <jsonserialization maxjsonlength="1000000000" /> </webservices> </scripting> </system.web.extensions>

delphi - Do C++ Templates play nicely with VCL classes? -

i'm trying use c++ template 'mixins' create new vcl components shared additional functionality. example... template <class t> class mixin : public t { private: typedef t inherited; // ...additional methods public: mixin(tcomponent *owner) : inherited(owner) { // .. stuff here }; }; used this: class mylabel : public mixin<tlabel> { .... } class myedit : public mixin<tedit> { .... } now, compiles fine, , mixin stuff seems work - until try , save component stream using tstream->writecomponent, inherited properties (eg tlabel.width/height/etc.) don't written. 'null' mixin 1 shown above. my code works fine when deriving classes directly tform, tedit, etc - , class correctly registered streaming system. the quick/simple answer is: no; when dealing template, compiler won't generate proper descriptors make streaming working. however, since has come before, peeked under cover find out what's missing. ,

jquery - How can I cover a div with a semi-transparent image? -

i want cover <div> looks has semi-transparent block on it. i using jquery not know how it. any thanks... if have div , can dimensions + position like var $somediv = $('#some_div_element'), pos = $.extend({ width: $somediv.outerwidth(), height: $somediv.outerheight() }, $somediv.position()); and use while dynamically creating overlay $('<div>', { id: 'overlay', css: { position: 'absolute', top: pos.top, left: pos.left, width: pos.width, height: pos.height, backgroundcolor: '#000', opacity: 0.50 } }).appendto($somediv); example: http://www.jsfiddle.net/gkfu4/1/

nvarchar - Handling larger strings in Sql Server 2008 -

we have stored procedure created user can write comma separated search tags in software product's admin. can add comma-separated tags , in case if wants edit them, read table tags, recreate them comma-separated values (csv) in stored procedure , returns calling code. happened recently, user complained not see new csvs wrote. looked , found out stored procedure truncating string when reads values database , creates csv string. string of type nvarchar, , because exceeding max characters of 4000 limit, values gets truncated. ideas on how work out problem. find code underneath. begin begin declare @synonyms table ( rowid int identity(1,1), synonymid int, [synonym] nvarchar(4000) ); set nocount on; insert @synonyms(synonymid, [synonym]) select distinct synonymid, [synonym] rf_searchsynonyms with(nolock) searchtermid = @searchtermid , activeind = 1 if((select count(rowid) @synonyms) <> 0) begin declare @cur

php - How do I weed out similar items from an associative array? -

update: edited question incorrectly, it's fixed now let's have following associative array: array ( [postponement no issue man utd (bbc) ] => 8 [postponement no issue man utd ] => 7 [postponement no issue man utd: manchester united have no issue on sunday's game @ chelsea being ... ] => 3 ) you'll notice term "postponement no issue man utd" appears in 3 keys. want turn array new array this: array ( [postponement no issue man utd] => 18 ) where 18 sum of values key contains "postponement no issue man utd". in other words: if 1 key appears inside key, latter dropped fom new array , it's value added on former key's value. is possible , how? in advance. depending on size of data may not feasible. there more optimal solution, works: <?php $array = array( 'postponement no issue man utd (bbc)' => 8, 'postponement no issue man utd' => 7, 'postponement no issue man u

Can local intranet application (built on php) query mysql database stored in offsite location? -

i have local intranet application runs off basic wamp server in our offices. every morning, 1 of our team members manually syncs our internal mysql db our external mysql db (where our online enrollments occur). if change made during day on intranet application, not reflected on external db until following day. i wondering if possible (essentially) tunnel external mysql connection wamp or xampp server within our offices , work in 'real-time'. anybody had luck or advice? yes replication enables data 1 mysql database server (the master) replicated 1 or more mysql database servers (the slaves). replication asynchronous - slaves need not connected permanently receive updates master. means updates can occur on long-distance connections , on temporary or intermittent connections such dial-up service. depending on configuration, can replicate databases, selected databases, or selected tables within database. if use external server directly, performance suffer.

python - Combine --user with --prefix error with setup.py install -

i trying install python packages system gained access to. trying take advantage of python's relatively new per user site-packages directory , , new option --user . (the option currently undocumented , exists python 2.6+; can see running python setup.py install --help .) when tried running python setup.py install --user on package downloaded, got following error: error: can't combine user with prefix/exec_prefix/home or install_(plat)base the error extremely perplexing because, can see, wasn't providing --prefix , --exec-prefix , --install-base , or --install-platbase flags command line options. wasted lot of time trying figure out problem was. document answer below, in hopes spare other poor soul few hours of yak shaving . one time workaround: pip install --user --install-option="--prefix=" <package_name> or python setup.py install --user --prefix= note there no text (not whitespace) after = . do not forget --user flag.

c# getting item in row from datatable -

foreach (datarow row in dt.rows) { string[] temprow={"","","",row[3].tostring()}; dtworklist.rows.add(temprow); } dt datatable. need 3rd element in row , put array. above tried far no luck. how do it? try this: int i=0; list<string> l=new list<string>(); foreach (datarow row in dt.rows) { l.add(convert.tostring(row[2])); } string[] stringarray=l.toarray();

jQuery changing the name of a field -

im trying change name of field on change state of select list. i have following code <script> $('#selectintrole').change(function(){ $('#proven_keyname').val($(this).val()); }; </script> <select name="item_options" id="selectintrole"> <option value="20030">universal (20030)</option> <option value="4545456">medium (4545456)</option> <option value="15447">large (15447)</option> </select> <input name="proven" value="1" type="checkbox" id="proven_keyname" /> it doesnt seem doing though ... when check generated source, nothing has changed .... missing something? i think need bind change event after document ready so $(function () { $('#selectintrole').change(function () { $('#proven_keyname').val($(this).val()); }); }); if want change nam

Passing Numpy arrays to C code wrapped with Cython -

i have small bit of existing c code want wrap using cython. want able set number of numpy arrays, , pass arrays arguments c code functions take standard c arrays (1d , 2d). i'm little stuck in terms of figuring out how write proper .pyx code handle things. there handful of functions, typical function in file funcs.h looks like: double innerproduct(double *a, double **coords1, double **coords2, const int len) i have .pyx file has corresponding line: cdef extern "funcs.h": double innerproduct(double *a, double **coords1, double **coords2, int len) where got rid of const because cython doesn't support it. i'm stuck wrapper code should pass mxn numpy array **coords1 , **coords2 arguments. i've struggled find correct documentation or tutorials type of problem. suggestions appreciated. you want cython's "typed memoryviews" feature, can read in full gory detail here . newer, more unified way work numpy or other arrays. t

xorg - Version information on Xserver modules -

i trying find tool extract module version information (a part of module record) fron xserver module. example, in xorg logs can see following information librecord module in xorg.0.log file... [ 39.892] (ii) loading /usr/lib/xorg/modules/extensions/librecord.so [ 39.905] (ii) module record: vendor="x.org foundation" [ 39.905] compiled 1.9.0, module version = 1.13.0 [ 39.905] module class: x.org server extension [ 39.905] abi class: x.org server extension, version 4.0 is there tools allow me extract aforementioned information. can use modinfo on module , have version information, not work. consistent way know of parse xorg log file. thanks. yes, there , can try write small one. http://gitorious.org/xdriverprobe the problem xdriverprobe won't compile on newer servers since didn't update newest abis. also, xdriverprobe used video drivers, can adapted used on other modules. main source code file (xdriverprobe.c) has less 500

c# - combox box error -

private void combobox1_selectedindexchanged(object sender, eventargs e) { combobox combo_design = new combobox(); combo_quality.items.add("best"); combo_quality.items.add("normal"); combo_quality.items.add("draft"); combo_quality.text = "best"; messagebox.show(combo_quality.text); string selecteditem = combo_quality.items[combo_quality.selectedindex].tostring(); combo_quality.text = "normal"; messagebox.show(combo_quality.text); string selecteditem2 = combo_quality.items[combo_quality.selectedindex].tostring(); combo_quality.text = "draft"; messagebox.show(combo_quality.text); string selecteditem3 = combo_quality.items[combo_quality.selectedindex].tostring(); } this relates combo box, have 3 items select want when choose best message box pops out , let me select ok , same goes normal , draf

php - Zend_Auth using Zend_Session instead of default storage? -

i reading through this tutorial , , @ 1 point in code, user info retrieved database , session created user: // default storage session namespace zend_auth $authstorage = $auth->getstorage(); $authstorage->write($userinfo); i tried this, session expires once browser closed. question how combine zend_session create cookie lasts 20 days or something? can't figure out through zend_session documentation.. any appreciated! thanks don't mix 2 different tasks. 1 task have "authentication", "remember me feature". so don't try solve them in 1 shot. for remember me store another cookie random hash , keep table assotiates each random hash particular user_id . also, lot of discussions "remember me" implementations here @ so: http://www.google.ru/search?q=site%3astackoverflow.com+remember+me&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:ru:official&client=firefox

cocoa - How do I preserve flags/width in a printf-formatted NSString used as a key for NSLocalizedString? -

i use genstrings generate .strings files source code files in project. though project technically cappuccino app, question should apply equally project uses .strings files. i have format string i'd localized: @"%d:%02d %@" . displaying time values. if osx/ios app, i'd use built-in datetime formatting, since it's cappuccino have roll own. when run genstrings produces value key: "%1$d:%2$d %3$@" . this appears in localizable.strings file: /* shortlocaltimeformat */ "%d:%02d %@" = "%1$d:%2$d %3$@"; by running command: genstrings -o resources/en.lproj -s cplocalizedstring *.j */*.j again, ignore i'm using cplocalizedstring instead of nslocalizedstrings , *.j instead of *.m , these values appropriate cappuccino. notice 02 in %02d discarded in resulting format string. if run again -nopositionalparameters option, leaves string is: genstrings -o resources/en.lproj -nopositionalparameters -s cplocalizedstring *.j

Is there an example of how to customize a .NET 4.0 profiler? -

i know there 1 profiler 2.0: http://www.codeproject.com/kb/dotnet/dotnetprofiler.aspx profiler api has changed in .net 4.0 , need consider in-process side side issues. need example customize our own profiler. knows that? thanks! i don't have actual example, this post question. check out rest of blog, there more posts 4.0 profilers (and profilers in general). by way, in comments section of linked blog post says official 4.0 profiler source not ready, when he'll post it. (though 4 months ago or something.) edit: clrprofiler 4.0 got released , includes source code, got sample ;-)

silverlight - Getting the home tile rearranging effect in Windows Phone 7 -

i have listbox items i'd user able re-arrange, in similar fashion how tiles on home screen can re-arranged. there control or easy way implement it, or have roll myself? you'll need roll yourself. @ stage there has not been control released implements out of box.

haskell - Understanding a Complicated Type Signature -

i need understanding type signature thrist package. import prelude hiding ((.), id) import control.category import data.monoid import control.arrow import control.monad foldlthirst :: (forall j k . (a +> j) -> (j ~> k) -> (a +> k)) -> (a +> b) -> thrist (~>) b c -> (a +> c) i confused several things. first +> , ~> symbols? documented , called? but confusion stop there. realize quantification describing threading of types of thrist, not sure if describing relationship holds first argument, or whole function, or knows... in othercases have seen existential quantification, phrase ends period, here ends ->, significant? first +> , ~> symbols? documented , called? they're infix identifiers, if used them name of function. same token, being equivalent lowercase identifiers (in contrast operators beginning : equivalent upper-case alphanumeric identifiers), in ty

javascript - onKeyPress event not working in Firefox -

i have following javascript code...here using onkeypress="somefunction( )" in body tag keycode of key pressed. the code working fine in ie8 not working in firefox. please give solution this. <html> <head> <title>onkeypress( ) event not working in firefox..</title> <script> function printdiv() { var divtoprint=document.getelementbyid('prnt'); newwin=window.open(''+self.location,'printwin','left=50,top=20,width=590,height=840,toolbar=1,resizable=1,scrollbars=yes'); newwin.document.write(divtoprint.outerhtml); newwin.print(); //newwin.close(); } </script> <script> function keypress() { alert(event.keycode); var key=event.keycode; if(key==112 || key==80) printdiv(); else if(key==101 || key==69) window.location="http://google.com"; else if(key==114 || key==82) window.reset(); } </script> </head> <body bgcolor="lightblue" onkeypress

how to get the previous 3 months in php -

how previous 3 months in php ex(if dec.. should display previous 3 months i.e., oct nov dec) you can use magical strtotime function this: echo date('m', strtotime('-3 month')); so specify previous dates minus sign. echo date('m', strtotime('0 month')); echo date('m', strtotime('-1 month')); echo date('m', strtotime('-2 month')); echo date('m', strtotime('-3 month')); results: dec nov oct sep you can same if using loop this: for ($i = -3; $i <= 0; $i++){ echo date('m', strtotime("$i month")); } results: sep oct nov dec check out documentation see many other friendly date , time keywords strtotime supports: http://php.net/manual/en/function.strtotime.php

Ruby: gem update --system gives this ---> ERROR: While executing gem ... (Net::HTTPRetriableError) 302 "Found" -

i trying install redmine project management tool on windows. when try run command "gem update --system", following error: error: while executing gem ... (net::httpretriableerror) 302 "found" i have tried solution in vain. could suggest work around this? note: guess proxy issue here...... i'm having same problem. found article here says need gem update --system begs question how gem update --system when give 302 redirect. http://help.rubygems.org/kb/rubygems/why-do-i-get-http-response-302-or-301-when-installing-a-gem not answer such think shows may not firewall issue. if find out more info please let me know.

dojox.grid - Change style of a EnhancedGrid line on "onRowClick" event -

i want change color of grid line without selecting it. means cannot use onstylerow event reacts 'selected', 'odd' or 'over' event. any ideas? thx i found updaterowstyles(idxrow) function, no idea how use (how pass syles etc.) , not sure if solve problem

Magento - How to translate the module mini-form search -

i want translate default input text of mini-form (search) german. original text "search entire store here..." , situated in "default/default/template/cataloguesearch/form.mini.phtml" thanks. hi grep out , can use inline translation tool magento offers. you looking following file app/locale/en_us/mage_catalogsearch.csv $ grep 'search' app/locale/ -rsn app/locale/en_us/mage_adminhtml.csv:360:"global record search","global record search" app/locale/en_us/mage_adminhtml.csv:361:"global search","global search" app/locale/en_us/mage_adminhtml.csv:433:"last 5 search terms","last 5 search terms" app/locale/en_us/mage_adminhtml.csv:533:"new search","new search" app/locale/en_us/mage_adminhtml.csv:778:"search","search" app/locale/en_us/mage_adminhtml.csv:779:"search index","search index" app/locale/en_us/mage_adminhtml.csv:780:&q

MySql - Is it better to select from many tables with union or using temp tables? -

we have report users can run needs select records 5 different services. right not, using union combine tables in 1 query, sometimes, server , crashed! optimized bits , pieces of query (where's , table joins) , there haven't been crashes since, report still takes long time load (ie query slow). the question is, mysql perform faster , more optimally if create 5 temp tables different service types, , select of temps? or there different idea? could, of course, use 5 separate selects , combine them in code (php). imagine cause report load slower... any ideas? usually limiting factor in speed database, not php. i'd suggest running seperate queries , let php combining, see if faster. if you're not storing data in arrays or doing other heavy processing, suspect php way faster. (this meant comment don't have rights yet..)

ruby on rails - Nice way of doing dual column validation -

i'm using rails 3 one. i've got collections model, user model , intermediate subscription model. way user can subscribe multiple collections, particular role. however, don't want user able subscribe same collection twice. so in subscription model i've got like: validate :subscription_duplicates def subscription_duplicates self.errors.add_to_base "this user subscribed" if subscription.where(:user_id => self.user.id, :collection_id => self.collection.id) end however seems ugly. also, breaks when want following in collection controller: def create @collection = collection.new(params[:collection]) @collection.subscriptions.build(:user => current_user, :role => subscription::roles['owner']) @collection.save respond_with(@collection) end when build subscription not have id "called id nil" error. thanks guidance! use validates_uniqueness_of validates_uniqueness_of :user_id, :scope => :collecti

c++ - SNMP trap not recognized by Manager -

i'm attempting create sample application utilizing microsoft's winsnmp library create example of trap. see code sample below: //send trap; lpstr strsrcaddr = "10.12.0.21"; lpstr strdstaddr = "10.2.255.8"; uint32 ndstport = 462; smiint snmppdutype = snmp_pdu_trap; hsnmp_vbl snmpvarbindlist = snmpcreatevbl(snmpsession, null, null); assert(snmpvarbindlist != snmpapi_failure); //copy src address src entity; hsnmp_entity snmpsrcentity = snmpstrtoentity(snmpsession, strsrcaddr); assert(snmpsrcentity != snmpapi_failure); //copy dst address dst entity; hsnmp_entity snmpdstentity = snmpstrtoentity(snmpsession, strdstaddr); assert(snmpdstentity != snmpapi_failure); //assign dst entity trap port; snmpstatus = snmpsetport(snmpdstentity, ndstport); assert(snmpstatus != snmpapi_failure); //create pdu, assigning trap_type; hsnmp_pdu snmppdu = snmpcreatepdu(snmpsession, snmppdutype, null, null, null, snmpvarbi

.net - Accessing newer APIs in a redirected assembly -

if use assembly binding redirection redirect v1.0 referenced assembly v1.1 assembly, can use reflection apis to: create new classes introduced in v1.1 assembly invoke new methods of existing classes introduced in v1.1 assembly while keeping reference v1.0 assembly? mmmm, i'm not sure if makes sense. you need know class names , methods available @ 1.1 while coding against 1.0 version why not change 1.1 references? you can create instances name using activatior.createinstance().

audio recording in android -

i have , android emulator , microphone connected pc. want capture pcm pulses microphone (i.e. record voice) , send udp socket. please me in source code @ least voice recording. you can use code audio recording: mediarecorder recorder; void startrecording() throws ioexception { simpledateformat timestampformat = new simpledateformat( "yyyy-mm-dd-hh.mm.ss"); string filename = "audio_" + timestampformat.format(new date()) + ".mp4"; recorder = new mediarecorder(); recorder.setaudiosource(mediarecorder.audiosource.mic); recorder.setoutputformat(mediarecorder.outputformat.three_gpp); recorder.setaudioencoder(mediarecorder.audioencoder.amr_nb); recorder.setoutputfile("/sdcard/"+filename); recorder.prepare(); recorder.start(); } protected void stoprecording() { recorder.stop(); recorder.release(); }

url - Normalizing params a named route in rails -

i'm again, wrestling rails 3 , routes. here problem: i created named route 1 example: match '/download/artist/:artist/album/:albumname', :to => "albums#show", :as => :search, :via => :get gives me route: search_path i have classic 1 this: get "albums/show" gives me route: albums_show_path . however, when i'm using search_path parameters this: <%= link_to "#{result.name[0..50]}(...)", search_path(:artist =>result, :albumname => result.name), :class => "albumname" %> , fails, not albums_show_path. here error: no route matches {:controller=>"albums", :action=>"show", :artist=>"eddie vedder & ben harper", :albumname=>"my city of ruins / father's house (live) [benefiting artists peace , justice haiti relief] {digital 45}"} i know because albumname parameter not escaped. after trying escape cgi.escape , doesn't work. suppo

actionscript 3 - Do you know if there's any problem with netstream.appendBytes() for streaming? -

i use netstream.appendbytes streaming (flv) http, works intermittently (it works, after refresh, doesn't work, works , on...) what problem?, have not idea my code is: import flash.display.*; import flash.events.* import flash.net.*; import flash.utils.bytearray; import com.hurlant.util.hex; var videourl:string = "http://url/vivo/flash"; //elemento de conexíon var conn:netconnection = new netconnection(); conn.connect(null); //stream de red var stream:netstream; //conexión stream = new netstream(conn); //oyente stream.addeventlistener(asyncerrorevent.async_error, asyncerrorhandler); function play() { var urlstream:urlstream = new urlstream(); //oyentes de urlstream urlstream.addeventlistener(statusevent.status, instatus); urlstream.addeventlistener(event.complete, completehandler); urlstream.addeventlistener(securityerrorevent.security_error, securityerrorhandler); urlstream.addeventlistener(progressevent.progress, oyenteproce

perl - given/when: how to test a hashvalue with $_ as key for trueness? -

is there way test hash-value in fourth "when" trueness? #!/usr/local/bin/perl use warnings; use 5.012; %hash; $hash{one} = 0; $hash{two} = 2; $hash{three} = 0; print ": "; $aw = <>; chomp $aw; given ( $aw ) { when ( 'cat' ) { '$aw eq cat' } when ( 'mouse' ) { '$aw eq mouse' } when ( 'sheep' ) { '$aw eq sheep' } when ( !( !$hash{$_} ) ) { '$hash{$_} true' } ### default { 'something else' } } well use shorter: when ( !!$hash{ $_ } ) { ... } but yeah, that's it.

php - Add values to one array after explode function -

i'm trying paths rows , add them (after exploding) 1 array (in order present them checkbox) this code: $result = mysql_query("select path audit ind=$ind"); $exp = array(); while($row = mysql_fetch_array($result)) { foreach ($row $fpath) { $path = explode("/", $fpath); array_push($exp, $path); } } my output that: array ( [0] => array ( [0] => [1] => [2] => path ) [1] => array ( [0] => [1] => [2] => 1 ) how can combine them 1 array? i want this: array ( [0] => [1] => [2] => path [3] => [4] => 1 ) thank you! take @ array_merge function: http://php.net/manual/en/function.array-merge.php use following lines of code: $path = explode("/", $fpath); $exp = array_merge($exp, $path); hth.

wpf - Communication between viewModels in MVVM Light -

i read couple of places people use messenger communicate between 2 different viewmodels. load viewmodels main viewmodel, wrong practice set property values using viewmodel instance in main viewmodel? mvvm great separating view code can better designer-developer workflow (i.e. designer can edit view in blend), , testing (i.e. can unit test logic without view, in headless mode). problem is, when people start using mvvm feel need other loose-coupling patterns to, ioc, di, etc ... basically, if you happy communicating directly between viewmodels (and yes, time), , can test code (that if choose test ... optional, don;t tell said that!). then, go it.

c# - Retry a service call ONLY ONCE in the event service fails logic help -

so have function calls web service return int indicitating success or various types of failures may have occurred. after recieve result service, run through switch statement , procceed accordingly based on encountered during service execution. private void example() { int result = executewebservice(); switch(result) { case 0: //no errors noerrorslogic(); break; case 1: // manual retry manualretrylogic(); break; case 2: // validation error validationerrorlogic(); break; default: // run time error occurred logicoptiond(); // @ point want to call service again once see if succeed break; } } generally, i'd add call function calls sevice , runs through results on again, don't want continuously run until service succeeds. in default option want force 'retry' calling service once - , process results accordingly. any ideas? you can alwaus do: private void example(bool retry = true) { .... default: if(retry) { example(false); } break; } just add

sql - Strange UPDATE syntax in MS Access 2003 -

i've got access application update query following syntax: update table1, table2 set table2.value1 = table1.value1, table2.value2 = table1.value2, table2.value3 = table1.value3, table2.value4 = table1.value4 the query working not understand what's going on here. i'm trying convert query sql server. can please explain query does? guess it's special access syntax. thanks, sven it uses older implicit join syntax, although sql server should understand syntax too. it's inner joining table1 , table2, moving values table1 table2. because of lack of join conditions, if table1 has more 1 row may have unpredictable results. essentially is: update table1 inner join table2 <<on missing conditions here>> set table2.value1 = table1.value1 table2.value2 = table1.value2 table2.value3 = table1.value3 table2.value4 = table1.value4 you can convert sql server this: update table2 set table2.value1 = table1.value1

javascript - jQuery UI Dialog and maxHeight in Internet Explorer -

here's current code: $("#dialogscroll").dialog({ bgiframe: true, autoopen: false, maxheight: 600, width: 550, modal: true, resizable: false, open: function (type, data) { $(this).parent().appendto("form"); }, close: function () { } }); maxheight works great in firefox, chrome, etc. expected, ie 7 has problem it. have idea how ui dialog use maxheight in ie? <div id="dialogscroll" class="dialog" style="display:none; "> <table> <thead> <tr> <th> state code </th> <th> state name </th> </tr> </thead>

oauth - How to specify "realm" parameter for dotnetopenauth lib -

i try oauth (version 1.0) request authorization on server , using dotnetopenauth library this. server has troubles getting authorization parameters through authorization http header , request parameter "realm" required. have no idea how specify in dotnetopenauth library. appreciated! regards, alex you can't. @ least not through public api included in shipping version of dotnetopenauth. please jump on http://dotnetopenauth.uservoice.com/ , submit feature request detailing need. useful details might include whether need same value realm parameter requests, vs. needing customize individual requests.

javascript - Convert Google Analytics cookies to Local/Session Storage -

update http://jsfiddle.net/musicisair/rsktp/embedded/result/ google analytics sets 4 cookies sent requests domain (and ofset subdomains). can tell no server uses them directly ; they're sent __utm.gif query param. now, google analytics reads, writes , acts on values , need available ga tracking script. so, wondering if possible to: rewrite __utm* cookies local storage after ga.js has written them delete them after ga.js has run rewrite cookies local storage cookie form right before ga.js reads them start over or, monkey patch ga.js use local storage before begins cookie read/write part. obviously if going far out of way remove __utm* cookies we'll want use async variant of analytics. i'm guessing down vote because didn't ask question. doh! my questions are: can done described above? if so, why hasn't been done? i have default html/css/js boilerplate template passes yslow, pagespeed, , chrome's audit near perfect scores.