Posts

Showing posts from August, 2011

mysql - How to find difference between two values in one column by cross referencing against values in another column -

i have table looks this: id | machine | date | status ---------------------------- 1 | 1 | 01-01-2009 | new 1 | 1 | 01-01-2010 | busted 1 | 2 | 01-01-2010 | new 1 | 1 | 01-01-2012 | repaired i need know differences in date between each status per machine, if recent status , there no newer status machine, needs show difference between last date listed , current date: id | machine | date | status | duration --------------------------------------- 1 | 1 | 01-01-2009 | new | 1 year 1 | 1 | 01-01-2010 | busted | 2 years 1 | 2 | 01-01-2010 | new | 2 years, 2 months, 5 days 1 | 1 | 01-01-2012 | repaired | 2 months, 5 days to quite honest, don't care how new duration column displays distances between dates. attempted make query myself failed. this give values in days - select *, datediff(ifnull((select `date` machine_status ms2 ms1.machine = ms2.machine , ms1.`date` < ms2.`date` order `date` asc limit 1), current_date), ms1.`date`) machine_st

wpf - Measure Maximum Fontsize for a control -

lets have 5 textblocks on screen each same size. i have 5 items display (of varying length) 10 100 1111 99 9192 is there way wpf calculate largest fontsize usable textblocks text fit in it's respective textblock, fontsizes same? use viewbox <viewbox> <stackpanel> <textblock text="10"/> <textblock text="100"/> <textblock text="1111"/> </stackpanel> </viewbox> then inside viewbox scale fit size available viewbox, regardless of font size.

Waiting mouse cursor in my GWT application stays infinitely (only in Chrome, only in Production) -

Image
could please tell me why have waiting mouse cursor in gwt application if page not loaded ? doesn't happen on dev server. happens in production. it's happening in chrome doesn't in ie. link app here . screenshot i checked again in chrome, me no wait cursor displayed. think, google chrome trying open google translate menu. me came , page loading stopped , mouse @ normal position. i prefer try updating chrome. i have checked same in co-workers laptop , working fine too. if problem still persists, please use ccleaner software , clear temporary files, browser cache, recent files etc. why because, gwt creates lot of temporary files may reduce system performance. after each cleaning, restart system also. had few such resolutions recently.

javascript - Backbone.js fetch collection from it's initialize method -

someone building app us, provided me code go through it, , noticed this, @ first seems ok, , nice let collection manage data after while started thinking possible pitfalls in idea so: practice fetch collection's data it's own initialize method. for example: var book = backbone.model.extend({}); var books = backbone.collection.extend({ url: '/books', initialize: function(){ // logic here // if collection empty, fetch server if(this.size() == 0) this.fetch(); } }); i ask because feel might problem in following situation: suppose in routeaction: books: function() { var books = new books(); var booklist = new booklist({ collection: books }); } isn't situation possible failure, if fetch faster initialization of view, view have bound reset event, reset have triggered way before initialize of view had been executed? am wrong on this, or should submit ticket fixed. while in practice i

How to authenticate that user owns twitter account? -

i'm developing social network. users may register , share twitter username (if want). wherever user posts comment or other content, username displayed. display follow @usertwitter button, if user has set twitter account. now, works, problem validate user owner of twitter account. right user entering valid twitter account! maybe using twitter api? you can set app twitter client, way user has log twitter authorize app, thereby verifying twitter identity. this couple years old might enough started: http://www.1stwebdesigner.com/tutorials/twitter-app-oauth-php/

c++ - Where does Z_int come from? -

i've been browsing lot of perl c library extensions , have noticed, in date::calc, z_int , z_long , standard (vs 'int' , 'long'). i'm assuming posix standard google has failed me while trying find definition or source syntax. know comes from, or have reference this? thanks. it's not standard thing; think it's steffen beyer 's personal notation uses in number of modules (including date::calc ). z here math sense of z denote set of integers; z_int signed int , whereas n_int (from n , set of natural numbers) unsigned int . these typedef s defined in the header file toolbox.h in modules use them.

internationalization - Pass a lazy translation string including variable to function in Django -

inside django view, create subject that: subject = _(u"%(user)s has posted comment") % { 'user': user } then pass subject function, handles email notifications: send_notifications(request, subject, url) in send_notifications, iterate on subscriptions , send emails. however, each user can have different language, activate user's language dynamically via django's activate: def send_notifications(request, subject, url): django.utils.translation import activate s in subscription.objects.filter(url=url): activate(s.user.userprofile.lang) send_mail(subject, render_to_string('notification_email.txt', locals()), settings.server_email, [s.user.email]) the template gets rendered in correct language of each user. however, subject passed evaluated , translated string send_notifications , thus, not translated. i played around lazy translations , lambda functions parameters, without success. appreciated :) instead o

javascript - Create a search box for my KMLlayer(s) -

i'm using google maps api v3 , displaying basic map 250 place markers kmz file. i'd add search box page allows users search specific item in kml. i'm pretty sure possible, not sure best way started... pointing me in right direction appreciated. thanks. as understand, kmz file zipped file containing .kml file , other related files. reading kml , extracting values trivial using jquery , can information how here. http://think2loud.com/224-reading-xml-with-jquery/ i've not done unzipping file in javascript, can check out stackoverflow question if want on client side. unzipping files alternately, can unzip kmz file on server, , let client code kml file using ajax (as shown in first link). hope helps.

sitecore - Get reviewer from workflow Item for email notification -

upon approve or reject execute custom email notification goes this: public void process(workflowpipelineargs args) { assert.argumentnotnull(args, "args"); processoritem processoritem = args.processoritem; if (processoritem != null) { //all variables initialized var site = sitecore.configuration.factory.getsite("website"); string contentpath = args.dataitem.paths.contentpath; var contentitem = args.dataitem; var contentworkflow = contentitem.database.workflowprovider.getworkflow(contentitem); var contenthistory = contentworkflow.gethistory(contentitem); var status = "approved"; //get item master database var workflowitem = sitecore.context.contentdatabase.items[args.dataitem.id]; //get workflow history can email last person in chain. if (contenthistory.length

php - Why does the count of an ADODB count result display differently on Virt. Dedic. Hosted site differently than other sites I've worked with? -

when not using symfony, use adodb querying databases. have of queries executed in file. each select statement accompanied select count statement , using binding parameters. make sure there count , if count zero, appropriate error message displayed. if there count greater zero, select statement performed. on hosting , other shared hosting sites, select count gives me value , use substr count, on client's virtual dedicated server w/plesk, weird happens. here example below: $selectcountsql = "select count(*) thistable email = ? , pwdhash = ?"; $selectcountquery = $db->execute($selectcountsql,array($email,$pwdmashed)); $count = substr($selectcountquery,10); on other clients' sites w/shared hosting, output of $count integer actual count of records. however, on client's site hosted on virtual dedicated hosting, when i: echo $selectcountquery variable, displays value count(*) 1 --e.g. if count of 1 record returned. echo $count variable, displays nothing.

xcode - Cocos2d how to scale a sprite without scaling layer? Or, How to scale and crop sprite/layer? -

ipad app setup: scenea contains layera - 1024x768. push button in layera, layerb drops down on top using ccmoveto action. layerb 800x600 can see layera behind (think of overlayed pause screen type effect). layerb contains 800x600 sprite user can zoom in on pressing button. zoom effect combination of ccscaleto , ccmoveto keep centered on part it's zooming in on. however, when sprite scales, layerb overtop of layera. there way scale sprite within contained window? layerb should use gl_scissor_test trim outside of itself. can google more information it, defines rect , uses glscissor on remove outside. have class extend when need this, goes follows: // // ccnodeclip.h // // created ignacio orlandoni on 7/29/11. // #import <foundation/foundation.h> #import "cocos2d.h" @interface ccnodeclip : cclayer { } -(void)previsit; -(void)postvisit; @end - // // ccnodeclip.m // // created ignacio orlandoni on 7/29/11. // #import "ccnodeclip.h"

ruby on rails - How do you fix? formtastic :label_method is no longer available -

ok.. i'm new ruby/rails. compensate weakness, company had guy come in me create bones of our website. put in formtastic :label_method, change fields displayed in ddlb. when moved project new box, got error. :label_method no longer available what i'm wondering is.. use in it's place? i think might be: :member_label according http://rubydoc.info/gems/formtastic/2.0.0/formtastic/helpers/inputhelper "(symbol, proc, method) — deprecated, renamed :member_label" if doesn't work post _form see?

date - MATLAB - datetick (specify number of points on axis) -

i use datetick('x','hh:mm:ss.fff'). how can specify how many labels (specially denotes points) on x-axis puts? datetick replaces labels of current tick marks formatted date/time strings. you control actual location of ticks using axes properties xtick, ytick, ztick: vector of data values locating tick marks set(gca,'xtick', [1 4 6]);%sets ticks @ x=1, x=4, x=6 gca "get current axes", change xtick locations on recent axes you've activated (created, clicked on, or else). if have axes handle set of axes, can use handle in place of "gca".

c++ - Explicit instantiation of operator>> overload -

i have class vector<t> , , using library provides class yaml::node . overload operator>> these 2 types. i have added following declaration vector 's declaration: friend void operator>>(yaml::node const & node, vector<t> & v); i have added following implementation of function: template<typename t> void operator>>(yaml::node const & node, vector<t> & v) { node[0] >> v.x; node[1] >> v.y; node[2] >> v.z; } finally, have added following (attempt at) explicitly instantiating template t = num_t : template void operator>>(yaml::node const & node, vector<num_t> & v); however, results in following linker error: error 9 error lnk2019: unresolved external symbol "void __cdecl operator>>(class yaml::node const &,class vector<double> &)" (??5@yaxaebvnode@yaml@@aeav?$vector@n@@@z) referenced in function "public: static class scene

regex - find specific string but not when present in certain sentence -

i not sure if possible 1 regex line. want find sentence particular string not when present in specific sentence. this grep 'word' file | grep -iv "particular sentence" eg: input: hello world foo here foobar here there foo bar bar foo now result should find word 'foo' not when sentence 'bar foo now': output: hello world foo here foobar here there foo bar is possible 1 line regex pattern? you do: ^(?!bar foo now).*?foo.*$ which says "match line isn't "bar foo now", has "foo" in it". however, you'll 1 match per line. if had: hello foo foo. that match, once entire line (as opposed twice, once each foo ).

java - What of these two multithrading layouts is better? -

i have multithread layout there manager object , lot of workers objects. i have doubt in layout better use: 1 - workers run in loop , ask "new job" manager after finished. or 2 - manager give new jobs workers after finish each job. are there recommendations this? this question have wrestled many times. each time have chosen specific situation coding for. should same. however, chose correctly must study 2 approaches carefully. consider test case. you have thousands of files process. 1. workers in control. the manager becomes queue of of files process. create fixed number of worker threads request next file manager , repeat until list exhausted. consequences you end having synchronize access queue. you can tinker number of workers attain maximal throughput hardware architecture. sometimes can dynamically adjust number of workers depending on current load can tricky. if successful can achieve exceptionally optimal sol

Android Listview displaying header when Overscrolled -

i need android listview display screen header displayed when user on scrolled. i tried using pulltorefreshlistview, but, have problem when number of rows less , height less list height. header view automatically displayed before pulling down. i achieved functionality in 2.2 android version using small line of below code. listview_object.setpadding(0,-height_of_the_header,0,0); this piece of code not working 2.3 , above overscroll locked in versions. even there method setoverscrollmethod(int) 2.3 , above, not working. can me resolve this... ? my requirement display screen coming top of listview when user overscrolled top bottom. maybe can use widget it not shows header when lines' height less listview's.

Why does Python's Decimal display some simple values as expontents and how can I prevent it? -

i understand value of exponents, typically when displaying decimal values end user, it's easier layman understand normal decimal values. when perform following, i'd rather display value of decimal 50 , instead of: >>> decimal('22679.6185') / decimal('28.349523125') / 16 decimal('5e+1') is possible without quantizing or doing modify actual value? also, why display short value exponent , longer values in normal decimal form? product of division (irony intended)? see: significant figures in decimal module (which admittedly tells use .quantize()). main problem must keep track of number of significant digits manually.

iphone - How to declare an instance of UIImageView as global? -

i want use single imageview in classes want declare global. can please tell me how declare global. you can create in appdelegate , use it appdelegate *localvar = [[uiapplication sharedapplication] delegate]; // ok localvar.imageview=[...];

java - export list value to pdf, xml, excel, text -

i need generate xml, excel, pdf, text file list retrieved database. have used itext-1.3.jar , have generated successfully. here want know means, there other api available itext, if yes means kindly suggest me . in advance. apache java api access microsoft excel format files can read/write microsoft excel 2003/2010 formats.

a python error- too many values -

i'm trying extract proper noun tagged file. problem the code i'm trying gives error : traceback (most recent call last): file "e:\pt\paragraph", line 35, in <module> sen1= noun(mylist[s]) file "e:\pt\paragraph", line 5, in noun word, tag = word.split('/') valueerror: many values unpack the code works fine texts gives error. the code: def noun(words): nouns = [] word in words.split(): word, tag = word.split('/') if (tag.lower() == 'np'): nouns.append(word); return nouns def splitparagraph(paragraph): import re paragraphs = paragraph.split('\n\n') return paragraphs if __name__ == '__main__': import nltk rp = open("t3.txt", 'r') text = rp.read() mylist = [] para = splitparagraph(text) s in para: mylist.append(s) s in range(len(mylist)-1): sen1= noun(mylist[s]) sen2= noun(mylist[s+1]) the i'm trying works if remove 1st paragraph other wise gives error. sample of text:

c# - Thread and object by reference -

i ask code thread safe? there problem attachment object. passed reference new thread mailhelper use , attachment object mixed between threads. public static void start() { foreach (var message in messages) { //skip code var filename = httpwebresponse.getresponseheader("filename"); var filestream = httpwebresponse.getresponsestream(); var attachment = new attachment(filestream, filename); var thread = new thread(() => { var dictionary = new listdictionary { { "$url$", message.url } }; mailhelper.sendmessage(dictionary, message.mail.headers.from.address, "emailconvertsuccess.txt", attachment) }); thread.start(); } } no not working - it's not attachment (see darins answer) message object use iterator - have copy local instance before calling th

c# - ASP.NET Repeater: Button in item template to redirect to another page -

i have repeater , each item contains button should redirect page , pass value in query string. i not getting errors, when click button, page refreshes (so assuming postback does occur) , not redirect. think reason, isn't recognizing commandname of button. repeater code: <asp:repeater id="mysponsoredchildrenlist" runat="server" onitemdatabound="mysponsoredchildrenlist_itemdatabound" onitemcommand="mysponsoredchildrenlist_itemcommand"> <headertemplate> </headertemplate> <itemtemplate> <br /> <div id="outerdiv"> <div id="innerleft"> <asp:image id="profilepic" runat="server" imageurl='<%#"~/resources/children images/" + string.format("{0}", eval("primary_image")) %>' width='300px' style="max-height: 500px" />&

multicore - If I have a process with only one thread running on a multi core why is it moved from one core to another -

why process having 1 core migrated 1 core another. assume process simple , has simple thread running. observed os moves 1 core when executing. why done? isn't there overhead continously moving process? why doesn't execute on 1 core , keep execting on same core forever? there many answers question, obvious 1 is: heat.

rendering a html.erb in rails with javascript -

i create page , parts of layout files rendered. want render 1 of these rendered part again javascript code. i want render these part again <div id="dialog" title="bookmark folders" style="resize: both;"> <%=render "layouts/filetree.html.erb"%> </div> it render function creates this: <div id="accordion"> <% @user.folders.each |f| %> <h3 id="<%= f.folder_name%>" class="folderbar"><a href="#" class="foldername"><b id="foldername"><%= f.folder_name%></b> created <%=distance_of_time_in_words(f.created_at, time.now)%> before</a></h3> <div class="<%= f.folder_name.delete(" ")%>"> <%if f.docs.empty?%> <b>-no document currently!-</b> <%else%> <% f.docs.each |r|%> <a href="<%=

html - Reduce loading time of heavy images in html5 -

i trying load heavy ong images in website. have tried use photoshop -> posterize method reduce file size of heavy pngs followed online tools reduce png file size without major compromizing filesize of image. have als tried pre-loading images, still taking considerable amount of time load. can please suggest me way reduce loading time of png images on website, they load quick? many in advance! even if follow all/some of the previous advice, nice addon workflow passing pngs through pngoptimizer . it's simple drag , drop program strips unnecessary information out of pngs. depending of type of image, size saving varies between 5-10% , more 70%.

database - mysql bulk delete -

i'm doing bulk delete in mysql , works when 100 records fails syntax error thing. my goal 10k records in every delete statement. i'm not sure if has memory settings mysql. if you're using sql editor, may need enable particular setting large deletes. example, in mysql workbench, it's this: set sql_safe_updates=0; -- delete statement goes here set sql_safe_updates=1;

.net - FileNotFOundException in System.Windows.Forms.Application.ExecutablePath -

running visual studio 2008 .net 2.0. debug menu, select exceptions , set break when clr exceptions thrown. then file new project, select new console application. i add following 2 lines inside of main. console.writeline(system.windows.forms.application.executablepath); console.readkey(); when execute code filenotfoundexception saying can't find \consoleapplication1\consoleapplication1\bin\debug\consoleapplication1.vshost.exe.config. i'm wondering both why happens , how prevent happening leave break on thrown clr exceptions setting on during testing sessions. thanks. edit: i'm aware of vshosting system , ok existence of files , for. don't want turn of hosting. i'm not sure why call application.executablepath looking config file. able around in 1 spot changing system.reflection call same value. got same error in on "new devexpress.xtraeditors.buttonedit()" call. the issue didn't not have app.config defined in project , had

java - Controlling thread using wait() and notify() -

(problem solved, solution below) have 2 classes: equip , command. equip equipment run commands, need able run 1 command @ same time. command thread, executes on run() function, while equip normal class don't extend anything. have following setup run commands: command class: @override public void run() { boolean execute = equip.queuecommand(this); if (!execute) { // if command 1 on queue, execute it, or wait. esperar(); } // executes command..... equip.executenextcommand(); } synchronized public void esperar() { try { this.wait(); } catch (exception ex) { log.logerro(ex); } } synchronized public void continue() { this.notifyall(); } equip class: public boolean queuecommand(command cmd) { // commandqueue linkedlist commandqueue.addlast(cmd); return (commandqueue.size() == 1); } public void executenextcommand() { if (commandqueue.size() >= 1) { command cmd = commandqueue.pol

android - Making AsyncTask Static (Having Issues, code provided) -

i need know how start asynctask in original activity service that activity starts. fetches music , plays in service , want grab next song after has completed right here: mediaplayer.setoncompletionlistener(new mediaplayer.oncompletionlistener() { public void oncompletion(mediaplayer mp) { if (mainmenu.radioflag == 1) { // start new asynctask } else { stopself(); } } }); down below asynctask, in radio.class. not know how make static references radio.this , getting errors on startservice(i) , stopservice(i). appreciate help, thanks. private class loadlist extends asynctask<string, userrecord, jsonarray> { string result = null; inputstream = null; stringbuilder sb = null; jsonarray jarray; @override protected void oncancelled() { toast toast = toast.maketext(getapplicationcontext(), "loading failed, tr

Advice on Debugging Machine-Specific Excel VBA Issue -

i have excel workbook dependencies on code in other other excel workbooks (these dependent .xls's vb-level references, i.e. via tools->references dialog box in vba editor), , dependencies on dll's such as: microsoft scripting runtime microsoft forms 2.0 object library this sheet has worked 2 years on around 20 machines running windows xp , office xp. have taken delivery of 3 new machines (same os, same office version) refuse run sheet. when sheet opens, throws 'compile error', , session hangs. if open sheet on 'bad' machine, hold down left shift key stop macro's running, , go vba editor->debug->complie vbaproject, compiles fine. able save sheet , open on 'bad' machine. new version of sheet refuses run on 'good' machine!! i think there must sort of version mismatch between dll's on 'good' , 'bad' machines. how establish causing issue? there tools available comparing versions of com components? t

html - Display an image to be a certain size in PHP -

i have number of different image urls in database, of varying dimensions. when display web page in php, how can display image , have fixed dimensions? using both fixed height , width stretch image. use 1 height or width in img tag or use css height or width zoom image fixed dimension. 1.) use either height or width in img tag in html 2.) use css either height or 3.) resize image proportionately using image resize in php. image resize can use 3rd party class. eg. suggested above.

javascript - Google-Maps error in IE7-IE8 in main.js -

on website ( http://goo.gl/j4ejn ), i'm building google maps block, , ajax-calls render route on google maps. each route use ajax-call (with jquery) , maps contain 20 routes. works perfect in ff, chrome, ie9. since few days, receive complaints routes not working in ie7 , ie8. the routes did work before, tested on ie7, ie8 , ie9 javascript error: script16389: unspecified error, main.js, line 37 character 2399. main.js referes http://maps.gstatic.com/intl/nl_nl/mapfiles/api-3/8/2/main.js . the jquery class wrote contains try {..} catch(err){} syntax in every function when error ocure in class, trigger it. all ajax-calls executed in ie7 , ie8. tried set async-property of jquery true. after changing property, discovered randomness of error. happens, doesn't.. anoyone got idea problem be? thx in advance.

iPhone: Handle action event from webview page -

i loading html page using loadhtmlstring. [mywebview loadhtmlstring:myhtmlstr baseurl:nil]; its loading properly. in html web page, i'm adding buttons, drop down(with selection) etc. want catch action events in code these web page controls. example, drop down if user chooses option, need add 'textarea' dynamically in same web page. and, if user clicks on button(button webview), need handle events. know, how tasks under events triggered controls in web view generated string. could please advise me. the documentation states uiwebview not intended sub-classing. however, can still detect events. maybe : tutorial

c# - Exception to ComboBox -

i looking way remove physical disk 0 when aquisition of list of device on computer. the command executed follows: managementobjectsearcher mosdisks = new managementobjectsearcher("select * win32_diskdrive"); foreach (managementobject modisk in mosdisks.get()) { drivelist.items.add(modisk["model"].tostring()); } thank help. managementobjectsearcher mosdisks = new managementobjectsearcher("select * win32_diskdrive"); foreach (managementobject modisk in mosdisks.get()) { if(!modisk["deviceid"].tostring().contains("physicaldrive0")) { drivelist.items.add(modisk["model"].tostring()); } } or more simply, change wql this: select * win32_diskdrive not name '%physicaldrive0'

write php inside javascript alert -

i write php inside js in following way alert(<?php echo __("error-login") ?>); echo__("error-login") correlates xml translate in 2 languages ​​with symfony, not work. how fix this? you missing quotes in alert() call. alert('<?php echo __("error-login") ?>');

php - How to place zend framework application in a wordpress website -

recently created application (sales portal) in php small company. company had website developed in word press. since hadn't worked word press way embedded application in website created sub directory on host , uploaded application there. e.g: domainname.com - website domainname.com/portal - application placed (the 'index.php' file). since month learning zend framework 1.8 , want rewrite portal in zend framework since wrote portal scratch , core not secure if implements zend framework. my question can include zend framework application wordpress website way did 'from-scratch' application, creating sub directory on host , upload application there? , if yes how should configure zend application recognizes 'domainname.com/portal' domain name (as home directory). the problem face right when type http://www.domainname.com/portal/sales returns 404 because there not such directory on server. of course mean above mentioned link (domainname.com/portal/s

Creating a GWT Tree dynamically from database -

i want create hierarchical tree of items using gwt. data generating tree hierarchy stored in database. in database each item holds parent’s id build hierarchical relationship. tried gwt tree. not having idea dynamically generate tree structure using database data. please advise me if have idea.

php - Getting Data from 2 different MySQL tables -

i'm working on project involved getting information 2 different servers. plan on doing having user enter or username password , have php script fill in rest of fields below first name last name etc. did searching , found of data have on 2 different tables within server. below coding have far. <?php $connect = mysql_connect("localhost","**************","**********") or die ("couldn't connect"); //host,username,password mysql_select_db("*******") or die ("could not find database"); $query = mysql_query("select * jos_users username='$username'"); ?> <html> <form action="populate.php" method='post'> <table> <tr> <td>vae&nbsp;username:</td> <td><input type='text' name='username' value=''></td> </tr> <tr>

c - what is wrong with the following code -

the following function gets file offsets rabin_polynomial structure, opens input_file md5 fingerprint generation , writes result fpfile my problem seems use same chunk_buffer content times generates similar fingerprints chunks different legths. what reason? i have tested md5 function other inputs separately , generates correct digests. int write_rabin_fingerprints_to_binary_file(file *fpfile,file *input_file, struct rabin_polynomial *head) { struct rabin_polynomial *poly=head; unsigned char fing_print[33]={'\0'}; size_t bytes_read; while(poly != null) { char *chunk_buffer; chunk_buffer = (char*) malloc ((poly->length)); bytes_read=fread (chunk_buffer,1, poly->length,input_file); if(bytes_read!=poly->length) { printf("error reading from%s ",input_file); return -1; } strncpy((cha

javascript - Add new input and use this without modify HTML -

i have only: <div> <textarea id="names"></textarea> </div> i can't modify html. can use jquery. possible make like: <input type="checkbox" id="yes"> <div style="display:none"> <textarea id="names"></textarea> </div> $("#yes").click(function(){ $("#names").parent().show(); }) default if page loaded , ready should only: <input type="checkbox" id="yes"> if checked show me div textarea. is possible make without modify html? if yes, how? fiddle: http://jsfiddle.net/2zmqz/ var checkbox = $('<input type="checkbox">'); var parent = $('#names').parent().hide().before(checkbox); checkbox.click(function() { parent.toggle(); }); ​ http://jsfiddle.net/2zmqz/14/

wcf - can't test my silverlight asp.net web site project -

when try start i've got error http://localhost:xxxx/gadgetmainstart.web/gadgetmainstarttestpage.aspx the webpage @ (website) might temporarily down or may have moved permanently new web address. i've got same problem when try start silverlight project. besides when want add service reference(wcf service in same project) i've got error error occurred while attempting find services @ http://localhost:xxxx/gadgetmainstart.web/weatherservice.svc how solve problems? ideas?

java - JPA/Hibernate Query failure related to entity variable name -

i'm new jpa , i've spent last 4 days trying figure out why *&^!@ queries keep blowing up. after ado seems problem somehow related name of variable i'm using. see entities , test class below. apologies enormopost i've tried simplify as possible. @entity public class myentity { @id @generatedvalue(strategy = generationtype.sequence) private long id; @column(length = 50) private string name; @manytoone private myentity myentity; @onetomany(cascade = cascadetype.all, mappedby = "myent", fetch = fetchtype.eager) @mapkey(name = "typename") private map<string, containedentity> ecconfigs; public myentity() { } public myentity(string name, myentity myentity) { this.name = name; this.myentity = myentity; } public myentity(string name) { this.name = name; } public string getname() { return name; } public void setname(string name) { this.name = name; } public long getid() { return id; } public void setid(long id)

How to change the color of a button in Dundas Dashboard v 2.5 on Click -

how can change color of button in dundas dashboard v 2.5 on click. know have on click interaction , have assign fill property. how using linear gradient brush. thanks suggestions in advance! there 2 ways linear gradient brush can set fill property to. 1) if need dynamic, build brush ground using script. instance: dashboardlineargradientbrush b = new dashboardlineargradientbrush(); b.startpoint = new point (0,0); b.endpoint = new point(0,1); dashboardgradientstop stop = new dashboardgradientstop(colors.black, 0); b.gradientstops.add(stop); stop = new dashboardgradientstop(colors.white, 1.0); b.gradientstops.add(stop); button1.fill = b; 2) if you're switching between predefined colors, create rectangle shape outside dashboard canvas , set brush on rectangle. then, when want switch color, can in on click interaction: button1.fill = rectangle1.fill;

javascript - Click event listener on a <tr> -

i have event listens click on img switches img another, img can real small , wanted make entire tr click able. suggestions? $('#example tbody td img').live('click', function () { var ntr = $(this).parents('tr')[0]; if ( otable.fnisopen(ntr) ) { /* row open - close */ this.src = "images/details_open.png"; otable.fnclose( ntr ); } else { /* open row */ this.src = "images/details_close.png"; otable.fnopen( ntr, fnformatdetails(otable, ntr), 'details' ); } } ); update tried using img won't change. how select img use (this) or make var it? $('#example tbody td').on('click', function (e) { var myimage = $(this).find("img"); var ntr = $(this).par

Node.js,Socket.io,Http-Proxy,Cluster,Express - Handshake drops on disconnect - delay in reconnect -

i'm using node.js , socket.io. i'm using http-proxy use port 80 on machine that's running apache also. apache on different ip. works great. i added in cluster , things got funky. spawns 2 workers (dual core vm) expected. connection on client side, off. it's good, if disconnect, there's delay reconnecting (there wasn't without cluster). here's code have.. ideas why there's delay between disconnect , connect using cluster? var http = require('http'), httpproxy = require('http-proxy'), io = require('socket.io'), cluster = require('cluster'), express = require('express'), redisstore = require('connect-redis')(express); var numcpus = require('os').cpus().length; if (cluster.ismaster) { //fork workers. (var = 0; < numcpus; i++) { cluster.fork(); } cluster.on('death', function(worker)

javascript - Pack and unpack complex object architecture with JSON -

i've been looking html 5's new local storage , seems pretty cool far. i've decided use json serialize objects strings , parse them objects, sounds nice. however, it's easier said done. i've discovered can't json.stringify() object , expect pack nicely you, can't figure out have instead. that's not all, though: object contains 2 arrays, each of holds type of object , 1 of multidimensional. here's rather complex , inter-dependent object architecture looks like: function vector2(x, y) { this.x = x; this.y = y; } function bar(id, position) { this.id = id; this.position = position; } function goo(state, position) { this.on = state; this.position = position; } function foo(name, size) { this.name = name; this.size = size; this.bars = new array(width) this.goos = new array(10); this.initialize(); } foo.prototype.initialize() { for(var x = 0;x<this.size.x;x++) { this.bars[x] = new a

python - Import json file to Django model -

i have file in json format, such structure: { "admiralty islands": [ [ "up 1 kg", "5.00" ], [ "1 - 10 kg", "10.00" ], ], "afghanistan": [ [ "up 1 kg", "15.00" ], [ "1 - 10 kg", "20.00" ], ], ... } and 3 models: class country(models.model): name = models.charfield(max_length=128, unique=true) class weight(models.model): name = models.charfield(max_length=128, unique=true) min_weight = models.integerfield() max_weight = models.integerfield() class shipping(models.model): country = models.foreignkey(country) weight = models.foreignkey(weight) price = models.decimalfield(max_digits=7, decimal_places=2) what correct way import database using json file? should convert j

jquery - eOnSuccess will be executed even if the Ajax.actionlink did not succsfully execute & also the OnSuccess will not display alerts if using firefox -

i have following ajax.actionlink responsible deleting answer objects:- <td> @ajax.actionlink("delete", "delete", "answer", new { id = answer.answersid }, new ajaxoptions { confirm = "are sure want delete answer ?", httpmethod = "post", updatetargetid = @answer.answersid.tostring(), onsuccess = "deleteconfirmation", onfailure = "deletionerror" }) </td> and following deleteconfirmation.js :- function deleteconfirmation() { jalert('the answer deleted succsfully', 'deletion confirmation'); $(this).remove(); } were ajax.actionlink call folloiwng action method:- [httppost] public actionresult delete(int id) { var = repository.findanswer(id); repository.deleteanswer(a);