Posts

Showing posts from June, 2012

ruby - problem with case sensitivity in acts_as_ferret -

i have problem case sensitivity - basically, searches work when lowercase: when looks text stored in index uppercase. how deal this, thanks! use string's downcase method?

.net - Read XElement from XmlReader -

i'm playing around parsing xmpp xml stream. tricky thing xml stream start tag not closed until end of session, i.e. complete dom never received. <stream:stream> <features> <starttls /> </features> .... network session persists arbitrary time .... </stream:stream> i need read xml elements stream without caring root element has not been closed. ideally work doesn't , i'm assuming it's because reader waiting root element closed. xelement someelement = xnode.readfrom(xmlreader) xelement; the code below (which borrowed jacob reimers ) work i'm hoping there more efficient way doesn't involve creating new xmlreader , doing string parsing. xmlreader stanzareader = xmlreader.readsubtree(); stanzareader.movetocontent(); string outerstanza = stanzareader.readouterxml(); stanzareader.close(); xelement someelement = xelement.parse(outerstanza); you shouldn't need work strings; should

c# - Convert an audio input to text with SAPI -

i want convert audio input being given through microphone text. prefer sapi , c# suggestions? or code samples? thanks !! you might want view previous threads, including getting started speech recognition , speech synthesis from thread: there article published few years ago @ http://msdn.microsoft.com/en-us/magazine/cc163663.aspx . best introductory article i’ve found far...

Reading a line from a file without advancing the line counter with Perl -

i want able read "next line" without increasing line counter, next time read command isued read same line. example: this first line this second line this third line i want able know second line says "this second line" not advancing counter program: print <>; print unknown_read_command; print <>; will print on screen: this first line second line second line and in more general, how can change , move pointer line in direction , amount want? you can fetch file position filehandle tell , , set seek : my $pos = tell $fh; # ... seek $fh, $pos, 0 or die "couldn't seek $pos: $!\n";

Magento 1.4 - Get the quantity of most selling products -

what php/magento code can use best selling products , display name of product. for example, i've sold 10 foos, 20 bars , 50 bazes. want know how query magento system , have "bazes" high selling products (with 50). thanks you reports little weird, they're implemented using collections don't have parent model. try following $c = mage::getresourcemodel('sales/report_bestsellers_collection'); foreach($c $item) { var_dump($item->getdata()); }

Paypal Express Checkout Recuring with Rails 3 -

i'm looking recuring billing paypal , rails 3. process express checkout, customer goes paypal enter details, confirms on website. i've looked activemerchant, support recuring billing paypal express checkout isn't there. how might go this? turned out there patch activemerchant, enough.

c# - How to define a route to match 3 parameters, when I'm only interested in the third? -

i'm trying specify route configuration allow url similar to: /{any sequence of characters}/{any sequence of characters}/{mexid} we're redesigning old system used urls of previous format. our new system has catch these requests , redirect them new url, if there 3 url parameters. it's third parameter i'm interested in. this route mapping i'm using: routes.maproute( null, "{param1}/{param2}/{mexid}", new { controller = "shareclass", action = "fundfactsheet", mexid = "" } ); the problem i'm having acting kind of catch-all invalid requests come in, interested in being route urls mexid in them. how can define route apply urls contain 3 parameters, if url doesn't match route i've more defined? you might want add route constraint (i haven't tested yet think should answer question) routes.maproute( null, "{param1}/{param2}/{mexid}", new { controller = "sh

objective c - toolbarSelectableItemIdentifiers: is not called -

Image
i'm trying make selectable nstoolbaritems. i've connected correctly in ib, toolbarselectableitemidentifiers: not working. doesn't called. delegate file's owner (subclass of nswindowcontroller), , toolbar in sheet. here's code: // toolbar dlgt - (nsarray *)toolbarselectableitemidentifiers:(nstoolbar *)toolbar { nslog(@"foo"); nsmutablearray *arr = [[nsmutablearray alloc] init]; (nstoolbaritem *item in [toolbar items]) { [arr addobject:[item itemidentifier]]; } return [arr autorelease]; } screenshot: can me please? no, don't want use bwtoolkit. are positive toolbar's delegate outlet points class (or instance thereof) think does? other nstoolbar delegate methods called there (easy enough test)?

How to get parent element by specified tag name using jquery? -

i want element's parent has specified tag name. sample code: <table> <tr> <td> <input type='button' id='myid' /> </td> </tr> </table> now want this: $('#myid').specificparent('table'); //returns nearest parent of myid element table it's tagname. see .closest() : get first ancestor element matches selector, beginning @ current element , progressing through dom tree. i.e., $('#myid').closest('table') ( demo )

jquery - Prevent Javascript from being executed twice -

i have script developing creates sliding button type effect. 5 div's situated next eachother each link. when 1 of divs clicked on associated content expanded , rest of div's closed. the problem is, if user clicks div twice while loads or clicks div in rapid succession, cracks start show. i wondering if possible allow query executed once , wait until completion rather queuing it. here current code, if crap feel free comment on how better it... not best @ javascript/jquery :p function mnuclick(x){ //reset elements if($('#'+x).width()!=369){ $('.menu .menu_graphic').fadeout(300); $('.menu_left .menu_graphic').fadeout(300); $('.menu_right .menu_graphic').fadeout(300); $('.menu').animate({width: "76px"},500); $('.menu_left').animate({width: "76px"},500); $('.menu_right').animate({width: "76px"},500); } var elementid

linq - Is there any way to clean up the following generic method using any of the new C# 4 features? -

i've modified method handling ddd commands (previously had no return type): public static commandresult<treturn> execute<tcommand, treturn>(tcommand command) tcommand : idomaincommand { var handler = iocfactory.getinstance<icommandhandler<tcommand, treturn>>(); return handler.handle(command); } the method fine, , want do, using creates fugly code: commandresult<customer> result = domaincommands.execute<customercreatecommand, customer> ( new customercreatecommand(message) ); before added customer return type treturn , nice , tidy , method infer types usage. that's no longer possible. is there way using new c# features rewrite above make tidier, i.e. using func, action, expression, etc? i'm expecting impossible, i'm getting fed of writing code call single method used simple. one option reduce have static generic type type parameter can't inferred, allowing have generic meth

statistics - two-sided censored model in R (similar to Zeligs Tobit)? -

is there model dependent variables censored on both sides? , if there implementation in r? aware of tobit models (e.g. in zelig package), they´re censored on left side... wonder if makes sense truncate on both sides... there's difference between truncation , censoring. need aware of case before start modeling. (in nutshell: censoring means events can detected, measurements not known (i.e. in case neither know exact beginning nor exact end of time interval subjects under risk event you're considering). truncation means events can observed if condition fullfilled: popular example survival in retirement home accepts people on 65 take residence - entry study population truncated @ age 65.) if have both left- , right censored data or data simultaneously right- , left-censored, techncal term looking interval censored. ?surv in package survival show how define interval censored observations modelling time-to-event in case.

iphone - iOS FBConnect access_token and resuming -

i using fbconnect in ios app, latest version of fbconnect-ios. the github docs claim no "resume" function available fbconnect sessions because developer not responsible storing access_token information. link here this , good, , can grab access_token string using [_facebook access_token]; however, can't figure out how resume session using token user doesn't have login every time app opened. does know how resume session using access_token key? many thanks! brett just call [_facebook issessionvalid] function check session.

php - Error when trying to parse XML from SVN log command -

i'm trying build simple drop down display revisions of specific file. option chosen, use jquery fetch current text contained in revision , populate textarea (using svn cat). the header in html file: <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> my shell command: svn log --xml "file:///c:/documents , settings/username_here/desktop/svnrepo/web/trunk/my_file.php" xml parsing call: $xmldata = simplexml_load_string(utf8_decode(trim(shell_exec($cmd)))); at point, error: input not proper utf-8, indicate encoding ! bytes: 0xe9 0x20 0xe7 0x61 -i'm using utf8_decode function display characters properly. instance, "é" gets displayed "é" -if change meta tag utf-8, displays properly. however, need have iso-8859-1 per organizational set rules -i'm calling svn repo using file:/// protocol temporary measure moment funny enough, jquery call necessitated header call display c

osx - Help using Simple Vector Library (SVL) with Xcode -

i writing small program using opengl , sdl. need use svl various reasons cannot link in xcode. has done before , talk me through it? followed readme svl , following when run make install: ip-156-133:svl-1.5 2 tom$ sudo make install installing /usr/local/include/svl /usr/local/doc done. installing /usr/local/lib /usr/local/include chmod: lib/*: no such file or directory make: [install-libs] error 1 (ignored) cp: lib/*: no such file or directory make: [install-libs] error 1 (ignored) done. could part of problem? also i'm not sure add -lsvl flag , -lsvl.dbg etc. any appreciated. thanks svl seems rather unmaintained, given latest version 8 years old. i'd recommend eigen , under active development , has added benefit of being header-only library .

ejb 3.0 - Doubt regarding JPA namedquery -

i trying execute namedquery @namedquery(name="getemployeedetails",query="select e.username,e.email,e.image,e.firstname,e.lastname employee e e.empid=?1") now when execute query in ejb 3.0 session bean object should return.i tried returning listits returning vector creates classcast exception.the employee table contains fields password , other confidential details don't want fetch.so not using select e employee e . learning jpa can help. below sample query fetches required fields, have make such constructor it. query : select new package_name.employee(e.username,e.email,e.image,e.firstname,e.lastname) employee e e.empid=?1; it return employee entity selected fields & remaining have default values.

web applications - Debugging ASP.Net shared pool techniques -

i work hosting company, providing asp.net 3.5 hosting. honestly, provide quite uptime , velocity. however, having problems 1 of our shared pools. usual, try maximize number of webs can run 1 pool. lately suffering continuous hangs. process doesn't crash, starts show outofmemoryexceptions or stops processing requests. think responsability of 1 of applications (it great know one). i have memory dumps have processed windbg. i've run f.e: !dumpheap -stat this method provide global memory usage of objects. nothing remarkable... i've checked: ~*e!clrstack i see various non managed threads. in managed appears stacks like: [helpermethodframe_1obj: 0f30e320] system.threading.waithandle.waitmultiple(system.threading.waithandle... 0f30e3ec 7928b3ff system.threading.waithandle.waitany(system.threading... 0f30e40c 7a55fc89 system.net.timerthread.threadproc()... 0f30e45c 792d6e46 system.threading.threadhelper.threadstart_context(system... 0f30e468 792f5781

asp.net: authentication -

when upload asp.net web application server , access url link, asking authentication... if dont, got error message: asp.net not authorized access requested resource. consider granting access rights resource asp.net request identity. asp.net has base process identity (typically {machine}\aspnet on iis 5 or network service on iis 6) used if application not impersonating. if application impersonating via , identity anonymous user (typically iusr_machinename) or authenticated request user. to grant asp.net access file, right-click file in explorer, choose "properties" , select security tab. click "add" add appropriate user or group. highlight asp.net account, , check boxes desired access. source error: an unhandled exception generated during execution of current web request. information regarding origin , location of exception can identified using exception stack trace below. what should change in web.config file in order working locally? thanks in adva

php - mod_rewrite for dynamically mapping SEO friendly links directly to individual files, without routing via front controller -

i'm looking seo friendly url rewrite rule work common php site doesn't have front controller. map seo friendly url directly php file found exist on server , convert remaining url branches standard url parameters. for example: /folder1/folder2/folder3/page/var1/val1/var2/val2/var3/val3 would map to: /folder1/folder2/folder3/page.php?var1=val1&var2=val2&var3=val3 now, here's tricky part. since rewrite rules need agnostic names of folders, pages, , variables, need base rewrite of url parameters on exact location along link can found file exists along path. instance, consider if following file happened exist (hypothetically) off document root: /folder1/folder2.php in case, following remapping legitimate , acceptable: /folder1/folder2.php?folder3=page&var1=val1&var2=val2&var3=val3 this ultimate rewrite rule many traditional websites have been built want urls , parameters instantly become url-friendly. the examples have found involve mappin

asp.net - .Net picking wrong referenced assembly version -

i copied existing project brand new machine start developing on , have run problem version of 1 of referenced assemblies (a telerik dll happens). the project referenced older version of assembly (lets call v1.0.0.0). new machine has latest version of assembly installed, thought i'd updated (lets call new version v2.0.0.0). now here's problem: if copy old v1.0.0.0 dll project folder , add reference, web site launches without problem. if delete reference (and delete old dll system) , add new version (v2.0.0.0), page shows following exception: could not load file or assembly 'xxxxxx, version=1.0.0.0, culture=neutral, publickeytoken=121fae78165ba3d4' or 1 of dependencies. located assembly's manifest definition not match assembly reference. (exception hresult: 0x80131040) clearly, code looking out of date version , can't find it. why? i greped solution folder version number , couldn't find single reference. double checked text

oop - C# Enums vs Data driven lists -

i trying figure out best way go design enum. let's have class , enum: public enum actiontype { acceptable = 1, unacceptable = 2, pendingreview = 3 } public class report { public actiontype action { get; set; } } let's have database table stores different action types: id action 1 acceptable 2 unacceptable 3 pendingreview if want add type of action @ later day have update enum , redploy assemblies. love way enums reduce errors, make code easier read , ensurance of forward compatibility. efficient way of hadeling new action types? thanks! i have had same problems have , have tried use enums as possible because make readability quite bit easier. the approach have used redundant, have created lookup table , have used mirror enum in code. problem using enums have statuses saved in db confusing such , have discerned documentation. problem db approach code readability hampered , have totally unreadable statements if (

iphone - How to move incrementally in a 3D world using glRotatef() and glTranslatef() -

i have 3d models render in opengl in 3d space, , i'm experiencing headaches in moving 'character' (that camera ) rotations , translation inside world. i receive input (ie coordinates move/the dregrees turn) extern event (image user input or data gps+compass device) , kind of event rotation or translation . i've wrote method manage these events: - (void)movetheplayerpositiontranslatinglat:(double)translatedlat long:(double)translatedlong androtating:(double)degrees{ [super startdrawingframe]; if (degrees != 0) { glrotatef(degrees, 0, 0, 1); } if (translatedlat != 0) { gltranslatef(translatedlat, -translatedlong, 0); } [self redrawview]; } then in redrawview i'm actualy drawing scene , models. like: glclear( gl_color_buffer_bit | gl_depth_buffer_bit); nsinteger nmodels = [models count]; (nsinteger = 0; < nmodels; i++) { md2object * mdobj = [models objectatindex:i]; glpushmatrix();

core dump segmentation fault with C++ -

i newbie c/cpp application , analysing issue piece of c/cpp code. came across segmentation fault error , not identify root cause of segmentation fault. please find scenario below: union value { int value_int; float value_float; rwcstring *value_string; } void setvaluestring(const rwcstring &value_string_arg) { *(value.value_string) = value_string_arg; //value reference union value. } when application makes use of piece of code, generates segmentation fault @ runtime , terminates. placed few console output statements , understood segmentation fault may due *(value.value_string) = value_string_arg; line. could please validate identification of segmentation fault? also, not pretty sure around issue. please let me know if has got thoughts on same. any appreciated. thanks ~jegan you want like: value.value_string = new rwcstring(value_string_arg); in code, if value.value_string uninitialised pointer, assignment you're doing

android - Is there a way to keep the orientation of my droid project vertical? -

can set code doesn't change orientation of screen of app if turn phone sideways? tried making new main.xml file in layout-land folder, , looks weird. so, screen doesn't turn when oreintation changed? thanks! you can like: <activity android:name="foo" android:screenorientation="portrait" />

javascript - Porting node.js server-side code to HTML5 WebSockets -

note: not using both node.js , html5 sockets. i'm not interested in discussing merits of setup i'm describing. node.js runs on server, and, since supports connecting via sockets as client , can act middle layer between html5/js client , server uses tcp/ip (such database server.) so, both node.js , websockets include ways of opening socket connections server. my question is, has ported node.js script websockets, i.e., cut node.js out of equation, web browser connects database directly? imagine like: cut out http port usage of node.js-specific functions use websockets api if has been done, lot of trouble or node.js , websockets apis relatively similar? your question bit hard parse i'll take stab. if interested in connecting websockets client (browser) arbitrary tcp socket server, might interesting in wsproxy generic websockets tcp sockets proxy. wsproxy included novnc (html5 vnc client) , has 3 reference implementations in c, python , node (nod

.net - Why doesn't the C# compiler automatically infer the types in this code? -

why c# compiler not infer fact fooext.multiply() satisfies signature of functions.apply() ? have specify separate delegate variable of type func<foo,int,int> code work ... seems type inference should handle this. wrong? and, if so, why? edit: compilation error received is: the type arguments method firstclassfunctions.functions.apply<t1,t2,tr>(t1, system.func<t1,t2,tr>, t2)' cannot inferred usage. try specifying type arguments explicitly namespace firstclassfunctions { public class foo { public int value { get; set; } public int multiply(int j) { return value*j; } } public static class fooext { public static int multiply(foo foo, int j) { return foo.multiply(j); } } public static class functions { public static func<tr> apply<t1,t2,tr>( t1 obj, func<t1,t2,tr> f, t2 val ) {

iphone - calling view methods from a view controller -

this simple question, , i'm sure got work in past. i'm trying call method in view #import <uikit/uikit.h> @interface view : uiview { } -(void)spinaction; @end from view controller #import <uikit/uikit.h> #import "view.h" @interface layers3viewcontroller : uiviewcontroller { iboutlet view *view; } -(ibaction)spinbutton:(id)sender; @end via method -(ibaction)spinbutton:(id)sender{ [view spinaction]; } but cannot work. put using interface builder. doing fundamentally wrong here? previous code worked putting [self.view spinaction] albeit error messages not works here. hints / suggestions more welcome. self.view returns object of class uiview, , shouldn't try change that. need create new outlet class of view , , wire in interface builder. @interface layers3viewcontroller : uiviewcontroller { iboutlet myview *myview; } @property (nonatomic,retain) iboutlet myview *myview; -(ibaction)spinbutton:(id)se

png - Transparent rounded corners in PHP -

is possible create transparent corners image on fly php? think possible, missing function preserve alpha values when copy image. my idea create image of same width , height, apply transparent corners, need preserve alpha channel , copy image on mask, leaving transparent still transparent, colors changed copied image (or vice versa, put mask on image). is possible , commands if there any? update: helping this. time ago, , forgot if cross question find solution visit one: http://www.pc-siete.g6.cz/galery.html . made functions gradient, radial gradient , rounded corners feel free use :) . i'm not using on webstie, it's have them prepared. for reason downloaded file had ad in it. it's stored inside zip , downloads properly. as far know there no built-in function this. can create 1 along these lines: function imageapplyroundedcorners(&$img,$radius) { // each corner // loop through pixels between corner , (corner +- radius) // i

windows phone - Creating Panorama Control Screenshots -

the microsoft panorama control common method performing layout , navigation in windows phone 7 applications. in many blogs , reviews find screenshots show entire panorama control in 1 image instead of individual sections. there way create these automatically xaml code or have merge individual pictures using image editing software? here's pretty workaround. include explanation, links, screen shots, , working sample app. wp7 tip #002: how create windows phone 7 panorama application screen shots?

sql - Creating temporary tables perl cgi dbi -

i have sql containing 8 table joins takes time fetch data considering amount of joins in sql. create temp table , sql might speed data retrieval process. i trying fetch data using sql in perl cgi dbi. makes sense create temp table on web application? i have used temp tables in sql web application before. web application part doesn't have it. temp table make sql more efficient? you'd have lot more specific question tell.

c++ - Obtaining a function pointer from an iterator over a function deque -

i'm trying build simple deficit round robin scheduler, , right i'm trying function has had least time running. i'm getting "bus error" returned me when try convert iterator pointer. below code, ptof typedef pointer kind of functions have in deque , state has info each process. doing wrong? appreciated. ptof leasttime(deque<ptof> fnc, map<ptof, state *> s){ double leastelapsed= 100000000; ptof f; deque<ptof>::iterator it; (it=fnc.begin() ; < fnc.end(); it++ ){ if(s[*it]->elapsed<leastelapsed){ f = (ptof)(&(*it)); cout<< s[f]->name<<endl; } } return f; } f = (ptof)(&(*it)); that taking address of function pointer. try f = *it; in case, avoid c-style casts. if tried static_cast instead, compiler tell cast invalid.

php - Why isn't get_post_meta working? -

simple wordpress problem - get_post_meta not retrieving custom field values. here's code pulling custom fields: <img src="<?php echo fcg_plugin_url; ?>/scripts/timthumb.php?src=<?php echo get_post_meta($post->id, 'slider_image', true); ?>&h=250&w=400&zc=1" alt="<?php echo $post_title; ?>" /> in production, html get: <img alt="post title" src="http://***.com/wp-content/plugins/jquery-slider-for-featured-content/scripts/timthumb.php?src=/&amp;h=50&amp;w=80&amp;zc=1"> you can see src= point in string empty - if there nothing posting it. have isolated , echo'd get_post_meta , it's whitespace. 100% sure it's named correctly within post - there glaring i'm missing here? search term "slider_image" in wp_posts , wp_postmeta tables using phpmyadmin. view row has see if there's inside. also try changing name of custom value test , see

c# - What to do with a winforms app that looks poor with medium/large fonts enabled on windows 7? -

i have windows forms app built .net 3.5 , relatively old version of infragistics controls. turns out of forms/controls quite poor when viewed in windows7 , medium or large fonts. options resolve this? have tens of forms , short-term solution rather rewrite, app migrated wpf or silverlight in medium term. is there switch can 'turn off' medium/large fonts app immediate fix? what general principles need followed winforms apps render nicely medium/large fonts turned on? so far main things i've found needed are: change forms/controls autoscalemode set font change forms programmatic resizing they're dependent on other controls' size or position, rather hard-coded numbers right if fonts set normal size. other things work desired. mostly. still odd odd thing track down.

Berkeley DB: Retrieving only keys -

i retrieving range of keys in berkeley db database using cursor. using db_set_range flag followed number of gets using db_next flag. everything works fine. problem need keys particular operation both keys , associated values. since values can pretty large (hundreds of kilobytes), avoid retrieving them. ideas? interesting problem. dont believe possible keys alone. one approach store keys in own database 0 data. if cant stand duplication, think best approach bulk read, since have definition locality of reference range of values. use db_multiple_key flag in dbc::get() call, , large dbt buffer data. use dbmultiplekeydataiterator iterate bulk retrieved block. this should improve things consecutive leaf items in retrieval result in efficient page copies dbt temporary buffer use in dbc::get.

How to get the address of a variable stated in C Macro? -

i new c , trying macro statements. have line this: #define write_data(src, type, value ) (write_implement(src, sizeof(type), &(value))) and in later function, use memcpy copy value in memory zone. this: void write_implement (void* src, int size_of_type, void* value) { //whatever, making destination address source address void* dest = src + 4096; memcpy(dest, value, size_of_type); } the value being passed in can of kind of data. that's why using void* point , memcpy copy number of size of bytes. but doesn't work of course :) this how call function: write_data(addr, int, i*3); // whatever integer variable gcc gives me this: error: lvalue required unary ‘&’ operand does have idea how find address of variable being passed in macro in order allow me make use of address copying? the later part of macro can changed (the "write_implement" , parameters not "write_data" parameters). , implementation part free change.

C warning: implicit declaration of function -

yes, question has been asked many times, , i've been looking , reading forums, , posts, answers unrelated (or seem) one. so, have main file : -- sgbd_server.c -- #include "sgbd_server.h" /** * open server pipe , return handle. -1 = error */ int open_server_pipe() { return pipe_open(fifo_name, o_rdonly, s_con_color); } /** * close server pipe */ void close_server_pipe(int fd) { pipe_close(fd, fifo_name, s_con_color); } int main(int argc, char *argv[]) { int pipe_fd; pipe_fd = open_server_pipe(); if (pipe_fd == -1) { perror("cannot open pipe"); } close_server_pipe(pipe_fd); exit(exit_success); } then header files : -- sgbd_server.h -- #include "common.h" #define fifo_name "./sgbd_server_pipe" #define buffer_size pipe_buf #define s_con_color 1 /* c_color_red */ -- common.h -- #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <stri

c# 4.0 - In C# bool? x = true; if (x == true) looks awkward -

bool? x = true; if (x == true) looks awkward. but needed. is there better way? edit: thank attempts, far have not found way beat original. guess need deal awkwardness, perhaps comment it. depending on situation, may want use null coalescing operator, lets specify default value you'll use if bool? not set. it's not shorter conditional, think it's useful: if(x ?? true) //defaults true if x not set or, directly replicate case (and due popular demand): if(x ?? false) //defaults false if x not set

C Socket, verifying server -

how 1 check if no connection possible (that is, server down...) c sockets? in other words; client tries establish contact connect(sock, (struct sockaddr *)&serveraddr, sizeof serveraddr) , server isn't responding. client should hold of variable verify server status, without using read / write? connect(3) return -1 on error, , set errno appropriate error. one case may have handle manually timeout. that, can either use multiple threads (a second thread kills socket if it's not connected after timeout expires), or use non-blocking sockets + poll(2) . should rare.

asp.net - problem with search -

hey, i've search in website. if search particular world works fine in pages not in contact us. contact page contains validation controls. tried removing validation controls, search works fine. on these how make search though validation controls, present. function keypress(txt) { //alert(txt); if(txt == "search") { document.getelementbyid("ctl00_txtsearch").value = ""; } } function onblur(txt) { if(txt == "") { document.getelementbyid("ctl00_txtsearch").value = "search"; // txtsearch.style.color = "silver"; } } function button_onclick() { if(document.getelementbyid("").value == "" || document.getelementbyid("").value == "search &qu

iphone - How to nest UITabBarController -

i trying nest uitabbar inside one, so: uitabbarcontroller *tabcontroller = [[uitabbarcontroller alloc] init]; tabcontroller.delegate = self; uitabbarcontroller *friendstabcontroller = [[uitabbarcontroller alloc] init]; findfriendsviewcontroller *findfriendscontroller = [[findfriendsviewcontroller alloc] initwithnibname:@"findfriendsviewcontroller" bundle:nil]; findfriendscontroller.rootviewcontroller = self; uinavigationcontroller *findfriendsnavcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:findfriendscontroller]; findfriendsnavcontroller.tabbaritem.title = nslocalizedstring(@"add", nil); friendstabcontroller.viewcontrollers = [nsarray arraywithobjects:friendstreamcontroller, friendlistcontroller, findfriendsnavcontroller, nil]; tabcontroller.viewcontrollers = [nsarray arraywithobjects:nearbynavcontroller, friendstabcontroller, mecontroller, checkincontroller, logcontroller, nil]; (obviously, of code, such other tabs ommitted br

Retrieve contact list from Hotmail using PHP/CURL -

possible duplicate: php apis hotmail, gmail , yahoo? hi guys how possible login hotmail through curl-php obtaining contact list? pleaze show me example code check out http://openinviter.com/

objective c - execution stops on [textView insertText:] without exception! -

i writing simple osx app. in app, there main thread keeps updating stuff, calculates statistics , prints them on textview. while developing, used same received ibaction perform cycle. got working, switched nsthread prevent ui locking while computing. as did that, app started running few cycles (about 7-8), whole app freezes without exception. debugging, noticed freezes when trying print statistics on textview, , have absolutely no clue how solve this. works if not inside thread... can help? code below. in advance :) -(ibaction) evolve:(id)sender{ nsautoreleasepool *pool = [[nsautoreleasepool alloc] init]; [nsthread detachnewthreadselector:@selector(evolve) totarget:self withobject:nil]; [pool drain]; } and whole cycle -(void) evolve{ nsautoreleasepool *pool = [[nsautoreleasepool alloc] init]; srandom(time(null)); //tag 0: minimo, tag 1: massimo int tagminmax = [minmax selectedtag]; //tag 0: rimpiazza sempre, tag 1: rimpiazza solo se migliori

delphi - Why do I get an access violation when I call FillChar? -

consider sample code: var p512sector:pbyte; ..... getmem(p512sector, 262144); fillchar( p512sector,262144 ,0); when run program, delphi gives me violation access error. why? use fillchar(p512sector^, 262144, 0) (note dereferencing ^). otherwise overwriting pointer , stuff behind in memory, not allocated buffer.

javascript - Best Practices for implementing Chat in Django (storing online users) -

i'm implementing chat system in django. i'm having bit of trouble deciding how create models decide online users. 2 problems see: you can't tell when user goes offline i want "users" lightweight (no log-in necessary), means don't want use django's user system. any suggestions on how go modeling this? store info in cache. it's ephemeral enough doesn't belong in long-term database, , access needs fast. you don't need store lot of info deal chat session, storing in user's session (you can anonymous non-logged in users, , pull info "real" users table if happen logged in) right way go provided you're using pure caching session backend , memcached.

Software architecture design patterns -

can please educate me on software architecture design patterns available? to elaborate question, want read through different architecture design patterns , decide suits project requirements? for example, there enterprise application design patterns, enterprise integration design patterns, esb patterns, soa patterns etc.. thank help. regards sandeep patterns occur @ many levels. architecture patterns (i.e., architectural styles) largest in scope , cover fundamental organization of system. design patterns @ level of several collaborating objects. bernd's suggestion of fowler's , other enterprise patterns one. recognize patterns tend more specific these architectural patterns: layered (i.e., virtual machine pattern) big ball of mud pipe , filter batch-sequential model-centered (shared data) publish-subscribe client-server (and n-tier) peer-to-peer mapreduce architecture patterns apply runtime structure of system, can apply modules or hardware

visual c++ - How to set last Unused drive letter to Combobox in MFC (VC++)? -

how set last unused drive letter combobox in mfc (vc++) ? code : tchar g_szdrvmsg[] = _t("a:\n"); int main(int argc, char* argv[]) { ulong udrivemask = _getdrives(); if (udrivemask == 0) { printf( "_getdrives() failed failure code: %d\n", getlasterror()); //so getlasterror retuns sring or char*? } else { printf("the following logical drives being used:\n"); while (udrivemask) { if (!(udrivemask & 1)) m_objcmbdrive.addstring(g_szdrvmsg); ++g_szdrvmsg[0]; udrivemask >>= 1; } } } m_objcmbdrive.setcursel(); what value should pass setcursel set drive letter in descending order. this code gives me drive drive letters being used in system. how unused 1 out ? to select last item in combobox, can do: m_objcmbdrive.setcursel(m_objcmbdrive.getcount() - 1); to fill combobox unused drive letters in descending order, use insertstring() method: for

Android Emulator opening view at 320*480 when set to 480*854 -

i trying set avd 480*854 device. avd seems fine when opens app surfaceview create opening @ 320*480 rather 480*854. have ideas might going wrong? cheers solution: make sure minsdkversion , targetsdkversion specified in attribute of androidmanifest.xml. stops android running in 'compatibility mode'. thanks input.

iphone - List of iOS devices that support compass/geomagnetic field -

i developing augmented reality ios app (iphone/ipad/ipod) , have list of devices feature supported. mean compass , geomagnetic field can orientation of device in degrees of freedom. thanks! the compass available on ipads , on iphone 3gs , 4.

SVN how to automatically commit into multiple branches? -

i have 1.0, 1.1, 1.2 branches , want every commit goesw 1.0 go automatically 1.1 , 1.2 , every commit 1.1 go automatically committed 1.2 is possible make in single transaction , automatically? can tell me how please? (can example please?) yes , no. can make atomic if checkout whole repository (or @ least branches folder). won't automatic though. have apply changes self other branches. different branches presumably have different code (you said version branches), applying same fix different branches may require different edits. can't (in general), avoid human intervention. i challenge idea of making 1 transaction. adversely impact quality of history. made independant changed in many places. if make merging other branches separate transaction history better reflect did (making 1 change , porting it). there reason need edit branches in 1 transaction?

c# - CS0234 Error on runtime, for classes in the same assembly -

we have asp.net 4 web application project. project contains number of pages. after having made changes error @ runtime (asp.net compile time) or namespace cannot found. at design time (in visual studio 2010) there no problem intellisense see these namespaces , classes, in project assembly themselves. , there no problems @ compile time in visual studio either. check out answer received similar question , see if trick (it did me!): .net extension method (this string foo) partially visible

dns - wildcard in hosts file -

it's not possible use wildcard in hosts file on windows or linux. there way browser plugin or else? i have dev server on vbox instance it's practically lan. i'm creating .dev domain virtual hosts example.com becomes example.dev. application i'm creating random subdomains (abd34dn.example.dev) should point dev server's ip. what options? instead of editing hosts file (which not work requirement), setup dns server , setup wildcard dns record -- *.example.dev in 1.2.3.4 you mentioned subdomains, assuming want host entries (a address entries) under example.dev. abcd.example.dev indicates "abcd" host entry, , not subdomain. if xyz.abcd.example.dev, "abcd" becomes subdomain. key point - since want abcd.example.dev - need dns records , suggested above.

.load() jQuery doesn't work with chrome? -

my code works prefectly on firefox, not on chrome. there problem jquery .load() on google chrome? it works fine me - if running code on machine , not live website, chrome may disallowing call security reasons. if doesn't help, post js console saying?

php - Ubuntu 10.04 zend-server and informix connection -

i have issue, php script connecting informix db. thought installing zend-server community edition , in addition pdo_informix extension. when run zend-server admin in browser, see pdo_informix extension marked "green". afterwards i've installed informix clientsdk 3.70 on ubuntu. i've set $informixdir environment variable /etc/profile , path variable bin directory. installation dir /opt/ibm/informix . when try write code in php try{ $db = new pdo("informix:host=xx.xx.com;database=xxx;server=xxx_net; protocol=onsoctcp;", databaseuser, databasepassword); $db->setattribute(pdo::attr_errmode, pdo::errmode_exception); echo "test"; }catch (pdoexception $e){ echo "<br/>failed: ". $e->getmessage()."<br/>"; } i've got following error in browser: failed: sqlstate=hy000, sqldriverconnect: -23101 [informix] [informix odbc driver][informix]unspecified system error = -23101. if i'm trying connect

c# - System.Timers.Timer not working every 5 minutes -

i have method must run every 5minutes in order show latest data in gridview. i experimenting system.timers.timer , following code: protected void page_load(object sender, eventargs e) { try { lblerror.text = ""; t = new system.timers.timer(300000);//every 5min = 300000 t.enabled = true; t.elapsed += new elapsedeventhandler(t_elapsed); if (!page.ispostback) { //t = new system.timers.timer(300000);//every 5min = 300000 //t.enabled = true; //t.elapsed += new elapsedeventhandler(t_elapsed); floor = ddfloors.selectedvalue.tostring(); generatestatus(); } } catch (exception ex) { lblerror.text = ex.message; } } void t_elapsed(object sender, elapsedeventargs e) { try { //response.redirect("home.aspx&quo

javascript - What are the inner workings of the Selenium waitFor mechanism? -

i trying customize behavior of selenium's click command, (via user-extentions.js), intercepting calls doclick(locator). need delay click actions whenever our application's "busy indicator" being displayed. (now standard answer kind of thing insert waitfor script situations. indeed, have zillions of them throughout our scripts. i'm trying eliminate those.) detecting page element trivial part. tricky part getting script wait. promising looking, failed attempt looks this: var nativeclick = selenium.prototype.doclick; selenium.prototype.doclick = function(locator) { this.dowaitforcondition("!selenium.browserbot.findelementornull('busy-indicator')", 5000); return nativeclick.call(this, locator); } the dowaitforcondition gets called before every click, not wait when condition evaluates false. nativeclick gets called immediately, , no delay introduced. suspect dowaitforcondition function doesn't waiting per se, rather establishes co

css - How can I select an nth child without knowing the parent element? -

i can't figure out way of selecting nth element, last element, or first element in cases don't know parent element. nth-child exists, children, example: <div> <p>one</p> <p>two</p> </div> p:last-child selects "two" paragraph, , p:first-child selects "one" paragraph. when have dynamic code , have no idea parent name is, or parent (may div, span, anchor, ul, etc.)? for example: <youdontknowwhat!> <p class="select-me">one</p> <p class="select-me">two</p> </youdontknowwhat!> how select second paragraph here? (i'm unable select youdontknowwhat! since don't know element (it's hypothetical name). why there first-child , last-child , , nth-child selectors , no :first , :last , :nth (like .select-me:first )? how :first different :first-child ? every html element child of other element in dom except <html> root e

serialization - How to deserialize 1GB of objects into Python faster than cPickle? -

we've got python-based web server unpickles number of large data files on startup using cpickle . data files (pickled using highest_protocol ) around 0.4 gb on disk , load memory 1.2 gb of python objects -- takes 20 seconds . we're using python 2.6 on 64-bit windows machines. the bottleneck not disk (it takes less 0.5s read data), memory allocation , object creation (there millions of objects being created). want reduce 20s decrease startup time. is there way deserialize more 1gb of objects python faster cpickle (like 5-10x)? because execution time bound memory allocation , object creation, presume using unpickling technique such json wouldn't here. i know interpreted languages have way save entire memory image disk file, can load memory in 1 go, without allocation/creation each object. there way this, or achieve similar, in python? try marshal module - it's internal (used byte-compiler) , intentionally not advertised much, faster. note doesn't

DB2 JDBC connection to a schema in IASP -

i have jdbc receiver adapter in pi 7.1 running on i5/os. i deployed db2 driver jspm , it's working fine on schema not in independent auxiliary storage pool (iasp) when try access schema in iasp adapter cannot establish connection. idea if need modify connection url, driver, security, ? thanks, martin url database need changed accordingly iasp. • toolbox driver: jdbc:as400://;rdbname=;; • native driver: jdbc:db2iseries:;;

iPhone SDK: How to know when background task has completed? -

we trying background task working purpose of including activity indicator in workhouse screen. our understanding, requires 1 create background thread run on. understand no gui updates can performed on background thread. given that, here general pattern of needs happen. a.) pre-validate fields. make sure user did not enter invalid data b.) setup background task. c.) process results background task this looks in code far: -(ibaction)launchtask:(id)sender { //validate fields [self validatefields]; /* operation queue init (autorelease) */ nsoperationqueue *queue = [nsoperationqueue new]; /* create our nsinvocationoperation call loaddatawithoperation, passing in nil */ nsinvocationoperation *operation = [[nsinvocationoperation alloc] initwithtarget:self selector:@selector(backgroundtask) object:nil];

Secure Login PHP CodeIgniter -

i'm building login part of codeigniter app using simple login class starting point. it's working fine, i'm unsure of differences between encryption types, , use. i've gone using crypt() function user's password salt (via md5), so: $pass == crypt($_post['login_password'], md5($_post['login_password'])) is method ok, or there glaring error in approach? seems secure neither password or salt stored in database. or bit obvious? thanks in advance. http://php.net/manual/en/faq.passwords.php this correct way implement passwords. everything below irrelevant. with have right there, simple $pass = md5($_post['login_password'] . "somerandomchars"); will suffice in cases unless high degree of security required. if you're using codeigniter highly suggest looking tankauth authentication plugin.

Toad for MySQL integration with SVN - Commit fails, comments required -

we use subversion source control , have implemented pre-commit hook checks comments , not allow commits without comments. i use toad mysql 5 manage db. provides way integrate svn , put db in source control not provide way add comments part of commit. is there way either a) provide default comment svn pre-commit hook checks comments gets or b) way override pre-commit hook checks comments toad client. you can tell doing commit (the author) using svnlook, try setting specific user toad client - that's not acceptable. the alternative allow blank commits specific file types (or repo paths) in pre-commit hook script itself. you cannot interfere suppled transaction in pre-commit hook, inspect , accept or reject it. there no client "host-agent" supplied in transaction.

performance - Dynamic-update with JPA -

i surprised learn default hibernate behavior update of fields in object if single change made , merge called. dynamic-update field allows configure alternative approach of updating changed field... http://www.mkyong.com/hibernate/hibernate-dynamic-update-attribute-example/ i using jpa hibernate , tried add following @javax.persistence.entity @org.hibernate.annotations.entity(dynamicinsert=true, dynamicupdate=true) to class (previously had jpa annotation) anyway, i've been monitoring sql , unfortunately didn't change , i'm still seeing every field updated. this java updates object... @transactional(readonly = false, propagation = propagation.requires_new) public void setaccountstatusforuser(string username, accountstatus act){ user u = this.getuser(username); u.setaccountstatus(act); this.update(u); } and update method following: @transactional(readonly = false, propagation = propagation.requires_new) public object update(ob

WP7/Silverlight Hyperlink Image -

i new both silverlight , wp7. have been attempting hotlink image using hyperlinkbutton , setting content image. however, makes image disappear. to reproduce: create new windows phone panorama application. on mainpage.xaml replace rectangle image, setting source applicationicon.png. then, surround hyperlinkbutton. <hyperlinkbutton navigateuri="http://www.bing.com" targetname="_blank"> <image source="applicationicon.png"/> </hyperlinkbutton> i have tried numerous properties , nothing works me. both items work interdependently. possible in wp7? external uri. have search documentation , found nothing that's helped. your comments , suggestions appreciated. this bit of oddity in can't directly place image control's content. topic explored here during beta. peter torr's had suggested using stackpanel hyperlink's content. did work @ time, not appear working @ moment reason. with said, richard

c# - How to handle temporary data and xml new attribute at initial element? -

before starting sorry awfull coding skills , hope can me advices , such. i have hashset of unique int values: private hashset<int> found = null; that use read data entity, each entry inserted on found unique , gives me whole new set of data. so let's consider each unique int follow data: id,m,x,y,z the hashset updated every second , when happens may gather repeated entities new data still have compare if not updating duplicated entity. so made dictionary follow dictionary<int, mylist> myitemlist = new dictionary<int, mylist>(); and above class mylist public class mylist { public int id { get; set; } public string m { get; set; } public string x { get; set; } public string y { get; set; } public string z { get; set; } } so here sample of found feeding dictionary: foreach (var myfoundid in found.except(myitemlist.keys)) { mylist listdata = new mylist(); listdata.id = get(myfoundid, "id"); listdata.