Posts

Showing posts from February, 2015

iphone - how to validate string in NSUserdefaults -

i getting id web services. eg:101. that id save in nsuserdefaults , give value string. now need validate string if string equal 0 need fire 1 action , if value not equal 0 need fire action. for code this. nslog(@"id is%@",[defaults objectforkey:@"id"]); nsstring *intstring = [nsstring stringwithformat:@"%d", [defaults objectforkey:@"id"]]; nslog(@"string %@",intstring); if ([intstring isequaltostring:@"0"]) { nslog(@"yes 0"); } else { nslog(@"no not eqal zero"); } for first time in console id 0,string 0 and if check second time id 0, string 100243248. i did n't 100243248 value. i need check id in nsuserdefaults. if value 0 need fire 1 action , if value not equal 0 need fire action. how can done can 1 please me. thank u in advance. try doing instead: nsstring *intstring = [nsstring stringwithformat:@"%@", [defaults objectforkey:@"id"]]...

.net - How to listen to specific IP address -

on server, under advanced tcp/ip settings have 2 ip addresses added. question is, how can specify want listen first or second ip? there way obtain ip addresses on machine via .net , select 1 listen to? any appreciated. hope question clear. thanks. the tcplistener in system.net.sockets accepts ip , port on construction: int32 port = 13000; ipaddress localaddr = ipaddress.parse("127.0.0.1"); // tcplistener server = new tcplistener(port); server = new tcplistener(localaddr, port); the full msdn article here , @ tcpclient

c# - How to solve this error? -

how solve following error? cs0234: type or namespace name 'helpers' not exist in namespace 'nerddinner' (are missing assembly reference?) if error occurring within class: add using nerddiners.helpers; using statements in class. as short cut, can place cursor on relevant part of code , press ctrl + . , visual studio add you. if error occurring within view: add following top of view (under inherits definition) <%@ import namespace="nerddinner.helpers" %> or can add namespaces section of projects web.config <namespaces> ... <add namespace="nerddinner.helpers" /> if error occurring within test class need add project reference main nerddinners project within add references option of test project.

maven - Automatic exporting of dependencies in InteliJ Idea when reading poms? -

i tried search both here , on jetbranis.net did not found answer. i have created project ( p ) using maven have modules ( a ,*b*). module a dependant on module b , module b dependent on libraries r . when open p using intelij idea 10.0.1 works smoothly. problem have dependency handling. the dependencies imported transitively. both a ,*b* dependent on libraries r . expect b dependent on r , expect r exported , a dependent on b . i found old posts on jetbrains seam related, seams have opposite problem http://devnet.jetbrains.net/thread/286098 . can advise me please? did missed configuration option? this how maven's dependencies work; each module (aka maven project) has isolated classpath. dependencies, imported idea, not 'exported' prevent interference between transitive dependencies.

How do I find the last <div class> in an HTML File with PHP Simple HTML DOM Parser? -

according documentation simple html dom parser (under tab “how modify html elements”), code finds first instance of <div class="hello"> : $html = str_get_html('<div class="hello">hello</div><div class="world">world</div>'); $html->find('div[class=hello]', 0)->innertext = 'foo'; echo $html; // output: <div class="hello">foo</div><div class="world">world</div> what if want insert 'foo' last instance of <div class="hello"> , assuming html code has lot of instances of <div class="hello"> . what should replace 0 ? well, since // find anchors, returns array of element objects $ret = $html->find('whatever'); returns array holding <whatever> elements, can fetch last element php's regular array functions, e.g. end $last = end($ret); if simplehtmldom implements css3 selec...

linux - find based filename autocomplete in Bash script -

there command line feature i've been wanting long time, , i've thought how best realize it, got nothing... so i'd have when start typing filename , hit tab,for example: # git add foo<tab> i'd run find . -name "*$1*" , autocomplete complete path matched file command line. what have far: i know i'll have write function call app parameters want, example git add . after needs catch tab-keystroke event , find mentioned above, , display results if many, or fill in result if one. what haven't been able figure out: how catch tab key event within function within function. so in pseudocode: gadd() {git add autocomplete_file_search($1)} autocomplete_file_search(keyword) { if( tab-key-pressed ){ files = find . -name "*$1*"; if( filecount > 1 ) { show list; } if( files == 1 ) { return files } } } any ideas? thanks. you should take @ introduction bash completion . briefly, b...

php - Store a user-input date string as datetime -

i'm using php, , need parse date string formatted dd/mm/yyyy , store in mysql. how can convert string datetime variable in mysql table? probably best way using this: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_str-to-date select str_to_date('04/31/2004', '%m/%d/%y'); -> '2004-04-31' or equivalent php functions like: http://www.php.net/manual/en/function.date-parse-from-format.php (from php 5.3) a generic php function like function convertdate($datestring) { return date('y-m-d h:i:s',strtotime(str_replace('/','-',$datestring))); } or function convertdate($datestring) { $a = explode($datestring('/')); return "{$a[2]}-{$a[1]}-{$a[0]} 00:00:00"; }

Are variables in python functions reinitialized with each function call? -

assume have 2 functions def myfunction1(number): biglist = [1,2,3,4,5,6,7,8,9] print number*biglist biglist = [1,2,3,4,5,6,7,8,9] def myfunction2(number, biglist): print number*biglist i time them ipython's magic %timeit: in [5]: %timeit myfunction2(number, biglist) 1000000 loops, best of 3: 607 ns per loop in [6]: %timeit myfunction1(number) 1000000 loops, best of 3: 841 ns per loop does mean biglist variable re-declared every time call myfunction1? have guessed after first function-call python somehow store biglist variable function, not have re-initialize list every time function called. i don't know inner workings of python i'm guessing. can explain happens? python can't suggest without doing quite complicated analysis. assignment statement assignment statement if type x=3 twice in interpreter expect x 3 after type regardless of have done x in between... no different to illustrate - function be def myfunction1(number)...

java - Arrays.asList() doubt? -

people aslist method convert array list , not copying, every change in 'alist' reflect 'a'. add new values in 'alist' illegal, since array have fixed size. but, aslist() method returns arraylist<t> . how compiler differentiates line 3 5. line 3 gives me exception ( unsupportedoperationexception ). string[] = {"a","b","c","d"};//1 list<string> alist = arrays.aslist(a);//2 alist.add("e");//3 list<string> b = new arraylist<string>();//4 b.add("a");//5 this list implementation receive arrays.aslist special view on array - can't change it's size. the return type of arrays.aslist() java.util.arrays.arraylist confused java.util.arraylist . arrays.arraylist shows array as list .

oData WCF service - hide an element -

i'm new wcf. web project has ado.net entity data model (aka ef edmx), has entity container name jobsystementities . i've created simple odata wcf data service uses jobsystementities , , works great: public class jobservice : dataservice<jobsystementities> { public static void initializeservice(dataserviceconfiguration config) { config.setentitysetaccessrule("jobs", entitysetrights.readsingle); } however, exposes of properties on job. hide sensitive data, i.e. cost field/property/column of job table. i posting late, might others. you can use ignoreproperties attribute http://msdn.microsoft.com/en-us/library/system.data.services.ignorepropertiesattribute.aspx on class. you have define partial job class in order this. in lines of: namespace dal.entities { [ignoreproperties("cost")] public partial class job { } }

Rails: How to escape ampersand in URL formation -

i have link_to helper following: <%= link_to "example & text", url_for(:controller =>'example', :title=>"example & text") %> it frames url http://localhost:3000/example?title=example&amp:text in sample controller calls index method params[:title] returns value example&amp:text . i want have value "example & text". have tried cgi::escape() , cgi::escapehtml() without luck. the url needs escaped using cgi.escape : link_to "example & text", :controller => "example", :title => cgi.escape("example & text") this should generate like: <a href="/example?title=example+%26+text">example & text</a> then, wherever you're wanting use this, can unescape again normal: cgi.unescape params[:title] # => "example & text"

android - Can anyone explain me this code? -

import org.apache.http.message.basicnamevaluepair; private string getserverdata(string returnstring) { inputstream = null; string result = ""; //the year data send arraylist<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(); namevaluepairs.add(new basicnamevaluepair("year","1970")); //http post try{ httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost(key_121); httppost.setentity(new urlencodedformentity(namevaluepairs)); httpresponse response = httpclient.execute(httppost); httpentity entity = response.getentity(); = entity.getcontent(); }catch(exception e){ log.e("log_tag", "error in http connection "+e.tostring()); } } my questions... what basicnamevaluepair class does? what piece of line httppost.setentity(new urlencodedformentity(namevaluepairs)); what is = entity.getcontent(); do? , can pass more...

C# Returning Types from a method -

if have method returns datagridview , flow similar this: if (ds.tables.count == 0) { sharedmethods.updatestatus("there no excluded results display"); //return dgv; } else { dgv.datasource = ds.tables[0]; dgv.autosizecolumnsmode = datagridviewautosizecolumnsmode.allcells; dgv.allowusertoaddrows = false; return dgv; } if if condition true not want return datagridview(as there no data), can return in case? if return null, calling method has null datagridview causes later problems. thanks. just set grid's visible property false if have nothing show.

xaml - wpf datagrid alternate row coloring -

i have tried method.. without luck.. <style targettype="{x:type datagridrow}"> <style.triggers> <trigger property="itemscontrol.alternationindex" value="0"> <setter property="foreground" value="red" /> </trigger> </style.triggers> </style> is there way row index? have tried <datatrigger binding="{binding alternationindex}" value="0"> <setter property="foreground" value="green"></setter> </datatrigger> unless done, have set alternationcount property of datagrid: <datagrid alternationcount="2" ... /> you should additionally check whether foreground property used control in datagridrow. try setting background property test alternation stuff.

javascript - Style parent li on child li:hover -

i've been digging day find out how style parent li when hovering on child li element. e.g. <ul> <li> parent element </li> <ul> <li> child element </li> </ul> <ul> i've found countless posts asking how in css find it's not possible. people "you can javascript" never how! i'm of javascript newb appreciated. thanks. edit: here outputted source code. i'm not sure if affect selectors required javascript/jquery because, can see adds additional info class name i.e. "page-item-9" on top of class name there ("page_item"). added wordpress i've needed use "page_item" reference in css. <ul class="pagenav"> <li class="page_item page-item-12 current_page_item"><a href="#" title="home">home</a></li> <li class="page_item page-item-2"><a href="#" title...

c - Generate #ifdef, #endif clause with another macro -

i'm having problem in program i'm working on. i'm trying in --help display features compiled in or not. however, there quite alot of these , "normal" way verbose. e.g.: #ifdef have_foo static const bool have_foo = true; #else static const bool have_foo = false; #endif printf("support foo: %s\n", have_foo ? "yes" : "no"); now, since have every feature, loads of lines, not want. so thought i'd write macros it: #define _supp(x) #ifdef have_##x \ static const bool _##x##_supp = true; \ #else \ static const bool _##x##_supp = false; \ #endif #define _printsupp(var, name, desc) printf("\t%s - %s: %s\n", name, desc, _##var##_supp ? "yes" : "no") however, there issue here. macro expanded single line, , preprocessor chokes on this. there way generate macro actual newlines inbetween, or possible evaluate #ifdef on single line? if, instead of not defining have_foo , define 0 , can do: ...

c++ - Howto call external program and get it's output from another program -

howto in c++: suppose program a command line tool inputs (for example file paths , number), according it's inputs, may other parameters during runtime. ( if(condithin) cin<<something ) i'd call a program b , want see complete output of a during it's running. a 's inputs must entered (if necessary). b gui tool written qt , a must shown in plain text area , it's inputs must shown in same place (like console client). i don't know start. reading ipc didn't help. know it's possible because see dolphin's console window , python interpreter in eric ide... since use qt, using qprocess best way it.

xml - iPhone RSS Reader, get image from rss feed -

i've problem. i've app download rss feed website. works fine, want set image in table view articles appear. how can image rss feed? need code. title, description i've done perfectly, i'm not able recover image. p.s. : sorry english, i'm italian :) ok, presume have url of image. can this: //normal text setting code //normal text setting code nsstring *imageurlstring = [rssfeed objectforkey:@img"]; nsurl *imageurl = [nsurl urlwithstring:imageurlstring]; nsdata *imagedata = [nsdata datawithcontentsofurl:imageurl]; cell.imageview.image = [uiimage imagewithdata:imagedata]; that quick , filthy method. it's running in ui thread etc, it's going terrible user experience. can fiddle performance on own terms, i'd suggest 1 of following: load data asynchronously , fill data becomes available load of data in secondary thread, show loading spinner for both of above, put images nsarray , call them doing cell.imageview.image = [myimage...

api - WCF 4: Passing Empty parameters on a GET request -

i'm creating api use request return search results database, i'm trying make optional parameters can passed (easy wcf) if parameters specfied in query string long empty ignored service. however if have query string empty parameters return bad request (400) server e.g. using end-user point of choice pass following querystring http://www.exampleservice.com/basic/?apikey=1234&noofresults=3&maxsalary=&minsalary=&ouid=0&keywords=web+developer note maxsalary , minsalary not passing values you have following wcf service: [operationcontract] [webget(uritemplate = "basic/?apikey={apikey}&noofresults={noofresults}&maxsalary={maxsalary}&minsalary={minsalary}&ouid={ouid}&keywords={keywords}", bodystyle = webmessagebodystyle.bare)] public list<searchresultsdto> basicsearch(string keywords, string apikey, int noofresults, int maxsalary, int minsalary, int ouid) { //do service stuff } this cau...

android - Multiple activity instances problem -

in application have activity class has listview cursor adapter. can go activity b, pressing button. b can go pressing button (not pressing button). means new instance of activity created. from point, if press key, current activity destroyed , b popped. , if press again initial activity popped. hope clear. my problem when second activity destroyed, database connection reseted, in static manner. in end, when initial activity displayed, listview empty. my question is: should try have single instance activities, or shoud change database connection (to link activity instance)? thanks lot gratzi first of in class carrying listview . on clicking listview call startactivity method class b activity without calling finish(). hope doing. in second activity button (not button) using calling activity . in clicklistener calling activity dont call startactivity(intentfora) instead call finish(); ending activity b. resume activity paused.. i hope

datetime - How to derive the week start for a given (iso) weeknumber / year in python -

this question has answer here: in python, how find date of first monday of given week? 6 answers i know can use datetime.isocalendar() getting weeknumber given date. how can inverse, given weeknumber , year retrieve first day of week. if you're limited stdlib following: >>> datetime.datetime.strptime('2011, 4, 0', '%y, %u, %w') datetime.datetime(2011, 1, 23, 0, 0)

osx - mac mysql after reboot -

after reboot try start using mysql on mac (10.6.5), get can't connect local mysql server through socket ' tmp mysql.sock' 2 i fix cd /usr/local/mysql sudo echo sudo ./bin/mysqld_safe & /usr/local/mysql/bin/mysql test so question (noob)... how avoid having type start mysql?? there can start easily? thanks!!! there system preferences app can download , install. has option "start mysql on boot". mysql preferences pane

java - How to link two values to dropdown in JSF? -

i have created entites , facde in netbeans. want create native query 2 feilds table. , bind them string query = "select distinct(m.idmanufacturer),m.hmid " + " model m"; @suppresswarnings("unchecked") list<model> modellist = (list&lt;model>) getentitymanager().createnativequery(query).getresultlist(); and used code <f:selectitems itemlabel="#{mycontroller.modellist.idmanufacturer}"/> to show values in dropdown. doesn't seem working. ideas? try creating list of selectitems list<model> , give in value attribute. e.g. list<selectitem> modellist = new arraylist<selectitem>(); //implement conversion label value here. <f:selectitems value="#{mycontroller.modellist}"/>

Can clean URLs be achieved in a pure ColdFusion solution? -

we need estimate portal based on coldfusion technology. have no information hosting environment (could windows or linux). one of requested features clean urls. know if can achieved pure coldfusion solution or web server related? know there neat extensions iis7 enabling clean urls i'm afraid can't depend on those. you can use coldfusion's application.cfc 's onmissingtemplate() method achieve effect. if want have extensions other .cfm you'll need web server configuration make coldfusion serve other extensions , directory paths (e.g. /path/to/something/ ) needs configured have standard default document (e.g. index.cfm ). ben nadel has blog post covers idea extensively - sure check comments well. that noted, both iis 7 , apache have url rewriting modules (assuming these web servers in windows , linux, respectively). situation if know url patterns module easier route. however, if patterns dynamic coldfusion alone may better, if more complex path, yo...

asp.net - Global.asax breaks with AJAX Control Toolkit -

everything working fine. added global.asax , got error: line: 4723 error: sys.webforms.pagerequestmanagerparsererrorexception: message received server not parsed. common causes error when response modified calls response.write(), response filters, httpmodules, or server trace enabled. details: error parsing near 'eectrl_data = null;| <%@ application language="vb" %> <script runat="server"> sub application_start(byval sender object, byval e eventargs) ' code runs on application startup end sub sub application_end(byval sender object, byval e eventargs) ' code runs on application shutdown end sub sub application_error(byval sender object, byval e eventargs) ' code runs when unhandled error occurs end sub sub session_start(byval sender object, byval e eventargs) ' code runs when new session started end sub sub session_end(byval sender object, byval e eventargs) ' code runs when session ends....

asp.net - Enterprise library 4 dataconfiguration tag -

i using enterprise library data access. when running application, @ createdatabase() statement getting exception: microsoft.practices.objectbuilder2.buildfailedexception unhandled user code message="the current build operation (build key build key[microsoft.practices.enterpriselibrary.data.database, null]) failed: value can not null or empty string. (strategy type microsoft.practices.enterpriselibrary.common.configuration.objectbuilder.configuredobjectstrategy, index 2)" source="microsoft.practices.objectbuilder2" now, googled bit , found have place <dataconfiguration defaultdatabase="localsqlserver"/> but don't know where. right solution? also, @ time of installing enterprise library didn't see connection string statement? so, wonder how take connection string web.config file. in connection string section of web.config file have: <remove name="localsqlserver"/> ...

c# 4.0 - Check box inside a gridview -

in application , inside grid view each , every row contains check box. after clicking check box have access entire row data. iam unable find row. can 1 ? try code may helps.. protected void rdblststudenttype_selectedindexchanged(object sender, eventargs e) { gridviewrow gridrow = ((sender checkbox).parent).parent gridviewrow; int currentrowindex = gridrow.rowindex; } by using currentrowindex, can access entire row .

arduino - Problem creating a HTTP POST message with the wiserver-library -

i call rest-service black widow 1.0 board (with wi-fi) using wiserver library. the http post should this: http://sensor.zonosoft.com/sensorservice.svc/savemeasurement http/1.0 content-type: application/json; charset=utf-8 {"id":0,"version":0,"name":"toilet 1","sensors":[{"id":0,"version":0,"measurements":[{"time":"\/date(1295820124154+0100)\/","value":1}],"name":"dor"},{"id":0,"version":0,"measurements":[{"time":"\/date(1295820124155+0100)\/","value":1}],"name":"tonden"}]} when test post request fiddler2's request builder, fiddler adds these 2 lines header. host: sensor.zonosoft.com content-length: 257 , fiddler detects response: http/1.1 200 ok cache-control: private content-length: 10 content-type: application/json; charset=utf-8 server: microsoft-iis/7.5 x-...

asp.net - how to access templatefield from code behind -

the reason why looking update dynamic because using objectdatasource , objectdatasource have collection of object , within object have object wanted access example: +student ...... ...... ...... -courses ......... ......... name update end how bind templatefield code-behind? <asp:gridview id="gridview1" runat="server"> <columns> <asp:templatefield headertext="name" sortexpression="name"> <itemtemplate> </itemtemplate> </asp:templatefield> </columns> </asp:gridview> first of define key field in gridview control, add net attribute gridview markup: datakeynames="studentid" . you can use both event handler gridview: rowdatabound or rowcreated. add 1 of event handler , find there control placed in itemtemplate. here, instance: void productsgridview_rowcreated(object sen...

asp.net - Automatic Website Login, Long URLs, Encryption -

i'm building secure payment portal. we have 2 applications using this. 1 web application, other desktop app. both of these require users login/authenticate, same credentials can used either application. i want build automatic login mechanism fill in various login/order details , able call either app mentioned above. i've been thinking best way pass information encrypted through url. ie https://mysite.com/takepayment.aspx?id=gt2jkjh3 .... since don't want integrate payment processing tightly desktop app reduce our pci scope, decided have open browser central, secured payment page through simple shell execute full url causing default browser open page. originally using aes encryption, being re-examined prefer not having give out key end user (aes symmetric, symmetric encryption = both parties need private key, why bother encrypting since we're going distributing app?) i'm looking @ switching on use public key encryption built in rsa routines within .net...

garbage collection - How does Boehm GC work for C program? -

i checked boehm gc. gc c/c++. i know mark-and-sweep algorithm. i'm in curious how picks pointers in whole c memory. understanding c memory plain byte array. possible determine value in memory pointer or not? the boehm gc conservative collector, means assumes pointer. means can find false positive references, integer coincidentally has value of address in heap. result, blocks may stay in memory longer non-conservative collector. here's description boehm's page : the garbage collector uses modified mark-sweep algorithm. conceptually operates in 4 phases, performed part of memory allocation: preparation each object has associated mark bit. clear mark bits, indicating objects potentially unreachable. mark phase marks objects can reachable via chains of pointers variables. collector has no real information location of pointer variables in heap, views static data areas, stacks , registers potentially containing pointers....

java - Building e-mail server -

i have project use case users should able send private messages other users should integrated e-mail box. should able send either private messages or e-mail messages same screen. my thought use kind of open-source e-mail server dump e-mails mongodb , have java api pull them out , display them on interface. , when user sends e-mail passed api e-mail server. is reasonable approach? if want own server (not unreasonable in many cases), check out apache james - open-source java mail server plug-in capability. (!) can use javamail talk this, pull messages etc.

asp.net - Why am I having trouble selecting a default radio button on a web page? -

it seems ought dead simple, i'm stuck. i've written asp.net code outputs pair of radio buttons: <p> <label for='chkyapper'>yapper</label> <input type='radio' name='yapper' id='chkyapper' value='yapper' checked='<%=gblyapperchecked %>' /> <br /> <label for='chknonyapper'>non-yapper</label> <input type='radio' name='yapper' id='chknonyapper' value='nonyapper' checked='<%=gblnonyapperchecked %>' /> if (registrationuser.isyapper == 1) { gblyapperchecked = "checked"; gblnonyapperchecked = ""; } else { gblyapperchecked = ""; gblnonyapperchecked = "checked"; } as expected, 2 radio buttons, "yapper" , "non-yapper". however, when step thru code , see gblyappe...

c - how to take integers as command line arguments? -

i've read a getopt() example doesn't show how accept integers argument options, cvalue in code example: #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main (int argc, char **argv) { int aflag = 0; int bflag = 0; char *cvalue = null; int index; int c; opterr = 0; while ((c = getopt (argc, argv, "abc:")) != -1) switch (c) { case 'a': aflag = 1; break; case 'b': bflag = 1; break; case 'c': cvalue = optarg; break; case '?': if (optopt == 'c') fprintf (stderr, "option -%c requires argument.\n", optopt); else if (isprint (optopt)) fprintf (stderr, "unknown option `-%c'.\n", optopt); else fprintf (stderr, "unknown option character `\\x%x...

mysql - validate password with preg_match in php -

i need validate passwords. use: preg_match("/^[a-z0-9_-]*$/i", $pass) . i add length this. mysql table set : userpassword varchar (40) not null, . between 6 , 40 characters. , allow characters not dangerous put in db. imposing arbitrary complexity rules on passwords user hostile , not improve security substantially. don't it. here's why i think above statement true: if want use website "123456" password, it's problem. let me roll it. you may impose minimum length (e.g. 6 characters), not maximum. if want cite entire john maynard password, let me roll it. your idea of "secure" password might not else's idea. people might use password generators not automatically comply rule set. don't annoy them not accepting password no other reason not containing enough/or many "special characters". you must hash customer's passwords decent hashing algorithm plus random hash salt , different every user. stor...

c# - WPF FrameworkElement Mouse Click issue -

in wpf app have bunch of customcontrols inside grid. processing mouse clicks on them use mouseleftbuttondown event of grid , in event handler check customcontrol clicked: private void grid_mouseleftbuttondown(object sender, mousebuttoneventargs e) { frameworkelement fesourcecomm = e.source frameworkelement; mycustomcontrol scurrentcomm = new mycustomcontrol(); try { scurrentcomm = (mycustomcontrol)fesourcecomm; } catch (exception) { ... the problem appeared when placed customcontrols in usercontrol , inside grid. in case approach doesn't work. checked type of click source in each case e.source.gettype().tostring(); , following results: when there no problem (in case put customcontrols in grid without usercontrol) myprojectnamespace.mycustomcontrol when put customcontrols in usercontrol , in grid myprojectnamespace.usercontrols.myusercontrolname when put customcontrols in usercon...

java - PostgreSQL - integer[] best practice -

working on web app lately decided use integer[] in data model. having 2 tables, 1 articles' data , second tags (tag id , description), decided tag ids article tagged in article.tags integer[] column. as milen a. radev pointed out: tip: arrays not sets; searching specific array elements can sign of database misdesign. consider using separate table row each item array element. easier search, , scale better large number of elements. not that, having work integer[] using jdbc , ibatis turned out, shall "interesting". for moment, can away working implementation in place had do. re-worked simplicity's sake using separate table storing article.id , tag.id relationships. in end i'm puzzled integer[] best used , in context? i think figured out hard way it's not best for. imho, since array violation of 1nf, best context is:... (drumroll)..... none. this gets question of why have data not meant queried. values potentially searchable, , if...

ruby on rails - PATH problem during RedCloth installation -

i'm trying run "bundle install" , tries install redcloth. seems theres problem during installation because of path variable. when tried "gem install redcloth" had exact same error. i dont know i'm supposed path variable. http://img231.imageshack.us/img231/613/bad4f6afda58444fa77707b.png my current path variable "%appdata%\python\scripts;c:\program files\google\google_appengine\" you need install ruby installer dev kit. download "development kit" here: http://rubyinstaller.org/downloads and follow these instructions: https://github.com/oneclick/rubyinstaller/wiki/development-kit

.net - WPF designing custom UI component for Silverlight/Windows Phone 7 -

i looking designing custom ui component windows phone 7 applications , possible later web based applications (silverlight). speedometer effects i.e. when speed changes arrow moves too. how these custom ui components designed? visual studio or maybe blend used that? are there tutorials around web guide me in creating such component? i imagine written wpf/xaml, vectorial , scale on needs. thanks help, -david you can create reusable usercontrols in silverlight windows phone. here's walkthrough. snowfall (user control sample) : windows phone 7 tutorials

cocoa touch - iphone - sliding in animation -

i have uiview animate screen in following way: imagine looking table top , have envelop , on envelop box. box covers envelop, see small envelop border not covered box. animation envelop sliding down until visible. i simple animate this, have have view box image, on envelop, cover envelop. idea make without box view. if using application photoshop animate this, make matte (or mask) fixed , make black rectangle want envelop invisible, is, simulate covered box. then, if keep mask fixed, can animate image , appear coming below box, in fact coming region matte black (image invisible) region mate white (image visible). is possible on ios? can mask uiimageview or layer , animate layer keeping mask fixed? check slide down effect here in page http://madrobby.github.com/scriptaculous/combination-effects-demo/ it give , idea of mean... thanks set clipstobounds -property of 'mask view' yes . add 'content view' subview 'mask view' , animate frame o...

database - Embedded C data storage module design -

i'm in process of designing embedded c data storage module. included files/modules want access "shared" system-wide data. multiple tasks aggregate dozens of inputs (gpio, can, i2c/spi/ssp data, etc) , stores values off using api. then, other tasks can access data safely through api. system embedded app rtos, mutexes used protect data. these ideas used regardless of implementation i've designed in past, , i'm trying improve upon it. i'm halfway through new implementation , i'm running few hiccups , benefit fresh perspective. quick rundown of requirements of module: ideally, there 1 interface can access variables (one get, 1 set). i'd return different variable types (floats, ints, etc). means macros needed. i'm not pressed code space, it's concern quick gets/sets absolutely paramount (which means storing in strings ala xml/json out) no new variables need added during runtime. statically defined @ boot the question how go designi...

Adding a reference between Eclipse Java projects -

i have 2 java projects in eclipse workspace, , use class 1 of them in other. how can add reference between them? i'm looking adding project reference in c#. assuming using eclipse... right click project -> properties -> java build path -> projects tab ...which allow force required projects on project in questions build path.

sql - ADsDSOObject query: Columns available when querying the LDAP? -

i writing vbscript query adsdsoobject, , don't quite understand structure of ldap. see how find available virtual tables in active directory, can't find available virtual columns. also, if "select * from", returns adspath. i'd select more "name", "type", , "description" objectclass='computer' group. dim objcomparr dim currcomp objcomparr = array() currcomp = -1 set objconnection = createobject("adodb.connection") set objcommand = createobject("adodb.command") objconnection.provider = "adsdsoobject" objconnection.open "active directory provider" set objcommand.activeconnection = objconnection objcommand.commandtext = "select name 'ldap://dc=mydomain,dc=com' objectclass = 'computer'" objcommand.properties("page size") = 1000 objcommand.properties("searchscope") = ads_scope_subtree set objrecordset = objcommand.execute if not objr...

java - get <aop:scoped-proxy/> that is session scoped inside of a jsp -

i have user session stored <aop:scoped-proxy/> proxy. how go accessing on jsp? i assuming bean stored somewhere in session, correct me if wrong. i found answer: http://digitaljoel.nerd-herders.com/2010/11/01/accessing-spring-session-beans-in-jsp/ in short: ${sessionscope['scopedtarget.usersession'].firstname} works charm

unit testing - MSpec runs under ReSharper fine, but TD.NET throws exception -

i've been receiving exception when trying run mspec specification tests td.net. ------ test started: assembly: designrightweb.specs.dll ------ error: runner failure: system.runtime.serialization.serializationexception: type not resolved member 'machine.specifications.runner.runoptions,machine.specifications, version=0.3.0.0, culture=neutral, publickeytoken=null'. @ system.appdomain.createinstanceandunwrap(string assemblyname, string typename, boolean ignorecase, bindingflags bindingattr, binder binder, object[] args, cultureinfo culture, object[] activationattributes, evidence securityattributes) @ machine.specifications.runner.impl.appdomainrunner.createrunnerandunloadappdomain(string runmethod, appdomain appdomain, assembly assembly, object[] args) in d:\buildagent- 01\work\340c36596c29db8\source\machine.specifications\runner\impl\appdomainrunner.cs:line 81 test 't:designrightweb.specs.given_a_string_calculator' failed: type...

Converting from a PHP MySQL result object to a result resource (OO to procedural) -

i have been handling mysql database functions within php application using object oriented style. want use function requires result resource input variable have available result object statement $oresult = $odb->query($sql); is there way produce result resource object oriented style database connection ($dbconn = new mysqli (...))? thanks you you want provide resource result set (wrapper functions encapsulate database functions. i.e., numrows(), affectedrows(), etc.), in turn can provide record set iterate results if necessary.

c# - Adding objects to javascript array and later accessing them in the same .js file -

long time reader, first time poster! i'm trying add div objects array , trying access them later when call loadviews function. of alerts fire, in proper order, array m_divs of length 0. , i'm stumped. i'm re-registering script each time on page_load, due throwing "error: object expected" after each page_load when trying call javascript if don't. .js file. var m_divs = new array(); function switchviews(obj) { alert("switchviews!"); var div = document.getelementbyid(obj); var img = document.getelementbyid('img' + obj); if (div.style.display == "none") { alert("adding div" + div); window.m_divs.push(div); alert("added"); } else {} } function loadviews() { alert(window.m_divs.length); (i = 0; < window.m_divs.length; i++) { window.m_divs[i].style.display=""; } } switch views triggered via <a href="javascript:sw...

How to change height of activity stream for Facebook Like Box social plugin? -

http://developers.facebook.com/docs/reference/plugins/like-box when using box, activity stream maxes out when set height 395. tried inspect html box , see page_stream class has height attribute when tried override css below, page_stream div doesn't expand .fan_box .page_stream { height: ; } any welcome. it's 1 of many facebook bugs. cannot set height. works if logged in facebook.

Can not get image information from Silverlight RichTextEditor -

i'm trying use silverlight richtexteditor in our website. we'd translate content in richtextbox html code save , load. however, know, richtextbox control not support uielements output. when insert image in richtextbox, richtextbox use inlineuicontainer show image. property richtextbox.xaml not include information image. shows code "". does have problem , handle before? richtextbox.xaml strips out lot of things, security safeguard (more setter getter far recall, both ways there no round-trip surpises). i recommend looking @ xaml serializer written david poll on blog (here: http://www.davidpoll.com/2010/07/25/to-xaml-with-love-an-experiment-with-xaml-serialization-in-silverlight/ ) can serialize rtb awesomely (it's in fact 1 of test cases shows). david pm on silverlight xaml parser in sl4, knows awful lot xaml. but careful when setting .xaml property, mistakenly end spinning inlineuicontainer elements load resources appdomain don't want in...

cocoa touch - iAds not showing on developer device -

on device developed app on, saw "test ad" screen on app before submitted app store. deleted version of app installed xcode , downloaded app once approved apple via app store. in newly downloaded app, still see "test ad" banner. there way see real banner on development device? curious types of ads users seeing. try deleting app , reinstalling xcode. fixed problem me.

c# - How to omit checking for SqlNullValueException in Mysql Connector/NET -

when reading data reader have check each parameter allows null values in database whether threw nullvalueexception. have check each value separate try/catch because still want parse next value first 1 null. in c# classes have tryparse(key, out value) function, returns boolean on success, didn't find connector/net. there way shorten following statements? product product; try { product = new product( reader.getstring("product_id"), reader.getdatetime("starttime") ); try { product.endtime = reader.getdatetime("endtime"); } catch (system.data.sqltypes.sqlnullvalueexception) { } try { product.description = reader.getstring("description"); } catch (system.data.sqltypes.sqlnullvalueexception) { } try { product.type = reader.getstring("type"); } catch (system.data.sqltypes.sqlnullvalueexception) { } } catch (mysqlexception ex) { throw ex; } catch (except...

jquery - "removeAttribute is not a function" error message -

mac firefox 3.6.13 firebug gives me error: "removeattribute not function" have read somewhere "removeattribute" buggy in browsers need use it. if browser problem can suggest different method. function closethumbview(){ $("#thumbreelbox").fadeout(1000, function(){ $("#thumbreellist > li > a, #thumbreellist > li, #thumbreelnav, #thumbreelbox").removeattribute('style'); }); } try use dom element removeattribute() method: function closethumbview(){ $("#thumbreelbox").fadeout(1000, function(){ els = $("#thumbreellist > li > a, #thumbreellist > li, #thumbreelnav, #thumbreelbox"); for(ind=0;ind<els.length;ind++){ els[ind].removeattribute('style'); } }); } or if want use jquery method, use removeattr() 1 of respondents said: function closethumbview(){ $("#thumbreelbox").fadeout(1000, function(){ els = $("#thumbreellist ...

java - ByteBuffer vs. Buffer on Datagram Packets -

i've read bytebuffer (java.nio) should used on buffer class reading in data because it's more efficient (?). question revolves around udp client reads packets multicast address , processes them primitive objects. efficient/fastest way parse these packets datagramsocket? right now, have datagram packet byte array wrap bytebuffer around , read there. goal minimize new object creation , maximize speed. a datagramsocket cannot read directly bytebuffer , can using datagramchannel instead.

in Rails, using HABTM, how to avoid multiple INSERTs in join table -

using has_and_belongs_to_many relationship, have following: model has_and_belongs_to_many :b, :join_table => "a_b" has_and_belongs_to_many :c, :join_table => "a_b" table a_b a_id b_id c_id current behavior: when doing a.save, 2 insert statements a_b table - a_id set, b_id, set, , c_id = 0, , other a_id , c_id set (no b_id in insert statement). therefore, there 2 rows in join table desired behavior: when doing a.save, want 1 insert a_b table, 3 ids set correctly. how do this? from understanding (as don't have access change db - legacy), can't use has_many :through on this, join table require id column. if not true, open suggestions. you might able extension method. you'd still 2 trips db, 1 can update. has_and_belongs_to_many :b, :join_table => "a_b" def save abc = a.find_or_create_by_a_id(self.a_id) abc.b = self.b abc.save end end has_and_belongs_to_many :c, :join_table => "a_b" ...

visual studio - Get Process Username c++ -

i making taskmanager app. windows,i can system processes,now want process's username.i got code net. void enabledebugprivileges() { handle hcurrent=getcurrentprocess(); handle htoken; bool bret=openprocesstoken(hcurrent,40,&htoken); luid luid; bret=lookupprivilegevalue(null,se_load_driver_name, &luid); token_privileges newstate,previousstate; dword returnlength; newstate.privilegecount =1; newstate.privileges[0].luid =luid; newstate.privileges[0].attributes=2; adjusttokenprivileges(htoken,false,&newstate,28,&previousstate,&returnlength); } char *getprocessusername(handle *phprocess, bool bincdomain) { static char sname[300]; handle tok = 0; handle hprocess; token_user *ptu; dword nlen, dlen; char name[300], dom[300], tubuf[300], *pret = 0; int iuse; //if phprocess null process handle of //process. hprocess = phprocess?*phprocess:getcurrentprocess(); //open processes...

php - How do I manage user profile page customization like twitter does? -

i'm creating simple webapps (not using framework) user profile page. , i'm thinking allow degree of customizations (theme selection, color scheme, header, etc) on page. similar twitter profile page. no layout changes. thx time. well, since developing web app, might create table in database , fill row each of users containing these customization settings. btw: here nice quickstarter using mysql in conjunction php: http://www.freewebmasterhelp.com/tutorials/phpmysql/1

ruby on rails - Paperclip, multiple attachments and validation -

does have rails 3 example of multiple attachments working validation on multipart form? i've been trying working forever (and have found every blog post , message could, none cover situation, , docs don't @ all). the first problem examples use 'new_record?' in view template, returns true in new/create sequence when validation fails because no model instances have been saved (so no 'id' value). if start 5 model instances/file inputs , upload 1 file, have 6 file inputs presented when re-render new view, , 'unless' clause fails same reason , no thumbnails presented. i want preserve link uploaded file (and know possible--they're living in temp directory) while presenting validation errors user other required fields. somebody somewhere must have working paperclip. ;) the way i'm using: i have properties has many photos (10 in case). going code whe have: in properties controller: def new @search = property.search(params[:...

db2 - How to allocate more memory to a PHP job on the iSeries? -

when running php scripts on iseries, though set memory limit -1 in php.ini... php says runs out of memory around 256mb. i'm curious if there way allocate more memory job on iseries allow php allocate more memory. finally figured out! on iseries apache configuration must set following environment variable in httpd.conf file: setenv="ldr_cntrl=maxdata=0x80000000" this allow access 2.25gb of memory in 1 php script via web server instead of 256mb (in case using zendserver , had edit config file fastcgi.conf) ref : zend forum post ibm reference

language agnostic - Algorithm to calculate number of intersecting discs -

given array a of n integers draw n discs in 2d plane, such i-th disc has center in (0,i) , radius a[i] . k-th disc , j-th disc intersect, if k-th , j-th discs have @ least 1 common point. write function int number_of_disc_intersections(int[] a); which given array a describing n discs explained above, returns number of pairs of intersecting discs. example, given n=6 , a[0] = 1 a[1] = 5 a[2] = 2 a[3] = 1 a[4] = 4 a[5] = 0 there 11 pairs of intersecting discs: 0th , 1st 0th , 2nd 0th , 4th 1st , 2nd 1st , 3rd 1st , 4th 1st , 5th 2nd , 3rd 2nd , 4th 3rd , 4th 4th , 5th so function should return 11. function should return -1 if number of intersecting pairs exceeds 10,000,000. function may assume n not exceed 10,000,000. so want find number of intersections of intervals [i-a[i], i+a[i]] . maintain sorted array (call x) containing i-a[i] (also have space has value i+a[i] in there). now walk array x, starting @ leftmost interval (i.e smallest i-a[i] )....

Rails PaperClip Attachments, knowing if there's a image thumbnail? -

i'm using rails 3 paperclip , allow users upload attachments attachment model. if file image, app generates image previews. if file not, uploads file (no image previews). now display list of attachments in db. use attachment.attachment(:large) , works fine image attachments, errors (obviously) non-image attachments. what's way check if it's image attachment or not? if not, i'd display standard static image. suggestions? thanks this did in view: <% if !(@attachment.attachment.content_type =~ /^image/).nil? %> <%= image_tag @attachment.attachment.url(:small) %> <%end%> this assumes model attachment, , file, called attachment. so like: <% if !(@attachment.attachment.content_type =~ /^image/).nil? %> <%= image_tag @attachment.attachment.url(:small) %> <%else%> <%= image_tag "/path/to/image/default.png" %> <%end%>

c# - Get currently selected line in RichTextBox -

i have richtextbox contains list of files. want open file when user double clicks on it. how selected line in c#? you can use richtextbox.getlinefromcharindex() . pass in selectionstart property value text box.

Disabling css override from html style attribute -

a height of element overriden in html 'style' attribute ext framework: <div class="class1" style="height: 900px;"> how set height 100% css file? following won't work since rule overriden html style attribute. .class1 { height: 100%; } is possible disable override rule? yes possible use .class1 { height: 100% !important; }

visual studio 2010 - Can't open the VSVim project -

i have clean install of visual studio 2010 c# , f# installed , getting following error when try open solution cloned github. d:\projects\vsvim\vsvim\vsvim.csproj : error : project file 'd:\projects\vsvim\vsvim\vsvim.csproj' cannot opened. the project type not supported installation. is there way more information missing can install components? you need install visual studio 2010 sdk .

iphone - Objective-C (iOS) Access UITextField's text from another class -

this question extremely basic , apologize if answer should staring me in face. so: have uitableview , viewcontroller. i'm updating information coredata in uitableview's .m file. in order need text in text field in other viewcontroller. so being rather inexperienced, tried: [entity setname:[nsstring stringwithformat:@"%@", viewcontroller.entitynameinputfield.text]]; i've renamed few things clarity. entity entity (no kidding), attribute i'm setting called name, viewcontroller textfield , text field called entitynameinputfield. i'm lot more interested in why sort of thing doesn't work solution problem might be. why can't text text field in way? i suppose word differently: if i'm in class , want access value of say, nsstring in class b, why can't use classa.thestring or [classa thestring] .... i've managed understand, i'm sending these objects getter methods , can't seem see why doesn't work... any appreciate...