Posts

Showing posts from March, 2015

Integrate a Java stand alone application to the Web -

i develop java applications eclipse process data. far developed stand alone applications take data file or database, process data, , output results console/file/database. i put application online. never did web development, understanding, difference code needs on web server can http requests users, , return http response based on application's result. i advice on easiest way can this. technology need learn , tools can use making transition easier. separate code code related web stuff. thanks lot! the simplest approach developing java web applications via servlet specification. lets load application servlet container (such jetty or tomcat), handles http-side invocation issue. servlet front-end front end agnostic processing application. since applications require user interface, take @ myraid of possible templating languages available. velocity safe pick. seperate user interface adapter code.

menu - jQuery Easing Tutorial -

i'm developing menu , need incorporate jquery easing effect sub menu. submenu horizontal dropline menu. here's html , css if you're interested in looking @ it. both not completed don't mind mess :) preview http://wilwaldon.com/easing/easingmenu.html i've googled didn't find total noobie myself. thank you! found asnwer cletus. superfish work perfect situation , easy implement using few simple css changes.

Python - Speed up generation of permutations of a list (and process of checking if permuations in Dict) -

i need faster way generate permutations of list, check if each 1 in dictionary. x in range (max_combo_len, 0, -1): possible_combos = [] permutations = list(itertools.permutations(bag,x)) item in permutations: possible_combos.append(" ".join(item)) #then check see if each possible combo in specific dict if helps, lists going lists of strings. ['such as', 'this', 'one'] my solution works, it's slow. need stop using python, thought i'd run experts first! best, gary i can't test without better input cases, here few improvements: for x in xrange(max_combo_len, 0, -1): possible_combos = (" ".join(item) item in itertools.permutations(bag,x)) #then check see if each possible combo in specific dict combos = (c c in possible_combos if c in specific_dict) first, assuming you're using python 2.x, xrange not constructing explicit ...

iphone - I do not know how to fix the leak -

how fix leak here? -(nsarray *)sectionindextitlesfortableview:(uitableview *)tableview { if(searching){ return nil; } nsmutablearray *temparray = [[nsmutablearray alloc] init]; [temparray addobject:uitableviewindexsearch]; [temparray addobject:@"a"]; [temparray addobject:@"b"]; [temparray addobject:@"c"]; [temparray addobject:@"d"]; [temparray addobject:@"e"]; [temparray addobject:@"f"]; [temparray addobject:@"g"]; [temparray addobject:@"h"]; [temparray addobject:@"i"]; [temparray addobject:@"j"]; [temparray addobject:@"k"]; [temparray addobject:@"l"]; [temparray addobject:@"m"]; [temparray addobject:@"n"]; [temparray addobject:@"o"]; [temparray addobject:@"p"]; [temparray addobject:@"q"]; [temparray addobject:@"r"]; [temparray addobject:@"s"]; [temparray addobject:@"t...

JavaScript Image Loading -

when click on button javascript function invoked , loads image in page. image not loading properly. image size 72kb , image coming db , it's loaded in server start. if put alert message image loads properly. what's reason behind issue? var catimg = document.getelementbyid(\"categorysampleimage\"); var oldimgsrc = catimg.src; var newimgsrc = oldimgsrc.substr(0,oldimgsrc.indexof(\"images\"))+\"images/\"+\""+imagename+"\"; catimg.src=newimgsrc; (var intcounter = 1; intcounter <= 500; intcounter++){ (var counter = 1; counter <= 500; counter++) { if(counter==500) break; } } document.getelementbyid(\"light\").style.display=\"block\"; document.getelementbyid(\"fade\").style.display=\"block\";"; code works fine browsers except ie6. in ie6 can see white area in place of image , need right clic...

c# - How to change modifier of a control to Static in Visual Studio -

when create control drag , drop vs automatically generate code this: public system.windows.forms.label label1; when want change modifier of control static, go form1.designer.cs , edit to: public static system.windows.forms.label label1; it's ok. when modify every control, vs automatically change origin :(. how change modify of control static ? sorry, im bad @ english :( code comment: public static void setlabelinfovisible(bool visible) { if (form1.labelinfo.invokerequired) { setlabelinfovisibledelegate del = new setlabelinfovisibledelegate(setlabelinfovisible); form1.labelinfo.invoke(del, new object[] { visible }); } else { form1.labelinfo.visible = visible; } } designer code not supposed user modified, gets re-written visual studio every time make changes form in designer (as have discovered). one way forward move control declaration , initialization non designer code file. however, means control ...

Image Processing on Android -

i'm writing application android. need make image processing on picture taken camera. use camera.picturecallback photo, , picture in byte array. problem want make operations on every pixel of photo (some filtering , other stuff) guess, have photo in byte array not bad idea. don't know how interpret information in byte array... way know make processing use bitmapfactory.decodebytearray() , use bitmap object. way handle lot of image processing? right use this: bitmap mphotopicture mphotopicture = bitmapfactory.decodebytearray(imagedata, 0 , imagedata.length); mphotopicture = mphotopicture.copy(bitmap.config.rgb_565, true); i appreciate help. i'm not sure if decoding byte array best way on android, can offer know image processing in general. if you're using rgb_565 , means each pixel 16 bits, or 2 of bytes. first 5 bits red, next 6 green, , last 5 blue. dealing hairy in java. suggest work easier format argb_8888 , mean have 32 bits, or 4 byt...

jquery and user city -

at first, sorry english. question is: have php generated dynamic div, id , image source.. if user click on dynamic div swap img source. script works, swaps div images, not selected div img source. problem? how can swap clicked div img source? can someone, me please? my script: <script> ( function($) { $(document).ready( function() { $("div.area_map").click( function () { $('div[id^=grass]').each(function(div) { $('img.hoverswap').css("width","229"); $('img.hoverswap').css("height","124"); $('img.hoverswap').attr("src","default/citymap/d5.png"); $('img.hoverswap').css("z-index", "9999") } ); }); } ) ( jquery ); </script> and div: <div class="area_map" id="grass <?php echo $k+$st_x/2; ?>" style='cursor:pointer; width:118px; heigh...

database - a nested query question in mysql -

i'm trying learn nested queries in mysql , i'm stuck while selecting hotels 30 miles away city , have rooms cost 150$ i can chose rooms 30 miles away city , costs 150 query,but can't reach hotels. (select id rooms cost = 150 , id in (select r_id has_rooms name in (select name is_at l_town in (select town location distance_from_city = 30)))); rooms +----+------+---------+ | id | cost | type | +----+------+---------+ | 1 | 100 | kral | | 2 | 0 | kralice | | 3 | 150 | padisah | | 4 | 150 | hop | | 5 | 150 | boss | +----+------+---------+ has_rooms +------+------+ | r_id | name | +------+------+ | 1 | | | 2 | b | | 3 | c | | 4 | | | 3 | | +------+------+ is_at +------+----------+ | name | l_town | +------+----------+ | | istanbul | | b | izmir | | c | kars | | d | adana | +------+----------+ select * location; +--------------------+----------+----------------+----------+ | distan...

jQuery - Click event on div but not on checkbox in the div -

i'm trying setup click event on div, , event fire if div clicked anywhere except checkbox in div. if checkbox clicked, not want div's click event fire. setup click event on checkbox , returned false, stops div's click event, not allow checkbox become checked either. here's have now: $('.thediv').click(function() { // click event div, i'm slide toggling $('.sub-div', $(this)).slidetoggle(); }); $('.checkboxinthediv').click(function() { // stuff checkbox click, dont fire event above return false; // returning false won't check/uncheck box when clicked }) instead of returning false, prevents default action, try stopping propagation. $('.checkboxinthediv').click( function(e) { e.stoppropagation(); ... other stuff... return true; });

javascript - how to disable whole body other than a div -

i have div creating through ajax, disable whole body once div popup , until, unless div closed. is possible in jquery. please let me know suggestion thanks, praveen jayapal you want remove, or hide body? technically shouldn't possible because need append div body in order see it. create 'mask' layer covers whole body, use z-index div display on top of body. something like: http://www.queness.com/post/77/simple-jquery-modal-window-tutorial might help! to hide page need change line 21: $('#mask').fadeto("slow",0.8); in javascript to: $('#mask').fadeto("slow",1); and color of mask on line 7 of css can changed whatever want too: background-color: #000;

database - GWT and notifyAll() (java.lang.Object) -

i'm making call database. result must used subit form. want wait until result db comes. need synchronization. idea use object.notifyall() java.lang, gwt doesn't support this. there equivalent method in gwt notifyall()? edit1 : i'm using gxt formpanel submit data. can change type of buttonbar, think, addsubmitcompletehandler not solve problem. here code snippet: final button submit = new button("submit"); submit.addlistener(events.onclick, new listener<buttonevent>() { @override public void handleevent(buttonevent be) { // 1. data database (here must wait response db) // 2. submit form } ); final formpanel buttonbar = new formpanel(); buttonbar.addstylename("abuploadfield"); buttonbar.setheadervisible(false); buttonbar.setborders(false); buttonbar.setstyleattribute("margin", "0px"); buttonbar.setencoding(formpanel.encoding.multipart); buttonbar.setmethod(formpanel.method.post)...

java - How to load program resources in Clojure -

how load program resources such icons, strings, graphical elements, scripts, , on in clojure program? using project layout similar in many java projects there "resources" directory hanging off of "source" directory. jar file created source , includes resources, can't seem resources loaded in java. the first thing tried like (classloader/getsystemresource "resources/myscript.js") but never find resource. you can similar with ... (let [cls (.getclass net.mydomain.somenamespace) strm (.getresourceasstream cls name) ] ... where name name of resource load, stream nil . you can try using context class loader like ... (let [thr (thread/currentthread) ldr (.getcontextclassloader thr) strem (.getresourceasstream ldr name)] ... but strem nil. in frustration, i've tried placing resource files in every directory in program. copied jar correctly, still can't seem load them. i've looked @ language...

is the command "java" the JVM? -

whenever run .class file in jvm. mean command "java" in terminal. or can click on open it? a java file compiled class file, bunch of java bytecode. jvm thing can execute java bytecode. java command line tool part of java runtime environment (jre) knows how start java virtual machine, load , execute class file.

iphone - handling events before back button is clicked -

is there way find out whether button (navigation bar) clicked particular view ? if yes how ? first of all, didn't try myself. don't know of way intercept click on button. "might" work following: there uinavigationbardelegate , contains navigationbar:shouldpopitem: event. event called before navigationitem removed stack of navigationbar, if handle event, might able whatever want archive.

ruby on rails - How to create association for nested model in a form -

in ruby on rails application want allow adding/editing of nested model has associated model. model survey string title has_many questions model question string question belongs_to category model category string name for sake of argument let's assume user should have enter new category when entering question (i couldn't come better example, sigh). in model/survey/edit.html.erb have working setup adding questions , saving them. when added category model picture, face problem when adding new question , there no corresponding category name-field displayed. suspect because though call question.new, not call question.category.build - , have no idea where/how that. my edit.html.erb: <h1>editing survey</h1> <%= render :partial => 'form' %> my _form.html.erb: <% form_for(@survey) |f| %> <%= f.error_messages %> <p> <%= f.label :title %><br /> <%= f.text_field :title %> ...

ajax - Jquery library/plugin for interactive modal popup? -

wondering if there's jquery library/plugin can perform following. at main page susan liew (click here update user profile) when click, trigger lightbox type 2.0 style modal popup show user profile modification form. this should ajax, jeffrey's user profile primary key pass modal popup (for complete user details retrieval via database). after editing.... click save auto close , doesn't refresh whole main page, refresh portion susan liew (click here update user profile) to susan li (click here update user profile) at same time, when modal popup, want make sure user not able interact or press in main page. how can that? i have seen http://www.no-margin-for-errors.com/projects/prettypopin/ http://www.no-margin-for-errors.com/demos/prettypopin/ajax/form.html but seem lack of ability pass pass in keys modal popup, , return value required main page after update done. i recommend jquery ui modal . you might want read post: what’s favorit...

jsp - RequestDispatcher.forward() vs HttpServletResponse.sendRedirect() -

what conceptual difference between forward() , sendredirect() ? requestdispatcher - forward() method when use forward method, request transfer other resource within same server further processing. in case of forward, web container handle process internally , client or browser not involved. when forward called on requestdispatcher object pass request , response objects our old request object present on new resource going process our request. visually not able see forwarded address, transparent. using forward () method faster send redirect. when redirect using forward , want use same data in new resource can use request.setattribute () have request object available. sendredirect in case of sendredirect, request transfer resource different domain or different server further processing. when use sendredirect, container transfers request client or browser url given inside sendredirect method visible new request client. in c...

continous integration with just Visual Studio 2005 -

any hints on how start ci vs2005 without tfs? will hudson able build vs2005? yes, hudson , cruisecontrol.net can both (as else can run, say, nant ). using nant, write script builds project. can have nant call msbuild (via nantcontrib think) , works quite beautifully.

jwplayer - JW Player problems -

havin problems jw player on here ferrazzilimoct dot com pause button doesnt seem work, , player doesnt work in browsers either, here code: <script type='text/javascript' src='http://ferrazzilimoct.com/wp-content/uploads/2010/01/swfobject.js'></script> <div id='mediaspace'>this text replaced if video works</div> <script type='text/javascript'> var = new swfobject('http://ferrazzilimoct.com/wp-content/uploads/2010/01/player.swf','mpl','498','380','9'); so.addparam('allowfullscreen','true'); so.addparam('allowscriptaccess','always'); so.addparam('wmode','opaque'); so.addvariable('file','http://ferrazzilimoct.com/wp-content/uploads/2010/01/ferrazzi_v021.swf'); so.write('mediaspace'); </script> seems working now. still having issue?

How do I import .sql files into SQLite 3? -

i have .sql files have following content: #cat db.sql create table server(name varchar(50),ipaddress varchar(15),id init) create table client(name varchar(50),ipaddress varchar(15),id init) how import file sqlite these created automatically? from sqlite prompt: sqlite> .read db.sql or: cat db.sql | sqlite3 database.db also, sql invalid - need ; on end of statements: create table server(name varchar(50),ipaddress varchar(15),id init); create table client(name varchar(50),ipaddress varchar(15),id init);

css - How to set float for every element inside a div at once wihout specfiying float for every element inside? -

how set float right every element inside div? i want give float inside elements not parent div? <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>sandbox</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <style type="text/css" media="screen"> body { background-color: #000; font: 16px helvetica, arial; color: #fff; } div {border:2px solid red;height:50px} {border:2px solid blue;margin:10px} </style> </head> <body> <div> <a>hello js bin</a> <a>from js bin</a> </div> </body> </html> you can target children of element using * selector, in example, add: div * { float: right; } note float c...

Determining the size of an Android view at runtime -

i trying apply animation view in android app after activity created. this, need determine current size of view, , set animation scale current size new size. part must done @ runtime, since view scales different sizes depending on input user. layout defined in xml. this seems easy task, , there lots of questions regarding though none solved problem, obviously. perhaps missing obvious. handle view by: imageview myview = (imageview)getwindow().findviewbyid(r.id.myviewid); this works fine, when calling getwidth() , getheight() , getmeasuredwidth() , getlayoutparams().width , etc., return 0. have tried manually calling measure() on view followed call getmeasuredwidth() , has no effect. i have tried calling these methods , inspecting object in debugger in activity's oncreate() , in onpostcreate() . how can figure out exact dimensions of view @ runtime? use viewtreeobserver on view wait first layout. after first layout getwidth()/getheight()/getmeasuredwidth(...

image processing - Calculating the center of rotation after translation -

i need able rotate image around given point ever part of image appears in center of container center of rotation. to calculate center points, taking inverse of translation applied image: rotate.centerx = translate.x * -1; rotate.centery = translate.y * -1; however, current calculation i'm using not sufficient not work if image has been translated after being rotated. i'm sure it's reasonably straight forward trig function, can't think is! cheers if working gdi+ use following: double imwidth = (double)im.width; double imheight = (double)im.height; double xtrans = -(imwidth * x); double ytrans = -(imheight * y); g.translatetransform((float)xtrans, (float)ytrans); g.translatetransform((float)(imwidth / 2.0 - xtrans), (float)(imheight / 2.0 - ytrans)); g.rotatetransform((float)angle); g.translatetransform(-((float)(imwidth / 2.0 - xtrans)), -((float)(imheight / 2.0 - ytrans))); if working wpf graphic objects, use following transform group: ...

android - Activity not started, its current task has been brought to the front -

i have simple android project. got following error message when try run it. emulator running application doesn't come up. couldn't find useful information online. can me? warning: activity not started, current task has been brought front public class profile extends activity { /*button button1; checkbox check1, check2; edittext text1;*/ /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); } } <edittext android:text="@+id/edittext01" android:id="@+id/edittext01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:enabled="false"></ edittext><checkbox android:text="@+id/checkbox03" android:id="@+id/ checkbox03" android:layout_width="fill_parent" android:layou...

python - What is the true difference between a dictionary and a hash table? -

i've used dictionaries. write in python. a dictionary general concept maps keys values. there many ways implement such mapping. a hashtable specific way implement dictionary. besides hashtables, common way implement dictionaries red-black trees . each method has it's own pros , cons. red-black tree can perform lookup in o(log n). hashtable can perform lookup in o(1) time although can degrade o(n) depending on input.

How to find out which JavaScript events fired? -

i have select list: <select id="filter"> <option value="open" selected="selected">open</option> <option value="closed">closed</option> </select> when select closed page reloads. in case shows closed tickets (instead of opened). works fine when manually. the problem page not reload when select closed watir : browser.select_list(:id => "filter").select "closed" that means javascript event not fired. can fire events watir: browser.select_list(:id => "filter").fire_event "onclick" but need know event fire. is there way find out events defined element? looks firebug (firefox add-on) has answer: open firebug right click element in html tab click log events enable console tab click persist in console tab (otherwise console tab clear after page reloaded) select closed (manually) there in console tab: ... mousemove clientx=1097...

cocoa - How to implement key equivalent for NSSearchField -

i have cocoa application building contains nssearchfield control. want enable keyboard shortcut / key equivalent when uses presses command-option-f, search field gets focus. however, after searching, not clear me best way implement is. there not option set nssearchfield in interface builder. is solution subclass nssearchfield , listen keydown event (and see if key equivalent pressed?) you can add menu item key equivalent of ⌘ ⌥ f i.e. command option f . in menu's action, manually make search field first responder using [window makefirstresponder:searchfield];

Sharepoint - create blank page with only webpart -

a client has asked create series of filters on list, heavily customised output. output correct i'll need style content query webpart using xsl - fine, that's pretty simple. however, main problem how apply multiple filters webpart. don't know how have 1 webpart insert parameters content query webpart, solution use ajax load seperate pages (containing webparts) page. so... unless crazy , bad idea, how can create .asp page has absolutely nothing except single webpart can preconfigure , hard code .asp page? i'm not .asp man, in fact i'm doing favour, please don't respond saying need xyz in sharepoint designer (to don't have access) or build custom module scratch. :) any ideas? since specific not wanting sharepoint designer solution, give 1 using 'tommy' in 'tommy': file => new => aspx page insert => sharepoint controls => webpartzone go in browser, http://server/mycustompage.aspx edit, insert webpart. ...

protocols - How do torrents work? -

can explain me or find me article online, explaining in technical details how torrents work, technology used in creating? project sites place start: http://www.bittorrent.com/

c# - .NET Application Cache vs Database Cache -

im building image gallery reads file disk, create thumbnails on fly , present them user. works good, except processing takes bit time. i decided cache processed images using asp .net application cache. when image processed add byte[] stream cache. far know beeing saved system memory. , working perfect, loading of page faster. my question if there thousands of images gets cached in application cache, affect server performance in way? are there other, better ways image caching? by default application cache stores data on server memory; depending on website navigation pattern, maybe don't many cache hits. you preprocess images generate thumbnails @ once , store original image. way don't need deal cache layer and, probably, won't take more disk space.

asp.net - Generate a normal distribution graph using C# -

i need generate gaussian graph (bell curve) using given average , standard deviation. how can completed in c#? if can completed in classic asp - better :) i manually generate values using forumulas this page use google charts render on client. work in c# or classic asp.

sql server - OLE Error in SQL -

i have windows server 2003 standard x64 edition sp2 microsoft sql server 2005 - 9.00.4035.00 (x64) enterprise edition (64-bit) on windows nt 5.2 (build 3790: service pack 2) i downloaded capicom platform sdk redistributable: http://www.microsoft.com/downloads/details.aspx?familyid=860ee43a-a843-462f-abb5-ff88ea5896f6&displaylang=en and installed c:\windows\syswow64 c:\windows\syswow64\regsvr32.exe capicom.dll , got registered succesfully. when tried run declare @s varchar(255) declare @d varchar(255) declare @o int exec @c = sp_oacreate 'capicom.encrypteddata', @o out if @c <> 0 begin exec sp_oageterrorinfo @o, @s out, @d out select err=convert(varbinary(4),@c), source=@s, description=@d return end and got error message. 0x80040154 odsole extended procedure class not registered what should do? how should check if capicom.dll correctly registered? this answer has walkthrough of how register surrogate capicom can used 64-bit ...

java - Group by month with criteria in Hibernate -

i'm trying report using criteria , projectionlist, , i'm pretty new using through hibernate. have model: private long _userid; private category _category; private long _companyid; private double _amount; private date _date; and building query using this: public list sumpaymentsbyusercategoryperiod(category category, long userid,integer period){ gregoriancalendar = new gregoriancalendar(); from.add(calendar.month, -period); list<categoryamount> resultdto= new arraylist<categoryamount>(); criteria criteria = getsession().createcriteria(payment.class); criteria.add(restrictions.eq("_category", category)); criteria.add(restrictions.eq("_userid",userid)); criteria.add(restrictions.between("_date", from.gettime(), new date())); projectionlist projectionlist = projections.projectionlist(); projectionlist.add(projections.sum("_amount")); projectionlist.add(projections.groupproperty("_dat...

Shift/reduce conflict with C-like grammar under Bison -

i've been working on c-like grammar personal amusement. however, i've been running shift/reduce conflicts, , i'm quite sure resolved. right expressions this, in simplified form, stripped of actions: %left '+' '-' %% expr : number | identifier | expr '+' expr | expr '-' expr /* other operators '*', '/', etc. */ | expr '(' expr ')' /* function call */ %% however, results in shift/reduce conflicts: parser unsure how treat parentheses. -v tells me, unclear whether expression expr '+' expr '(' should reduce expr '+' expr expr or shift parenthesis. obviously, want parenthesis shifted. foo % bar(4) shouldn't end being (foo % bar)(4) . however, i've had no success using %prec directive mean. adding %left funcall , %prec funcall after rule yields no change. i know default path bison's lalr parsers go when encountering shift/reduce shift, , use %expect fi...

ASP.NET/URL Rewriting in a development environment -

this general question dealing url rewriting in development environment. i'm developing cms learn asp.net/c#, , of course need implement url rewriting. technique known me since i've been using php several years. in php, can have local http server, modify php content directly, refresh page , see results. of course in asp.net it's not same, since need compile , publish code. the problem have need check url rewriting-friendly links code generate in development environment - basically, make asp.net development server compatible url rewrite. or maybe not. my question is: best solution that? use iis/apache2 (w/ mono) development server? if you're developing i'll make guess you're doing on windows. amount of hosts out there mono , linux/apache slim it's best use iis way of doing things. for iis vista/windows 7 have number of choices one url rewrite of many http module asp.net - works if want rewritting on asp.net pages. can infact map other f...

xml - adding select-attribute using the "attribute"-tag in xslt not working -

how come not work: <xsl:with-param name="message"> <xsl:attribute name="select"> <xsl:text>'alla koder kopplade till den e-post-adressen är nu skickade till dig!'</xsl:text> </xsl:attribute> </xsl:with-param> you need: <xsl:with-param name="message" select="'&apos;alla koder kopplade till den e-post-adressen är nu skickade till dig!&apos;'"/> whenever declare param or variable without select attribute , content template, variable or parameter of type result tree fragment. whenever output attribute node, it's error if don't output before other node type of element's content template. error recovery mechanism silently output nothing. in xslt 2.0 error rised. note : i'm ussing &apos; entity because have wrapped text ' , otherwise it's no needed.

Replacement for "TypeDescriptor" class (since it's not implemented on Windows Phone 7)? -

i have simple function wrote million years tries convert string type. works great values types, numbers, enums, datetimes etc use time when parsing xml file values, web request results - whatever. however code won't work on windows phone 7 because "typedescriptor" object not implemented (see pc code sample below). recommendations on how can implement simple string -> type converter on phone? here's existing code (written non-phones): internal t changetype<t>(object o) { type typeoft = typeof(t); // null if (o == null) { return default(t); } // types same if (typeoft == o.gettype()) { return (t)o; } // these different type - try see // if there's built in convertor // note: "typedescriptor" not implemented on windows phone 7 typeconverter convertor = typedescriptor.getconverter(typeoft); i...

mailing list - PHP: adding a timer -

i'm creating mailing list application. send 40 emails per hour due restrictions of mailing service. how can add timer? if need create scheduled task, suggest creating cron job .

.net - C# Exception when remotely connection to SQL Server 2005 instance -

trying connect sql server 2005 instance remotely getting following exception: a network-related or instance-specific error occurred while establishing connection sql server. server not found or not accessible. verify instance name correct , sql server configured allow remote connections. (provider: sql network interfaces, error: 26 - error locating server/instance specified) have checked , server enabled accept remote connections. connection string i'm using in .net looks this: data source=serverip\instance;initial catalog=databasename;user id=username;password=password; any ideas? thank :) you might want try quick telnet tcp port 1433 of server see if can establish connection way. telnet remote_name_or_ip 1433 if can't, know it's @ network layer, , can start checking things windows firewall or other network pieces might in way. (you need access via udp port 1434.)

iphone - How to display Two tables on a UI view -

i use , display 2 tables on ui view. please let me know how this. code same appreciated. thanks, sandeep add 2 uitableviews view in ib , connect them 2 different outlets in file owner (or assign different tag properties). set delegate , data source them (may same view controller both). in delegate/data source methods following: -(nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section{ if (tableview == myfirsttable) // return value 1st table if (tableview == mysecondtable) // return value 2nd table return 0; } or if use tag approach: - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section{ switch(tableview.tag){ case firsttag: // return value 1st table case secondtag: // return value 2nd table } return 0; }

What is String pool in Java? -

this question has answer here: what java string pool , how “s” different new string(“s”)? [duplicate] 6 answers i confused stringpool in java. came across while reading string chapter in java. please me understand, in layman terms, stringpool does. this prints true (even though don't use equals method: correct way compare strings) string s = "a" + "bc"; string t = "ab" + "c"; system.out.println(s == t); when compiler optimizes string literals, sees both s , t have same value , need 1 string object. it's safe because string immutable in java. result, both s , t point same object , little memory saved. name 'string pool' comes idea defined string stored in 'pool' , before creating new string object compiler checks if such string defined.

c# - Programmatically change Windows power settings -

is possible change power-saving behaviour of laptop computer on lid close hibernate/standby/shutdown do nothing .net framework? edit: appear setting value standby , blocking standby application, lid close event can detected, i'm after. i found this question deals detecting lid close, boils down using standby event or writing driver. yes, can use wmi classes. take here introduction wmi note can use application.setsuspendstate , method allows suspend or hibernate. guess doesn't match needs... about lid, there seems a way detect if lid closed or not...

jquery - Accessing properties of html element inside javascript function using $(this) gives undefined -

i calling function test() on anchor tag this:- <a class="link" onclick="test();">hello</a> and trying access class of anchor inside function test():- function test() { alert($(this).attr("class")); } but alerts undefined . know calling onclick=test(this); instead , having following function works:- function test(obj) { alert($(obj).attr("class")); } but, wanted access properties of element (on function called) without passing this . able get / set properties of element (on function called). possible? how this? in scenario need make sure html element owns function wanna call upon click. u doing u using onclick attribute takes string parameter , oblivious of else. in order make html element owner of function need map onclick property completely own custom function. in javascript that element.onclick = dosomething; so our code <div id="element">click</div> <script> fun...

objective c - AppDelegate file missing in Xcode 3.1? -

i starting learn xcode , objective-c , reading 3 different books on topic currently. of these books refer file called "appdelegate" (my_first_projectappdelegate.m, my_first_projectappdelegate.h) said "created project" (i creating "cocoa application"). these files not present when create new project. seem not 1 having problem (see http://pragprog.com/titles/dscpq/errata ). is there more information appdelegate? current practice on how deal missing appdelegate? using xcode version 3.1.4 on mac osx leopard. appdelegate nothing more common nsobject class needed connections in mainmenu.xib. can recreate own: create class, name appdelegate open mainmenu.xib , add nsobject object object palette in object inspector's identity tab (the last one) set object's class appdelegate (you should autocomplete) ctrl+drag application object newly created appdelegate object , choose "delegate" opened panel.

javascript - Multiple file upload. cloneNode of input fields with IE -

i want form uploads files server want transparent user. have input tag outside form cloned form clonenode() [javascript] every time user changes value. name of input tag "files[]". mozilla firefox clones input correctly ie doesn't copy value , ie inputs inside form empty. how can copy input field correctly ie? a piece of code: in javascript function called when input.onchange: inputcopy = inputparent.childnodes[i].clonenode(true); document.getelementbyid('divfromform').appendchild(inputcopy); the html input tag: <input type="file" id="archivoanadir" name="files[]" onchange="anadir(this.value)"> the php request: foreach ($_files["files"]["name"] $key => $file) { $query = "..."; mysql_query($consulta) or die("..."); if (!is_uploaded_file( $_files["files"]["tmp_name"][$key] )) die("..."); if (!move_uploaded_file($_fil...

spring - Auto login after successful registration -

hey want make auto login after successful registration in spring meaning: have protected page requires login access them , want after registration skip login page , make auto login user can see protected page, got me ? using spring 3.0 , spring security 3.0.2 how ? this can done spring security in following manner(semi-psuedocode): import org.springframework.security.web.savedrequest.requestcache; import org.springframework.security.web.savedrequest.savedrequest; @controller public class signupcontroller { @autowired requestcache requestcache; @autowired protected authenticationmanager authenticationmanager; @requestmapping(value = "/account/signup/", method = requestmethod.post) public string createnewuser(@modelattribute("user") user user, bindingresult result, httpservletrequest request, httpservletresponse response) { //after creating user authenticateuserandsetsession(user, request); return ...

Javascript and bookmarks -

lets on page has long list of urls , want make sure have of them bookmarked. know have many of them in bookmarks list , avoid duplications as possible. with in mind, able grab of links , open new tabs not contained in bookmarks list. can of getting links, , comparing links, don't know how access bookmarks via javascript. i can in whatever pc/mac browser has workable solution. have ideas? you never able access user's bookmarks via javascript. in fact, severe security hole. javascript gets executed in socalled sandbox. means that, @ least in theorey, javascript never have access resources of client machine (in practice, sandboxes have bugs allow nasty things, different story).

tinymce only readable in jquery ui dialog -

hi i'm using tinymce in jquery ui dialog. readable why? how can fix it? thanks i solved it. have init of tinymce on dialog's textarea after open event of , destroy on beforeclose event.

flash - HTML : Make <object> a link -

i have html code got designer of form: <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="20"> <param name="movie" value="products.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#ffffff" /> <embed src="products.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash" type="application/x-shockwave-flash" width="100" height="20" bgcolor="#ffffff"></embed> </object> i want turn link, when click it go ./products.html can't figure out how. wrapped entire object <a href...></a> when click it, gives me warning g...

character encoding issue with mysql -

in lamp app, users cut , paste input web forms other applications ms word. all of webpages set, via content type tag, display in utf. php script saves data web form mysql table has character encoding set utf-8. there apostrophe character display correctly in html, in mysql tables, viewed linux command prompt, displays ’. if both html page , mysql table using same encoding, why rendering of character different? perhaps reason linux command prompt uses font not support character. windows' cmd default use font doesn't support either. relax though, data stored way wanted it.

asp.net - Self Tracking Entities vs POCO Entities -

we starting new web based product in planning expose our business logic through wcf services. using asp.net 4.0, c#, ef 4.0. in future want build iphone applications , wpf applications based on services. have been reading lot using poco vs self tracking entities (ste) , understand stes not work web scenario. can shed more light on issue? for me ste absolutely wrong concept. implementation of dataset. in asp.net application have store stes somewhere among requests. in first request query datasource ste , provide data in page. in next request (postback) want modify ste returned data browser. support tracking have use same ste in first request => have store ste in viewstate (if want use asp.net webforms) or session. ste useless soa or interoperability. tracking logic part of ste = running on client. if expose ste in service immediatelly expecting client side use same tracking features included in ste logic. these features not provided other side automatically. in .net ...

c - Comparison operation on unsigned and signed integers -

see code snippet int main() { unsigned int = 1000; int b = -1; if (a>b) printf("a big! %d\n", a-b); else printf("a small! %d\n", a-b); return 0; } this gives output: small: 1001 i don't understand what's happening here. how > operator work here? why "a" smaller "b"? if indeed smaller, why positive number (1001) difference? binary operations between different integral types performed within "common" type defined called usual arithmetic conversions (see language specification, 6.3.1.8). in case "common" type unsigned int . means int operand (your b ) converted unsigned int before comparison, purpose of performing subtraction. when -1 converted unsigned int result maximal possible unsigned int value (same uint_max ). needless say, going greater unsigned 1000 value, meaning a > b indeed false , a indeed small compared (unsigned) b . if in code should resolve else branch, ...

.net - How to Convert this generic method from C# to VB.Net -

i have following code block in c# private void synchronize<t>(textselection selection, dependencyproperty property, action<t> methodtocall) { object value = selection. getpropertyvalue(property) ; if ( value != dependencyproperty. unsetvalue) methodtocall((t) value) ; } that have converted vb. private sub synchronize(of t)(byval selection textselection, byval [property] dependencyproperty, byval methodtocall action(of t)) dim value object = selection.getpropertyvalue([property]) if value isnot dependencyproperty.unsetvalue methodtocall(directcast(value, t)) end if end sub the calling method like: synchronize(of double)(selection, textblock.fontsizeproperty, addressof setfontsize) synchronize(of fontweight)(selection, textblock.fontsizeproperty, addressof setfontweight) synchronize(of fontstyle)(selection, textblock.fontstyleproperty, addressof setfontstyle) synchronize(of fontfamily)(selection, textblock.fontfamilyproperty, addres...

Does there exist a tool for combining java files -

i joining competition requires me put java classes in 1 single .java file. there exist tool me (including changing visibility of classes able this)? addition : trying me read site of competition quote: it possible make more 1 class program, have put source classes in single .java file (the compiler produce multiple .class files anyway). when this, should not declare classes public, or compiler complain it. so, 1 .java file allowed (no jar) , in file can have multiple non-public classes besides public main class (and not static inner classes suggested). if have access unix-y shell (for windows, can install e.g. git decent bash implementation, and gives great vc tool): cat *.java | sed 's/public class/class/g' >alltehcodez.java doesn't have more complicated (unless have lot of strings containing substring "public class", of course). edit: doesn't work package , imports. but... ( egrep -h ^package *.java | head ...

sql server - Use like in T-SQl to search for words separated by an unknown number of spaces -

i have query: select * table column '%firstword[something]secondword[something]thirdword%' what replace [something] match unknown number of spaces? edited add: % not work matches character, not spaces. perhaps optimistically assuming "unknown number" includes zero. select * table replace(column_name,' ','') '%firstwordsecondwordthirdword%'

c# - Linq Error on Left outer join -

i have alert table has 1:many mapping devices. relationship conveyed ina mapping table. when try produce left outer join mapping table various asset type tables following error:system.security.verificationexception: operation destabilize runtime. var alertassets = (from in dc.msalert_assets b in dc.msrfids.where(x => x.accountid == a.accountid && x.rfid == a.tagnum && x.custnum == a.custnum).defaultifempty() c in dc.msdevices.where(x => x.accountid == a.accountid && x.deviceid == a.deviceid).defaultifempty() d in dc.msgroups.where(x => x.accountid == a.accountid && x.groupid == a.groupid).defaultifempty() let x = grrepo.getassetsforgroupid(d.groupid, d.accountid) a.alertid == alertid select new {... specific objects} i thought may narrowing issue, enumarated i...

osx - Boost Libraries: Unable to link regex library on MAC OS X -

i'm trying use boost libraries ... no avail. attempted follow getting started tutorial on boost's website (for unix variants), having problems along way. i compiled libraries directory in downloads folder: /users/myusername/downloads/boostcompiled when use full path library ... example program (given on boost website) compiles , links fine. g++ -o boosttesting boosttesting.cpp -i /users/myusername/downloads/boostcompiled/include/ /users/myusername/downloads/boostcompiled/lib/libboost_regex.a however, when attempt link using -l , -l options ... fails ... g++ -o boosttesting boosttesting.cpp -i /users/myusername/downloads/boostcompiled/include/ -l /users/myusername/downloads/boostcompiled/lib/ -l boost_regex ld: library not found -lboost_regex collect2: ld returned 1 exit status g++ -o boosttesting boosttesting.cpp -i /users/myusername/downloads/boostcompiled/include/ -l /users/myusername/downloads/boostcompiled/lib/ -l libboost_regex ld: library not found -ll...

web crawler - How can I get MediaWiki to ignore page views from a Google Search Appliance? -

the page view counter on each mediawiki page seems great way identify popular pages worth putting more effort keeping up-to-date , useful, i've hit problem. we use google search appliance index our mediawiki installation. problem have gsa increments page view counter each time crawls page. dominates statistics, swamping views made real users. i know how reset page counters start again. there way configure mediawiki ignore page requests gsa purposes of counting page views? this can done adding condition in article.php: includes/article.php:2861:function viewupdates(): if( !$wgdisablecounters && !$wguser->isallowed('bot') && $this->getid() ) { add: && strpos($_server['http_user_agent'], 'gsa-crawler') === false where gsa-crawler part of default gsa ua... another way setup forms authentication in gsa, , have login wikimedia user in bot group..

End Call in Android -

i'm trying end new outgoing call after few seconds. here code: public class phonecalls extends activity { componentname cn; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); call(); } private void call() { try { intent callintent = new intent(intent.action_call); callintent.setdata(uri.parse("tel:123456789")); startactivity(callintent); cn = new componentname(getapplicationcontext(), receiver.class); } catch (activitynotfoundexception activityexception) { log.e("dialing-example", "call failed", activityexception); } } } my receiver class is: public class receiver extends broadcastreceiver { public void onreceive(context context, intent intent) { if (intent.getaction().equals(inte...

versioning - How do I tag files in a directory in a SVN repository with a global version number that will appear in the actual file? -

i working on project stores multiple versions in same svn repo in different directories. ease of reference coders working on project i'd able add commented tag # $revision: 144 $ however, instead of file revision should contain simple version number so: # $version: 1.63 $ # $version: 1.64 $ # $version: 2.0 $ is there way subversion automatically specific directory , sub-directories new files added those? stores multiple versions in same svn repo in different directories sounds suspiciously tagging described in svn documentation. can instead? svn automatically keep track of revision files came from, won't have embed in files themselves.

css - What's a cross-browser compatible way to right-align child divs and make the parent div get its width from the children? -

i have bunch of child <div> 's of variable width, want right-align within parent . want parent <div> no wider needs to contain children. (i don't know in advance how wide children -- they'll contain dynamically generated content.) here's example works correctly in ie 8.0 not in firefox 3.5 (child <div> 's aren't right-aligned): <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <style type="text/css"> #parentdiv{float:left; text-align:right; background-color: gray;} .childdiv{clear:both; border: 1px solid black; background-color: white;} </style> </head> <body> <div id="parentdiv"> <div class="childdiv" style="width: 25px">&nbsp;</div> <...

Visual Studio 2010 - C++ MFC application with Ribbon UI - Transparency in bitmaps -

Image
i playing around small mfc-wizard-generated application, in visual c++ 2010, , decided put own bitmap resources replace three-cubes mfc bitmap shows in ribbon ui application button, aka "marble". the original appeared use black (0,0,0) transparency color, unable determine mfc ribbon (mfc-feature-pack stuff) stuff in visual studio 2010 determine transparency on bitmap used ribbon's main icon. the properties of ribbon (idr_ribbon) show image=idb_main, , idb_main 32x32 bitmap in bmp format, loaded disk file called main.bmp. some of bitmap resources in project have looks expect: magenta color becomes transparent, mfc main bitmap did not use color scheme or palette. here example of actual results, hope show results not wanted: incidentally, not seem possible use icon resource in application button, little mystified how pull off transparency in it. translucent png, perhaps? did know bmp files can have alpha channels?

c# - linq sql - aggregate count -

i have linq returns correct data. var numemails = (from row in emailbatchproposal row.emailbatchid == emailbatchid select row.emailbatchproposalid).count(); however, if understand linq correctly, not perform optimally. grabs data , walks through list , counts rows. i'd linq (in background) use like: select count(*) ... i trust performance reasons obvious. does know proper way this? actually, if linq query used collection implements iqueryable , supports translation underlying sql variant, quite basic functionality translate count function example correctly.

java - Are there patterns for model / entity classes -

what best approach take when pulling model objects multiple datasources? for example have application has has data stored in mysql database using hibernate. if wanted store other objects in ec2 or google app engine? understand dao's abstract implementation of working particular data source, entities themselves? at first thought annotating entities jpa annotations great solution, seems i've tied entities down particular implementation. in case of app engine example, of these annotations make no sense. it seems need pure pojo class represent entities, entirely free of persistence logic. if wanted model dog example (yes lame choice, whatever). make sense have abstract dog class, define subclasses work particular persistence solutions: hibernatedog, gaedog, etc. thanks. this great question, if issue isn't new. industry, we've been changing "conventional wisdom" on subject on years. answers today aren't you'd 5 years ago or 5 y...

svn - How to restrict access to a staging environment -

our workflow has developers working on locally hosted copies of our web application svn source control. have post-commit hooks deploy each new revision designated staging environment running on subdomain. my question is, best way restrict access these staging sites can't stumbled across or god forbid indexed search engines? we'd avoid ip based, have remote developers working unavoidably dynamic ips. i have initial ideas such simple form can hit login credentials either a) give access cookie that's checked when running in staging environment, or b) register current ip address allowed determinate length of time. if can share ideas, previous experience or best practice appreciated if you're using apache simple , basic protection should .htaccess file . if doesn't satisfy needs security, should think implementing own security mechanism . the best solution put staging server in closed network , allow access via secure vpn .

seam - RestEasy and JSON - how to avoid quotes around a number? -

i using resteasy marchal entities json. works okay somehow every thing represented string. e.g. @xmlrootelement(name="testobject") public class testobject { private long value; public long getvalue(){ return value; } } instead of creating like: {testobject:{value:1234}} it creates {testobject:{value:"1234"}} (please note " " around number) so long value converted string. how can avoid that? i've asked on jackson forum resteasy using json marchaling said caused going java->xml->json. there doesn't seem resteasy forum , on seam forum no 1 answer question. does else have same problem? regards okay problem resteasy+seam uses jettison default (and not jackson). jettison marchaling via java->xml->json. the jackson jars aren't included in seam distribution have download resteasy , copy jars mention jackson lib directory. when resteasy finds resteasy-jackson-provider.jar in classpath, jacks...

c++ - Array to Hex Representation -

i writing program needs take array of size n , convert it's hex value follows: int a[] = { 0, 1, 1, 0 }; i take each value of array represent binary , convert hex value. in case: 0x6000000000000000; // 0110...0 it has packed right 0's 64 bits (i on 64 bit machine). or take array elements, convert decimal , convert hexadecimal that's easier... best way of doing in c++? (this not homework) the following assumes a[] ever use 0 , 1 represent bits. you'll need specify array length, sizeof(a)/sizeof(int) can used in case, not heap allocated arrays. also, result need 64bit integer type. for (int c=0; c<array_len; c++) result |= a[c] << (63-c); if want see looks in hex, can use (s)printf( "%i64x", result )

seo - Two identical URL's but different order in parameters: Duplicated content? -

my own cms automatically adds new parameters links in page specify given language. it works quite doesn't put var in same position, giving me link same page/language: www.xxx.yy/index.php?mod=blog&page=3& lang=en or www.xxx.yy/index.php?mod=blog& lang=en &page=3 will search engines smart enough detect both urls same? or detect 2 different urls , therefore mark them duplicated content? i fix issue anyway, i'm curious since long time ago. google supports this, explicitly mention example in webmaster blog : like www.example.com/skates.asp?color=black&brand=riedell , www.example.com/skates.asp?brand=riedell&color=black . having type of duplicate content on site can potentially affect site's performance, doesn't cause penalties. our article on duplicate content : duplicate content on site not grounds action on site unless appears intent of duplicate content deceptive , manipulate search engine results. if site...

C# WPF - ComboBox to also be a TextBox, for example: just like in office where users can choose Font Size or enter it -

i allow users choose font size combobox, them able enter size there own, tried out property: "iseditable" (and changed true value) of combobox, when enter isn't in combobox items (for example: items are- 2,3,4;and entered- 6), shows me following message: "object reference not set instance of object". next time post source code question. public partial class mainwindow : window { public class someitem { public int[] numbers { get; set; } public string chosentext { get; set; } } private someitem item; public mainwindow() { initializecomponent(); this.item = new someitem{numbers=new[]{7,8,10}, chosentext="10"}; this.teststackpanel.datacontext = item; } private void button_click(object sender, system.windows.routedeventargs e) { messagebox.show(item.chosentext); } } <st...