Posts

Showing posts from February, 2012

jsp - Apache tomcat setup -

i think first question here in stackoverflow. it's simple setting tomcat server. downloaded tomcat 7 yesterday, unzipped , run 'start'. strange reason, when try open "http://localhost:8080" redirecting me "glassfish enterprise server". i not sure when i've installed glassfish server (may did long ago). tried stop using commands necessary, url: http://thedata.org/book/start-and-stop-glassfish-server but doesn't stop. can please me in setting tomcat server ? thank much. a bit off topic : want server environment (at home) can practice server-scripting programming jsp, servlets , on, if can me in setting free server side 'eclipse' environment, great, appreciate it. thank you. glassfish part of java ee sdk download. downloaded , installed java ee sdk while being ignorant it's software bundle includes glassfish application server, netbeans ide (optionally) , several documentation/examples. likely installed glass...

c# - UI automation not tracking Telerik controls -

i creating application record application level , control events . using white recorder framework, able trace other controls not telerik based . want know why telerik controls not getting traced since derived system.windows.control class . is there way can use ui automation elements track telerik controls . how achieve this? afaik windows forms not support uia while silverlight , wpf does. here few links this: http://social.msdn.microsoft.com/forums/en/vsautotest/thread/016e46e3-f7cd-46fb-9e12-728f4c846304 http://blogs.msdn.com/b/lixiong/archive/2009/03/28/msaa-uia-brief-explanation.aspx

database - Every derived table must have its own alias error in MySQL -

i have following query: select sum( cost ) ( select s.cost sandwiches s s.name = "cheese steak" ) union ( select p.cost pizza p type = "plain" , size = "l" ) that gives me error of: #1248 - every derived table must have own alias you need alias temp tables select sum( cost ) ( ( select s.cost sandwiches s s.name = "cheese steak" ) t1 union ( select p.cost pizza p type = "plain" , size = "l" ) t2 ) t

Keep XMPP connection (using asmack) alive on Android -

i'm developing application receives push notifications via xmpp ( know c2dm, has limitations , can't use because of ), problem connection after time garbage collected , can't send push notification android device. i think need implement android service have no idea how implement service keep connection alive. me? i not sure if "garbage collected" right term here. more activity gets closed android, because create connection in activity. but right, in order keep stable connection need put xmpp connection service . make sure connection in thread, because service not process or thread. done, example handler . handlerthread thread = new handlerthread(service_thread_name); thread.start(); handlerthreadid = thread.getid(); servicelooper = thread.getlooper(); servicehandler = new servicehandler(servicelooper); then can communicate service thread via messages/intents. alternative binder interface. you have on how others this: beem , gtalksms both...

asp.net mvc 2 - System.MissingMethodException: No parameterless constructor defined for this object -

i have elmah controller factorym these steps using elmah makes dont have mark each method in controllers. file telling me dont have parameterless constructor while do pricelistcontroller public partial class pricelistcontroller : controller { public pricelistcontroller() { } [canonicalurlattribute("pricelist")] [compressionfilter(order = 1)] [cachefilter(duration = 120, order = 2)] public virtual actionresult index() { godscreationtaxidermyentities context = new godscreationtaxidermyentities(); var viewmodel = new pricelistviewmodel() { pricelistanimals = context.getanimallistforpricelist() }; return view(viewmodel); } [compressionfilter(order = 1)] [cachefilter(duration = 120, order = 2)] public virtual actionresult list(string animal) { godscreationtaxidermyentities context = new godscreationtaxidermyentities(); var viewmodel = new pricelistindexviewmodel() { animalpric...

jquery - animated images for navigation bar -

i trying build navigation bar shows animated gif on hover/click backdrop text. for example - want have navigation bar 3 links - home, catalogues , contact. when user scrolls on 1 of menus animated gif(?) or css/jquery animation occurs circle grows behind text , shrinks again when mouse scrolls different menu (and same effect occurs on one). has seen - , possible use animated gif rollover image - issue wouldnt able shrink circle again when hovered away link...... hope makes sense , can help!!! thanks jd you can use jquery create special effect using .hover() , .animate() . can find working example here: http://colorpowered.com/blend/ and second part of question. yes, can use animated gifs rollover image.

Android linear layout align center and right -

Image
this have: <?xml version="1.0" encoding="utf-8"?> <linearlayout android:id="@+id/linearlayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:background="#ffffff"> <linearlayout android:id="@+id/linearlayout01" android:layout_width="fill_parent" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:background="#e30000" android:layout_gravity="center_horizontal|center_vertical" android:gravity="center_horizontal|center_vertical"> <textview android:id="@+id/textview00" andro...

ruby - How to SSH into a server and then SFTP from there to another server? -

here's situation: i have ssh access servera i have sftp access serverb, servera i want use ruby ssh servera, sftp files serverb servera. i can connect servera using documentation net::ssh: require 'net/ssh/gateway' gateway = net::ssh::gateway.new('server_a', 'user') gateway.ssh("server_a", "user") |ssh| # how sftp server_b here , run sftp commands? end gateway.shutdown! what can't figure out how sftp serverb context of servera? assuming have private keys setup, run: $ ssh-add and write this: require 'net/ssh' # set :forward_agent => true automatically authenticate server_b net::ssh.start('server_a', 'user', :forward_agent => true) |ssh| puts ssh.exec!("scp -r server_b:dir_i_want_to_copy dir_to_copy_to/") end

Is String a Primitive type or Object in Javascript? -

is string primitive type or object in javascript? source says undefined, null, boolean, number , string primitive types in javascript. says string object too. i'm confused. can please explain? thank in advance ;-) both. there string object , there string literals. you can call string method on literal , can call string method on string object. the major difference string object generates new object new string("foo") !== new string("foo") that , string object type "object" , not "string" how check both? if(typeof(s) == "string" || s instanceof string){ //s string (literal or object) } credits @triynko snippet in comments

iphone - How can I set position of 3 UITable and 2 Navigation Bar? -

my xib has 3 uitable , 3 navigation bar.uitables dynamic scale , use navigation bar seperate uitable , show title of uitable name. i want set first navigation bar under first table , second navigation bar under second table. i try find frame of first table position x,y , height of table don't work. - (void)viewdidload { blah blah... cgrect table1frame = table1.frame; //but don't work } i don't know each table frame. please me or guide me.thank much i'm not sure understand you're trying do, keep in mind geometry of view controller's view (its bounds) not yet set when viewdidload called. bounds (and frames) of subviews have not been set either. means frames pretty set 0 @ point. and, may noticing if trying access view's frame, or frame of of subviews, so, if need based on view's geometry (on frame or frame of of subviews), done in viewwillappear . your problem may not where table view's frame, when it. looking in...

treeview - Tree view in sencha-touch -

i want create tree panel in sencha touch, unable find single example net , on sencha website also, istead got 1 in ext js 4, need create in sencha touch only. can help? there construct called nestedlist, seems similar. doesn't have granularity extjs treepanel seems have, however. http://docs.sencha.com/touch/1-1/#!/api/ext.nestedlist http://docs.sencha.com/touch/2-0/#!/api/ext.dataview.nestedlist

Can i add javascript in xml file where xml file has <svg> tag -

can use javascript in xml file has <svg> tag. mean file name hello.xml <?xml version="1.0" standalone="no"?> please me on thanks, pradeep yes can, need wrap javascript in cdata section. example <svg> <script> <![cdata[ function() { code........ } ]]> </script> </svg> cdata (unparsed character data) required in case because javascript's < , & characters illegal in xml. xml parser ignores inside cdata section.

aggregate - NHibernate - Eager loading grouped object when aggregating -

i have following code aggregating auction statistics statistics table , returning auction summed counts (there may multiple rows in statistics table per auction...) var stats = _session.queryover<auctionstatistic>() .select( projections.group<auctionstatistic>(s => s.auction), projections.sum<auctionstatistic>(s => s.bidcount), projections.sum<auctionstatistic>(s => s.viewcount), projections.sum<auctionstatistic>(s => s.searchcount) ) .orderby(projections.sum<auctionstatistic>(s => s.applicationcount)).desc .fetch(x => x.auction).eager .take(take) .list<object[]>(); the query seems work fine - except auction returned evaluated lazily, causing select n+1 scenario. can provide suggestions how field can evaluated eagerly? thanks in advance jp the brute force way (similar sub-select): _session.queryover<auction>()....

.htaccess - htaccess URL routing for PHP MVC? -

i've been searching , have yet find article me. i'm unfamiliar when comes rewrite engine of htaccess files, , developing php mvc framework. basically, root of webserver, need page requests controllers / actions in url redirect app/index.php so, example site.com/login/ direct index.php, , uri parsed out php enact login controller passed post data. i think 'usual' way forward requests non-existent files , directories controller: rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^ app/index.php [l]

jQuery validate Each -

i'm working on site many forms, use jquery validation script. as now, need add form.validate() on forms. make general validation forms. what came with, works on first form, , not other ones. can somehow make work on each form?? if ($('form').length) { $('form').validate({ submithandler: function() { alert("validated"); } }); } can see do? ...or know better way??? thank in advance. a longshot, since have no idea how plugin works expect wants work on object created single html form: if($('form').length) { $('form').each(function(i) { $(this).validate({ submithandler: function() { alert('validated'); } }); } }

c# - I want to use a regular class library on XBox360! -

why can't use regular class libraries in xbox360 games? i have application logic want keep independent xna , use in both wpf , xna applications. does know practice share code between xbox/phone7 applications , "regular" windows applications? have @ portable class libraries: http://msdn.microsoft.com/en-us/library/gg597391.aspx using portable class library project, can build portable assemblies work without modification on .net framework, silverlight, windows phone 7, or xna (xbox) platforms. without portable class library project, must target single platform , manually rework class library other platforms. portable class library project supports subset of assemblies these platforms, , provides visual studio template makes possible build assemblies run without modification on these platforms.

Do I have to enable webdav manually for dotCMS? -

on windows, webdav dotcms works fine. however, not work co-worekr's server. using linux. for dotcms, have enable use webdav? by default enabled, check detail here you can access 2 url links: host:port/webdav/autopub (files published uploaded) host:port/webdav/nonpub (files uploaded "working" copies) btw, usually, can download of items, when upload files, fail.

java - Cannot make this code work properly -

how make show answers randomly on 1 of 4 lines, without having duplicates? my current code: textview question; private int qtype = -1; private int asked = 0; private void qbegin() { /* * gets random question */ question = (textview) findviewbyid(r.id.question); string[] types = { "q1", "q2", "q3", "q4", "q5"}; random random = new random(); int qtype = random.nextint(types.length); question.settext(types[qtype]); asked++; // stringlist.add(types[qtype]); getanswers(qtype); /* if(stringlist.contains(types[qtype]) && asked >= types.length+1){ asked = 0; answercounter.settext("the end"); } else if (stringlist.contains(types[qtype]) && asked < types.length+1){ qbegin(); } */ } public static int random(int range) { return (int)(java.lang.math.random() * (range+1)); } public void shuffle(string input){ /* * ...

c++ - Is p = array the same as p = &array[0]? -

int numbers[20]; int * p; are 2 assignments below same? p = numbers; p = &numbers[0]; yes both same. in case, name of array decays pointer first element. hence, p = numbers; //name of array is same as: p = &numbers[0]; //address of first element of array

security - How can USB vendor ID and product ID values be spoofed on OSX? -

we considering using vendor , product id of usb device (obtained via iokit) unlock features of application. i'm aware these values can spoofed, i'm not sure how can done on osx. involved in spoofing vendor , product id? non-programmer can easily? a non-programmer cannot that. can writing kernel extension (an iokit driver) device, has matching dictionary matching real vendor-/product-id of device, causes system automatically load kernel extension when device connected , pass reference device object. driver responsible initializing device , create necessary user space information necessary iokit framework (the user space library) communicate device. apple has default iokit drivers usb device classes (that's why don't need driver every usb mouse or keyboard example), if there more specific driver found, driver used instead. , when creating user space data, of course driver may lie vendor-/product-id, causing user space program see false values. since iokit w...

Jquery/Javascript regex: filter, allow multiple tags to be typed in to select that category, jsfiddle -

http://jsfiddle.net/nicktheandroid/atknw/ the goal take value of textbox, have multiple keywords in seperated space, filter list show item(s) contain of keywords. right now, can type keywords in listed in <span class="tags"> . i able type them in, out of order, , have still keep item keywords visible item. think might have use .split(" ") somewhere in here... hmm... <li>entertainment <span class="tags">tv radio dance opera</span> </li> jquery: $("#filter").keyup(function () { var filter = $(this).val(), count = 0; var length = $(this).val().length; if (length > 1) { $(".filtered li").each(function () { if ($(this).text().search(new regexp(filter, "i")) < 0) { $(this).addclass("hidden"); } else { $(this).removeclass("hidden"); count++; } ...

Upload a file to Google Storage on GAE Java -

which best way upload file generated google app engine app google storage? gae app in java. i tried use jets3t didn't work on gae because use threads. google apis java client recommended way access google apis java clients . there examples apis, unfortunately not yet storage (the issue mentioned resolved).

c++ - Risks of running on single byte character app on a MBCS OS -

i have mfc application character set "not set". risks associated running application on os has multi byte character set code page? the "character set: not set" option defines neither _mbcs nor _unicode . means you're using *a series of functions. will return mbcs strings, when _mbcs not defined. if _mbcs doesn't affect strings returned *a functions, do? maps <tchar.h> tcs* functions mbs* versions, instead of str* or wcs* variants. e.g. without _mbcs , _tcsrev maps strrev , not _mbsrev . therefore, may not able reverse multi-byte strings receive os, or edit them otherwise.

css - Get html element rendered height with jQuery -

a simple question. for example, have class this: .someclass { font-size: 1.2em /* let's 1em set 10px in example */ padding: 1em 0 2em 0; border: 0.1em solid #000; } and simple html use it: <div class="someclass">test</div> i generated height of element - computed height border , padding. using jquery .height() method in example gives current value of line-height property - expected, because text in div has 1 line. i know calculations myself relatively simple i'd ask - there built-in solution in jquery? jquery has several methods this. see http://api.jquery.com/category/dimensions/ in case, sounds want outerheight() . http://api.jquery.com/outerheight/

amazon web services - A(Host) Records with AWS Load Balancer -

Image
i have question regarding aws load balancers. i can point cname www load balancer's dns , know work, need point @ record load balancer people can access mysite.com instead of www.mysite.com , hit loadbalancer. the problem records have point ip address can't point dns , ip of load balancer keeps changing mysite.com stops working. can recommend me work around this? here steps. click create record set for zone apex record leave name field blank select type of alias want make or aaaa (all steps after same both types) select yes radio button. open ec2 console in tab , navigate list of load balancers. click on load balancer , @ description tab in pane below list. sample output below

apache - Localhost just stopped working -

i use xampp hosting server software. everything been worked since installed software first time updated xampp regular when there better version. but 3 days ago power cut @ night , when started computer day after, can not access localhost neither 127.0.0.1 or http://localhost/ tested http://192.168.0.101/ neither 1 of them allows me access localhost. i've looked through forums similar issue come , have tested solutions have worked others. my hosts file looks should do, have no ideas on cause of problem. would grateful if solve me or give me sort of advice on solution. thanks time. yours daniel server may have stopped , may need start manually: http://www.apachefriends.org/en/xampp-windows.html#1173 http://www.apachefriends.org/en/xampp-linux.html#378

How can I change the variable to which a C++ reference refers? -

if have this: int = 2; int b = 4; int &ref = a; how can make ref refer b after code? this not possible, , that's by design . references cannot rebound.

ms access - SQL COUNT command -

create table student_exam( exam_id integer, s_id integer, primary key (exam_id, s_id), foreign key (exam_id) references exams(exam_id), foreign key (s_id) references students(s_id), pass text ); create table students( s_id integer primary key, first_name text, surname text ); create table exams( exam_id integer primary key, date_taken date ); how can correct this? select max(students.s_id) s_id, **count(pass="yes")** no_of_exams_taken student_exam, students, exams students.s_id=student_exam.s_id , exams.exam_id=student_exam.exam_id , (exams.date_taken)>=#1/1/2010# , (exams.date_taken)<=#12/31/2010# group student_exam.s_id; i count number of exams each student has passed? how count should in select command? select student.s_id, count(*) final_exam_level student, exams, student_exam (student.s_id)=student_exam.s_id , ((exams.exam_id)=student_exam.exam_id) , (exams.date_taken)<=#12/31/2010# group student.s_id, student.course_level ord...

c - What is the equivalent syntax of this line of code(myMovie->pMovieTitle->pValue) using the * and . operators? -

struct values { char *pvalue; //character string int nbytes; //amount of bytes }; struct movie { values *pmovietitle; //name of movie }; movie *mymovie; 1) equivalent syntax of line of code using * , . operators? mymovie->pmovietitle->pvalue; i tried (*mymovie).pmovietitle->pvalue which works, however (*mymovie).(*pmovietitle).pvalue doesn't work. 2) why there 2 arrow operators when there 3 pointers? mymovie, pmovietitle , pvalue pointers. for example there 2 arrow operators line of code: mymovie->pmovietitle->pvalue; and there 2 arrow operators line of code: mymovie->pmovietitle->nbytes; even though pvalue pointer , nbytes not. your second attempt should (*(*mymovie).pmovietitle).pvalue ; can't dereference struct member, value returned after accessing said member. the fact pvalue pointer irrelevant; -> used when object on left struct pointer, regardless of type of member named on right.

php - installing php_printer on wamp server -

ive been googling around on how install php_printer.dll wamp server, nothing came up. perhaps, know how install ext? basically, im trying use php printer function , need extension heard. tried http://www.issociate.de/board/goto/751941/call_to_undefined_function_printer_open().html install on wamp server, still give me error in webpage? added extension: php_printer.dll in php.ini testing code: <?php $filename = "test page"; /////// ob_start(); include $filename; $contents = ob_get_contents(); ob_end_clean(); /////// $handle = printer_open("hp80aa62"); printer_set_option($handle, printer_mode, "raw"); printer_write($handle,$contents); printer_close($handle); ?> although don't have experience installing/enabling extensions myself, has worked me in past: ensure php_printer.dll listed under "ext" directory inside of php installation. if isn't there, need download extension , save under "ext" directory. ...

Plugin system for text editor writen in C++ -

i creating cross platform text editor in c++. have basic base, implement features through plug-ins. but, unfortunately i'm getting in designing plug-in system. how done? can point me in right direction? don't know if matters, i'm using wxwidgets widget kit. you can start having base class defining specific plugin interface ie: texttransformplugin, method taking string , returning string (virtual). each plugin inherit interface , build class eg: spanishtranslatetransformplugin in dynamic library (.so file). from program use dlopen open library (see here c++ example). can't call class constuctor, in library define standard function (same name plugins, lets create() , give c calling conventions can use dlsym symbol , cast function returning texttransformplugin , call it. extern "c" { texttransformplugin * create(); // return new spanishtranslatetransformplugin } that way texttransformplugin object plugin. interface methods virtual, co...

c++ - Is there any enhanced gdb console for Eclipse? -

currently gdb console of eclipse connects stdin/stdout between java gui , underlying gdb process, hence many gdb shell features missing, e.g. tab-autocomplete, command history etc. i want know if there enhanced console fast gdb interacting. used gdb commands "print" , "call" etc. imho, "print" command superiors eclipse "expression watcher" because execute once , later evaluated time , crash-prone. if think there no need use gdb console, what's best-practise in terms of gdb ui eclipse ui transfer. there doesn't seem gdb-specific plugin, beside initial gdb integration initiated eclipse3.4 . and current list of gdb bugs doesn't include missing features.

How can I lag a computer in c#? CREATE lag! -

this odd question, understand. assumed simple, because lord knows have created share of infinite loops. i'm trying cause slight pc lag in c# - need create 'choppy mouse' situation system wide (not sandboxed exe). the little app can't crash computer! lag should able run 2-10 seconds ish - stop. what have tried far: -spawning numerous threads save data (filled memory , cause pf usage, no real lag). -spawning tons of threads (lag @ first, none when treads re-spawned again - if second time os ready). -spawning threads take several screenshots (the screenshots don't seem lag). none of these have worked - ideas? optional story (optional): reason application, without divulging company information, cover laggy background process in production environment. have tried speed app up, or improve computers no results. there abuse case present when production workers associate lag background application running. goal disassociate lag ... creating similar 1 @ rand...

Xcode memory addresses were in hex but now are in decimal. How do I change back to hex? -

Image
using xcode 4.2. when viewing memory in memory browser, memory addresses in leftmost column (called "line numbers" in editor menu) showing decimal numbers. earlier today, in hex. prefer hex can't figure out how change format decimal hex. the individual variables, shown in variables view, have addresses in hex. contents of memory shown in hex. edit: screenshot: red rectangle around decimal addresses. have since found clicking anywhere in column red rect toggles between hex , decimal addresses. thx cocoafu helping me figure out. . not sure how trying first clue "line numbers" not viewing memory. created: int *a = malloc(500); a[0] = 3; right (control) clicked on "a" in locals variable display, selected view memory of "*a" click in red rect change between different address bases (decimal/hexadecimal)--thanks @onquest

.net - I'm not getting any OnPaint events for my panels -

i have panel containing panel contains panel contains several labels. onpaint event outer panel , labels not intervening panels. what's going on?? update: tracing wrong when cliprectangle size(0,0) happens entirely overlain panel. a paint event raised whenever there part of control needs repainting. areas of control covered (opaque) control obscured control, logically won't need repainted. thus, if panels entirely covered child controls, may never raise paint events.

jquery - facebook like lightbox plugin with comment feature on photo -

is there plugin implementing lightbox comment feature in facebook,google+. i planning use in asp.net mvc 3 thanks in advance. colorbox best javascript lightbox implementation, hands down. as comment features, disqus might me style. best of all, these work on client-side, shouldn't matter whether backend in .net or plain old c!

Android:Unlock Screen -

i able unlock screen when there incoming call , after lock screen again. after restart of device if first incoming call logic not working. on subsequent incoming calls logic works. any help?? my code is: string state = intent.getstringextra(telephonymanager.extra_state); if (state.contentequals("ringing")) { lock.disablekeyguard(); } lock.reenablekeyguard(); it seems me "lock" object not exist until first call made can't tell looking @ piece of code. i use windowmanager unlock , lock screen. window window = getwindow(); windowmanager.layoutparams windowparams = window.getattributes(); winparams.flags |= windowmanager.layoutparams.flag_show_when_locked; window.setattributes(winparams); http://developer.android.com/reference/android/view/windowmanager.layoutparams.html hope helps

Question about reversed lists in Python -

i new python, able tell. if have list: a = [1,2,3,2,1] this evaluates true: a == a[::-1] ...but evaluates false: a == a.reverse() why case? because .reverse() reverses list in-place , returns none: >>> print a.reverse() none and a == none evaluates false .

sql - Row Inserted and Updated Time in Fact Table -

i see there importance in having row inserted , row last updated fields in fact table. not find standard data warehouse or reference says thing do. uncertain whether because bad practice; if why should so? if because of data size, see 8bytes full date field. any appreciated!!! there's nothing talking whether it's or bad practice because include creation time , updated time if need them or ever need them. it's "good thing do" if need access columns , "bad thing do" if table never require columns.

DOS script to read one file into another -

i discovered couldnt granted bulkadmin or sysadmin role on hosted sql server db , trying bypass bulk insert operation creating .sql file containing insert statements. insert statements created using xls macro, theres bit of manual bodyshopping work doing now. let me draw problem here. i have text file following contents - 10/05/2011 01:21 pm 1-16332-1008261.psa 10/05/2011 01:21 pm 1-16332-1011698.psa 10/05/2011 01:21 pm 1-16332-1023151.psa 10/05/2011 01:21 pm 1-16332-1035695.psa 10/07/2011 03:36 pm 1-16332-1023193.psa 10/07/2011 03:36 pm 1-16332-1035694.psa 6 file(s) 8,933,754 2 dir(s) 1,675,268,096 free what want achieve in final output file - insert xyz.abcd values('10/05/2011', '1-16332-1008261.psa'); insert xyz.abcd values('10/05/2011', '1-16332-1011698.psa'); insert xyz.abcd values('10/05/2011', '1-16332-1023151.psa'); insert xyz.abcd values('10/05/2011', '1-16332-1035695.psa'); insert xyz.abcd valu...

database - MySQL question for conversation app -

i have app manages conversations between users on website. 1 one conversations having multiple people in single conversation. here layout mysql tables conversations conversations_meta the conversations_meta table links users conversations logging user_id , conversation_id. holds meta info conversation specific each user in conversation. what having trouble detecting if conversation same people exist. example if conversation between eric jason , bob exists maybe it's old , user forgot , tries create addition conversation same users notify them of conversation. so query should in conversations_meta table , compare user_id , conversation_id see if same conversation exists already. wouldn't want return conversations include same users , additional users well. main reason posted question on here fastest query possible accomplish task since there thousands of conversations. what this: select conversations_meta.conversations_id conversations_meta (conversat...

reflection - Detecting whether a method/function exists in Java -

is there method/function in java checks if method/function available function_exists(functionname) in php? here referring method/function of static class. you can find out if method exists in java using reflection. get class object of class you're interested in , call getmethod() method name , parameter types on it. if method doesn't exist, throw nosuchmethodexception . also, please note "functions" called methods in java. last not least: keep in mind if think need this , chances you've got design problem @ hand. reflection (which methods inspect actual java classes called) rather specialized feature of java , should not used in business code (although it's used quite heavily , nice effects in common libraries).

ios - Error when assigning NSString variable in a block -

- (nsstring *) geocodeaddressfromcoordinate:(cllocationcoordinate2d)coordinate { cllocation *location = [[cllocation alloc]initwithlatitude:coordinate.latitude longitude:coordinate.longitude]; __block nsmutablestring * address = [nsmutablestring string]; geocoder = [[clgeocoder alloc]init]; [geocoder reversegeocodelocation:location completionhandler:^(nsarray *placemarks, nserror *error) { if (error) { nslog(@"%@", [error localizeddescription]); uialertview *alert = [[uialertview alloc]initwithtitle:@"no results found" message:@"try search" delegate:self cancelbuttontitle:@"cancel" otherbuttontitles:nil, nil]; alert.show; return; } if ([placemarks count]>0) { nslog([placemarks description]); clplacemark *placemark = [placemarks ...

html - How to set the color of "placeholder" text? -

is possible set color of placeholder text ? <textarea placeholder="write message here..."></textarea> nobody likes "refer answer" answers, in case may help: change html5 input's placeholder color css since it's supported couple of browsers, can try jquery placeholder plugin (assuming can\are using jquery). allows style placeholder text via css since it's swap trick focus events. the plugin not activate on browsers support it, though, can have css targets chrome\firefox , jquery plugin's css catch rest. the plugin can found here: https://github.com/mathiasbynens/jquery-placeholder

objective c - how to create a link button in iPhone? -

Image
here in above figure sleeping baby link button . i don't want place uitextview opens pickerview how can create link button of similar kind in iphone? use uiwebview display text. can supply html link url. mean link button? or want happen when text pressed? subclass uilabel , detect touch down event , in response that. or text button , make button surrounding area act button , use 1 of control events respond selection.

junit4 - Paramterized Testing with Junit -

how can test following method parameterized testing in junit public class math { public static int add(int a, int b) { return + b; } } i wish know how parameterized testing junit implemented test method, when want test 10 different args. the test class must have annotation @runwith(parameterized.class) , function returning collection<object[]> should marked @parameters , constructor accepting inputs , expected output(s) api: http://junit.sourceforge.net/javadoc/org/junit/runners/parameterized.html @runwith(parameterized.class) public class addtest { @parameters public static collection<object[]> data() { return arrays.aslist(new object[][] { { { 0, 0, 0 }, { 1, 1 ,2}, { 2, 1, 3 }, { 3, 2, 5 }, { 4, 3, 7 }, { 5, 5, 10 }, { 6, 8, 14 } } }); } private ...

Is a "Globals" class holding static variables in Android safe? -

can enlighten me safety of class holding global values in android? here's short example of mean: public class globals { public static int somevariable = 0; public static user currentuser = null; public static handler onlogin = null; } then somewhere in activity following: globals.somevariable = 42; globals.currentuser = new user("john", "doe"); i have rely on globals.currentuser @ multiple places in app user logged in, i'm unsure if should it, , if use handler this. i read everywhere android app killed anytime, mean killed or maybe part of it, killing globals class only? or there other way store globally available data in safe way, without writing every member change database (in fact, user class little more complex in example. ;-) thanks effort! edit: ok, here's did: public class myapp extends application { private static myapp _instance; public myapp() { super(); _instance = this; ...

jquery - jsfiddle works in FireFox, Chrome but not IE8 -

here jsfiddle . works fine in chrome , firefox, error when running in ie8: message: object doesn't support property or method line: 244 char: 9 code: 0 uri: http://jsfiddle.net/js/actions.js i added code jsfiddle site , i'm seeing same issue ie8. have add specific working in ie8? thanks one of jsfiddle's scripts contains error. expecting element have been extended mootools, it's not. if knew how, i'd tell jsfiddle devs need wrap e.target in call $() : line 244 of http://jsfiddle.net/js/actions.js : if (e && $(e.target).getparent().get('id') == 'm') { edit: work around, add bookmarklet links bar , click once when page loads. run button in state error won't occur anymore. javascript: $$("#run > span"); void 0; another work around use ctrl + enter instead of clicking "run" button. while we're on topic of making jsfiddle behave ie through bookmarklets, here's 1 use jsfiddle t...

Multi layered architecture using Entity Framework 4 and Repository Pattern -

i have build architecture of web application using entity framework 4.1 , asp.net. have database structure, have use database-fist. have read lots of articles , threads here, seems i'm missing something. have decided organize projects in following way: i have architecuted web app linq2sql. used this project . provides t4 template generates specific static repository class each entity. approach easy add additional logic repository, such getuserbyname() . approach cannot find similar approach ef4 far. have found generic repositories , have manually create concrete repositories. don't in case first have application i'm working on has bit complex business logic, have manually create concrete repositories each entity. second, if @ first use generic repository entities, , later need use, example getuserbyname() , there inconsistency in code. prefer data retreiving done same way. i either missing in architecte structure. generic: generic repository if neccessary seperat...

wolfram mathematica - How to get all definitions associated with other symbols? -

how definitions symbol associated other symbols tagset , tagsetdelayed , upset or upsetdelayed ? for example, if 1 has defined area[square] ^= s^2 area[cube] ^= 6*s^2 how obtain these definitions, not knowing names square , cube knowing name area ? i have found upvalues not return definitions makeboxes , n since stored in formatvalues , nvalues correspondingly: in[1]:= rotate /: makeboxes[expr_rotate, "standardform"] := x upvalues[rotate] formatvalues[rotate] out[2]= {} out[3]= {holdpattern[makeboxes[expr_rotate, "standardform"]] :> x} in[4]:= pi /: n[pi] = 3.14 upvalues[pi] nvalues[pi] out[4]= 3.14 out[5]= {} out[6]= {holdpattern[n[pi, {machineprecision, machineprecision}]] :> 3.14} in way instead of upvalues should use combination of upvalues , formatvalues , nvalues . when trying output list of formatvalues 1 can face problems makeboxes since formatvalues gives definitions makeboxes are further processed makeboxes...

android - Horizontal ProgressBar increment with percentage -

i have written program in android downloading web server have used json , http request program working properly... want show progress bar percentage depending upon things downloading. query how increment progress bar in percentage depending upon things downloaded , pending. know how calculate percentage how know how downloading pending server. how downloading pending server. you have implement range request in application. you may use this reference if using chunks. otherwise, simple downloads urlconnection cxn = url.openconnection(); cxn.connect(); int lenghtbytes = cxn.getcontentlength(); how increment progress bar use publishprogress() in case of asynctask publishprogress((int)(bytesdownloaded * 100 / lenghtbytes));

combobox - DevExpress RepositoryItemComboBox different background color -

does possible set different background color each item of devexpress repositoryitemcombobox? repositoryitemcombobox.appearancedropdown.backcolor affects items. this can done using repositoryitem's drawitem event. here sample code: private void repositoryitemcombobox1_drawitem(object sender, listboxdrawitemeventargs e) { if(e.state == drawitemstate.none) { e.appearance.backcolor = e.index % 2 == 0 ? color.green : color.red; } }

javascript - Cannot get access to the Jquery JCrop api -

i trying access jcrop api ( http://deepliquid.com ). here code snippet : // selected image has been loaded $('#selectedimage').load(function() { var jcrop_api = $('#selectedimage').jcrop({ touchsupport: true, onselect: cropselected }); jcrop_api.setselect([ 100,100,200,200 ]); }); i in console : typeerror: result of expression 'jcrop_api.setselect' [undefined] not function. i aware can pass parameters options, use api perform other stuff (setimage, etc.) any ideas ? lot ! you calling api in wrong way... change this: var jcrop_api = $('#selectedimage').jcrop({ touchsupport: true, onselect: cropselected }); to this: var jcrop_api = $.jcrop('#selectedimage',{ touchsupport: true, onselect: cropselected });

c# - ScrollViewer in ItemsControl - ScrollBar not shown but working -

this not average "my scrollviewer isn't working" question... assume window grid. sizes of column 0 , row 1 set auto , column 1 , row 0 set * . (important) in cell [0, 0] there itemscontrol template stackpanel inside scrollviewer inside grid . reason simple: show scroll bar if not items in itemscontrol can displayed. visibility of vertical scrollbar set auto (important). in cell [1, 1] there button displays width. if window small display items in itemscontrol lead following: scroll bar there not visible. working, because can scroll using mouse wheel. reason seems grid column in itemscontrol contained not automatically extended make space scrollbar. if change (nearly) any of parameters, scroll bar displayed expected , second column reduced in size. can explain odd behavior? additional info: the following parameter changes lead scrollbar becoming visible: changing size of column 0 * changing size of column 1 auto changing size of row 1 * r...

Different hint font style and typed in text font style android -

i want have different font style hint , font style typed in text in edittext. eg. lets hint font size 12 , normal type. when user starts typing edittext, font size of typed text should become 14 , bold. again if user remove text hint should of above mentioned type. you can programmatically change hint color make different font style typed in edittext using following code edittextid.sethinttextcolor(color.alpha(006666));

Algorithm question -

if f(x) = o(g(x)) x -> infinity, then a. g upper bound of f b. f upper bound of g. c. g lower bound of f. d. f lower bound of g. can please tell me when think , why? answer g upper bound of f when x goes towards infinity, worst case scenario o(g(x)) . means actual exec time can lower g(x) , never worse g(x) . edit: as oli charlesworth pointed out, true arbitrary constant k <= 1 , not in general. please @ answer general case.

windows - Send email from a batch script. Blat doesn't work -

Image
i need send email batch script. tried several solutions without success. for example, blat : :send_mail "\program files (x86)\blat275\full\blat.exe" -server smtp.gmail.com -port 525 -f myadress@gmail.com -to recipient@foomail.com -s "hello" -body "world" when run script, windows crash: does have better solution? edit & solution i tried on our server (with our smtp) , worked blat. see the full code in answer below. realize old, googlers: blat not work gmail, requires ssl connection accessed on smtp, blat doesn't (as of 06/02/2013) support see here: http://www.jeffkastner.com/2010/01/blat-stunnel-and-gmail/ (slightly messy) workaround.

objective c - How can I pass a parameter when initializing a UIViewController? -

i have 2 controllers, first- , secondviewcontroller . want share methods of firstviewcontroller use them in secondviewcontroller. this how create secondviewcontroller in firstviewcontroller: sms = [[secondviewcontroller alloc] init]; uinavigationcontroller *navcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:sms]; [self presentmodalviewcontroller:navcontroller animated:yes]; i thought of passing current instance of firstviewcontroller secondviewcontroller extends uiviewcontroller . default initwithnibname method of secondviewcontroller called. how achieve in objective-c? im not sure understand problem... part of issue has how instantiating secondviewcontroller... posting code help. but answer question have asked it.... "how pass firstviewcontroller secondviewcontroller"... in secondviewcontroller.h create own init method -(id) initwithfirstviewcontroller:(uiviewcontroller *)thefirs...

"java.net.ConnectException: Connection refused" in zookeeper -

i installed zookeeper follows : wget http://archive.cloudera.com/cdh/3/zookeeper-3.3.3-cdh3u1.tar.gz here zoo.cf : # number of milliseconds of each tick ticktime=2000 # number of ticks initial # synchronization phase can take initlimit=10 # number of ticks can pass between # sending request , getting acknowledgement synclimit=5 # directory snapshot stored. datadir=/home/reach121/basf/data/zookeeper/data1 # maximum client connection maxclientcnxns=500 # port @ clients connect clientport=2183 server.1=localhost:2878:3878 server.2=localhost:2879:3879 server.3=localhost:2880:3880 and started /bin/zkserver.sh start zoo.cfg and when do? bin/zkcli.sh -server 127.0.0.1:2183 it gives me error: connecting 127.0.0.1:2183 2011-10-13 14:11:28,433 - info [main:environment@97] - client environment:zookeeper.version=3.3.3-cdh3u1--1, built on 07/18/2011 15:17 gmt 2011-10-13 14:11:28,437 - info [main:environment@97] - client environment:host.name=cignexnew 2011-10-13 14:11:28,437...

php - Programming In General - Binary Search Algorithms -

given array $array of n numbers , key $key, write binary search algorithm in plain english. if $array contains $key, return index of $key; otherwise, return -1. can show me how this? doesn't seem should give code here, maybe description can help? sort list. let i = length / 2 compare term @ index i key. a. if equal, return index. b. if key greater term, repeat 3 (recurse) on upper half of list i = (i + length) / 2 (or (i + top) / 2 depending how implement) c. if key less term, repeat 3 on lower half i = i/2 or (i + bottom)/2 stop recursion if/when new i same old i . means you've exhausted search. return -1 be careful off-by-one errors, can make exclude terms mistake, or cause infinite recursion, general idea. pretty straightforward. think of playing 'guess number' numbers 1 through 100. take guess, tell higher or lower. 50, lower. 25, higher. 37...

c - Call static lib function embedded in DLL -

let's following architecture: a static library used/linked within dll the dll loaded (either implicitly or explicitly) executable is possible executable code access code of static library without relinking explicitly nor inserting wrapper functions in dll? in other terms, looking way make dll export of dependant static library code. given constraints, answer no. the reason executable doesn't have visibility dependencies or "call-ees" of dll. far executable concerned, he's knows dll itself: @ link time, executable knows exports consuming dll. he's going loadlibrary() against dll (which fail if dependencies of said dll aren't resolvable), call exports of said dll. if can't statically link library used dll reason, approach wrap calls said static library. can pain of there lots of calls, there automated tools others have created help. in particular i've used before create wrapper dll exported hundreds of functions when want...

java - 2 Hashtable Keys -

i'm having 2 records title. example record 1: title record 2: title i need store them arraylist using hashtable. this do. package com.testing; import java.util.hashtable; import java.util.arraylist; import java.util.dictionary; public class anotherclass { private hashtable <string, string> items = new hashtable <string, string>(); private arraylist <hashtable <string, string>> finalarray = new arraylist <hashtable <string, string>>(); public arraylist <hashtable <string, string>> returnarray() { return finalarray; } public void adding() { this.items.put("record", "record 1"); this.items.put("format", "my title"); this.finalarray.add(items); this.items.put("record", "record 2"); this.items.put("format", "my title"); this.finalarray.add(items); } } w...

session - How to measure HttpSession size accurately and effectively -

is there easy, effective , accurate way measure session size in servlet based application? preferably measuring method should application server/container independent. tried measuring session size lambda probe on tomcat 7, seemed me quiet inaccurate, slow , buggy. think there should easy straightforward way, because every decent java ee developer cares session size. i want stress test application , measure session bloat. this how calculate size of session in application itself: totalsize = 0; totalserializable = 0; totalnumber = 0; httpsession session = getsession(); enumeration<string> attrs = session.getattributenames(); while (attrs.hasmoreelements()) { string attr = attrs.nextelement(); sessionobject sobj = new sessionobject(attr, session.getattribute(attr)); sessionattributes.add(sobj); if (sobj.isserializable()) { totalsize += sobj.getsize(); totalserializable++; } totalnumber++; }

iphone - Why calling [self becomeFirstResponder] caused so many problems? -

for past few extremely frustrating days of life, i've been trying figure out what's wrong me code. in page, if put uitextviews or uitextfields or mfmailcomposer or messagecomposer or fields require editing, fields wouldn't respond touches. couldn't edit when ran app. couldn't edit text views or email fields or anything. tried everything, nothing worked. turns out on main page ( mainvc ) leads page fields don't respond ( giftvc ), in viewdidappear method (in mainvc ), say: [self becomefirstresponder]; . now i'm not sure why put there, turns out commenting line out fixes , makes fields , textviews , email composers , work fine again. i have in mainvc page: -(bool)canbecomefirstresponder { return yes; } and commenting out fixes problem well. the weird part [self becomefirstresponder] line, worked fine in new ios 5 (simulator , device), in ios 4 (simulator , device), wouldn't work @ line. i've removed it, works fine in both cases....

text - Confusion with J2me reading file. Please Help me understand -

i working on j2me app symbian s60 phones reading text file required. have no access bufferedreader extract line of text file, did find in nokia forums, , has me bit confused. here's code, , question below. answering. /** * reads single line using specified reader. * @throws java.io.ioexception if exception occurs when reading * line */ private string readline(inputstreamreader reader) throws ioexception { // test whether end of file has been reached. if so, return null. int readchar = reader.read(); if (readchar == -1) { return null; } stringbuffer string = new stringbuffer(""); // read until end of file or new line while (readchar != -1 && readchar != '\n') { // append read character string. operating systems // such microsoft windows prepend newline character ('\n') // carriage return ('\r'). par...

php - Why are there � on my page -

i've set page default charset , mysql table charset utf8. works on of pages, on pages when output chinese characters '全' , '公' appears � while on other pages can output normally. the difference between pages , error pages realize used ereg_replace before output on error page. $sounds = nl2br($model->sounds); $sounds= preg_replace('/(\v|\s)+/', ' ', $sounds); $sounds= preg_replace("#(<br />|<br /> )+[< b r > \ ]*[<br />| <br /> ]+#","<br>",$sounds); $pattern='#[\d]+[\-]*[\d]*[\.]+#'; if(preg_match($pattern,$sounds)&&!preg_match('#<br />|<br />|<br>#',$sounds)) { $sounds= preg_replace("#[\d]+[\-]*[\d]*[\.]+#","<br>",$sounds); } could these functions reason? or else reason be? update: fo...