Posts

Showing posts from March, 2010

database - one php page with different contents and urls -

i have xml database stocked several blog posts. xml example: <element id="12" size="square" category="portfolio"> <tag tag="printer printing 3d apple iphone 5 bumper case"></tag> <icon class="icon-picture"></icon> <urlpage url="/contact/contact.html"></urlpage> <urlimage src='./post thumbnail images/01.png'></urlimage> <date date="8 apr"></date> <title>minimal bumper iphone 5 : protect iphone lightwheight , protect full case </title> </element> i want have website based on 2 main php pages. main index.php page blog post thumbnails , links displayed. , single.php page each blog posts can displayed individually. how can load, change content , url of single.php page when click on blog post thumbnail link in index.php page (finally, think, wordpress without use it)? if possible, how works seo

html - Div height and background-color -

i have tried overflow , using clear: both; can't child div heights equal, don't want heights static. can me achieve this? here fiddle showing problem. since seem have static widths, don't want static heights, fix setting container div position: relative; , having 1 div float left, , positioning other div 's absolutely. in jsfiddle . the 1 floating div ensure container div has height, , absolutely positioned div 's automatically resize same height floating div . have set overflow-y: auto on absolutely positioned div 's ensure scroll bars appear inside of them if height exceeds height of floating div . should work in browsers. div.container { position: relative; width: 800px; // height determined content of div.left } div.left { float: left; width: 400px; // height determined content } div.middle, div.right { position: absolute; overflow-y: auto; width: 200px; bottom: 0px; // these 2 lines ensure div's height to

c# - Converting mouse click position to a given scale -

here's problem i'm trying solve: you have screen display heart rate (of 1 hour - 60 minutes), how can know minute in, upon click on screen? when clicked on screen specific height , width. this i've done: created form, , on form have docked picturebox object. picturebox object has method invoked clicking on picturebox object. method: private void picturebox1_click(object sender, eventargs e) { var mouseeventargs = e mouseeventargs; if (mouseeventargs != null) { int widthperminute = (int)(mouseeventargs.x / ((picturebox1.width + 1) / 60.0)); messagebox.show((widthperminute).tostring()); } } is there more elegant solution? i'm pretty sure misinterpreted asking first reply (i'm leaving @ end of answer reference). i think you're asking higher-level design you're doing. if going developing heart rate graph display further, rather using picturebox might want write own custom control it. way can encaps

wordpress - Failed to send your message. Please try later or contact the administrator by another method -

i use contact form 7 send messages. in own server theform works perfect. client gets error: failed send message. please try later or contact administrator method. in contact form setting in field , insert valid mail domain this blog you

Parsing large xml data using python's elementtree -

i'm learning how parse xml data using elementtree. got error say:parseerror: not well-formed (invalid token): line 1, column 2. my code right below, , bit of xml data after code. import xml.etree.elementtree et tree = et.fromstring("c:\pbc.xml") root = tree.getroot() article in root.findall('article'): print ' '.join([t.text t in pub.findall('title')]) author in article.findall('author'): print 'author name: {}'.format(author.text) journal in article.findall('journal'): # venue tags id attribute print 'journal' <?xml version="1.0" encoding="iso-8859-1"?> <!doctype dblp system "dblp.dtd"> <dblp> <article mdate="2002-01-03" key="persons/codd71a"> <author>e. f. codd</author> <title>further normalization of data base relational model.</title> <journal>ibm research report, san j

asp.net mvc - How to export to pdf, word, excel file -

i use asp.net mvc 3. have these 2 requirement. frist 1 creating invoice in application. want export datas pdf , word , excel file. downloaded itextsharp dll, can tel me there anyother alternative datas in ui pdf, word , excel document? second need print document after clicking print button. how connect printer print button in exported document ? you can use snippet. this one great. take on it. this example of usage: html <asp:gridview id="gridview1" runat="server" autogeneratecolumns = "false" font-names = "arial" font-size = "11pt" alternatingrowstyle-backcolor = "#c2d69b" headerstyle-backcolor = "green" allowpaging ="true" onpageindexchanging = "onpaging" > <columns> <asp:boundfield itemstyle-width = "150px" datafield = "customerid" headertext = "customerid" /> <asp:boundfield itemstyle-width = "150px&

How to execute a command from a scala script? -

i want execute mysqldump -u talkexchange -p --opt talkexchange > /talkmedia/backups/database_backup.sql command scala script. how go it? thanks. you can @0__ suggested sys.process._ little tweak: import sys.process._ import java.io.file "mysqldump -u talkexchange -p --opt talkexchange" #> new file("/talkmedia/backups/database_backup.sql") otherwise > interpreted parameter mysqldump , instead of redirection operator.

javascript - I am having problems getting my form to validate or submit -

my form not seem validating or submitting. submitting , validating before, jquery error messages not displaying @ same time had edit code, , not submitting or validating @ all. here js: function validateusername(user) { var u = document.forms["newuser"]["user"].value var ulength = u.length; var illegalchars = /\w/; // allow letters, numbers, , underscores if (u == null || u == "") { return "you left username field emptyyy"; } else if (ulength <4 || ulength > 11) { return "the username must between 4 , 11 characters"; } else if (illegalchars.test(u)) { return "the username contains illegal charectors men!"; } else { return ""; } } function validatepassword(pwd) { var p = document.forms["newuser"]["pwd"].value var cp = document.forms["newuser"]["confirmpwd"].value

c# - kendo-ui grid serverfiltering column filtering dropdownlist -

i trying kendoui grid support filtering dropdownlist filter. want users able pick list of available options, rather requiring them type in filter manually. i have shared datasource this: var transport = { read: { url: "/api/account/changes", type: "post", datatype: "json" } }; this method returns object looks this: public class response { public ienumerable data { get;set; } public int count { get; set; } public ienumerable users { get; set; } } i have 2 datasources tied 1 transport: var masterdatasource = new kendo.data.datasource({ transport: transport, schema: { data: "data", total: "count", model: { id: "id", fields: { id: { type: "number" }, user: { type: "string" }, // other columns value: { type: "string" }

facebook - Fb.ui method feed not working. Loading gif appears but no error message or anything -

so i've been trying implement fb method feed people can share songs website. doesn't work. it pops loading gif in dialogue , thats it. no error nothing. i've wasted lot of time trying figure out haven't been able to. here's code, share_obj = { method: 'feed', link: "", redirect_uri: "", picture: ", name: "", caption:"" , description: "" }; fb.ui({method: "permissions.request", "perms": 'publish_stream'}, callback); function callback(response) { if(response["perms"]=="publish_stream") { var obj = share_obj; fb.ui(obj,callback_share); } } function callback_share(response) { } does have facebook app migrations or app permissions? so turns out, there s no need ask user permissions when invoking fb.ui met

c++ - Windows Unicode keyboard hook -

i'm developing application in point needs capture keyboard , mouse user input. had no problems installing , using mouse hook, keyboard not working properly. need capture wide characters multiple keyboard layouts. found relevant did not solve problem: https://stackoverflow.com/questions/15976108/keyboard-hook-not-capturing-unicode-in-other-threads that's have without not necessary stuff winmain: //set hook, threadid = 0 hhook = setwindowshookex(wh_keyboard_ll, keyboardproc, hinstance, 0); hkl keyboardlayout = getkeyboardlayout(0); //all window , message queue code keyboardproc: wchar unicodechar; byte keyboardlayout[256]; kbdllhookstruct* keyparam = (kbdllhookstruct*) lparam; if(code < 0) return callnexthookex(hhook, code, wparam, lparam); if(wparam == wm_keydown) { getkeyboardstate(keyboardstate); int translation = tounicodeex(keyparam->vkcode, keyparam->scancode, keyboardstate, &unicodechar, 1, 0, keyboardlayout); translation = to

jQuery Point A to Point B Slide effect -

i looking jquery plugin, or if can other means, thats welcome also, anyways heres need do. on website fsp.dbztech.com i need red arrow move point (where now) point b, down little. on mouse over. so kinda hinting @ proceed down kind of thing. if have other questions because isn't enough information, let me know. using jquery.ui, assuming non-static (e.g. absolute) positioning of arrow, move arrow down 400 pixels when hover on it: $(function() { $(".arrow").hover(function() { $(this).animate({ top: "400px" }); }); }) replacing "400px" "+=40px" make arrow move 40 pixels below it's original position.

python 2.7 - can not read post data in app engine -

i'm trying post data app engine in following manner: sendmessage = function(path, data) { $.ajax({ type: "post", url: path, data: data, contenttype: "application/json", datatype: "json", failure: function(errmsg) { alert(errmsg); }, success: function(result,status,xhr){ alert(result); } }); }; sendmessage('/chatmessage', {"message": "aaaa"}); the receiving code: class chatmessage(webapp2.requesthandler): def post(self): user = users.get_current_user() message = self.request.get("message", "fail") logging.error('requestbody:' + str(self.request.body)) logging.error('message:' + message) the log messages: error 2013-05-18 16:23:31,954 channels.py:52] requestbody:message=aaaa error 2013-05-18 16:23:31,956 channels.py:53] message:f

phantomjs: unknown module system -

phantomjs version 1.4 (the newest version available through apt). have single js file, content: var page = require('webpage').create(); var system = require('system'); when run it, with: phantomjs testscript.js i error: undefined:0 unknown module system require() what mean? causes it? trying run example https://github.com/ariya/phantomjs/blob/master/examples/direction.js , can't seem simplest thing work. there way read command line arguments using system? update latest version (1.9.1). see: how can setup & run phantomjs on ubuntu? or compile own version: sudo apt-get update sudo apt-get install build-essential chrpath git-core libssl-dev libfontconfig1-dev git clone git://github.com/ariya/phantomjs.git cd phantomjs git checkout 1.9 ./build.sh note need symlink /usr/bin/ etc build dir

Is there somewhere I can get the typical XML styles from the Android design guides? -

this driving me insane @ times, why don't provide xml snippets of showing? example: http://developer.android.com/design/building-blocks/lists.html it'd nice know how using 2 lined list item layout. sdk sources. there many examples, metrics , need. including drawables. shamelessly copy them project keeping copyright notice , that's all. but of course, you'll need study code bit... by way, 2 line list item seems medium , small text, 4dp (or 8) between them, , 16 margins on top , bottom. left margin think 8dp. there standard r.layout including two_line_list_item, put stuff on sides you'll need go custom. header standard list header available under r.layout.* it follows design guides. nothing fancy.

c++ - Pass vector of pointers by reference and replace a vector of void* pointers -

i have following structure: typedef struct{ int pkttype; void* sourcepeer; void* destpeer; void* aboutpeer; int tree; std::vector<int> cogsize; //leave ? std::vector<void*> newparents; //join_rep }packet; in addition, have class named base_peer declared follows: class base_peer { ... public: virtual void createmessage(int, base_peer*, base_peer*, base_peer*, int, std::vector<int>&, std::vector<base_peer*>&, packet*); ... } and createmessage() function defined follows: void base_peer::createmessage(int msgtype, base_peer* msgsourcepeer, base_peer* msgdestpeer, base_peer* msgaboutpeer, int msgabouttree, std::vector<int>& msgcogsize, std::vector<base_peer*>& newparents, packet* newpacket) { newpacket->pkttype = msgtype; newpacket->sourcepeer = msgsourcepeer; newpacket->destpeer = msgdestpeer; newpacket->aboutpeer = msgaboutpeer; newpacket->tree = msgabouttree; newpacket->c

vba - Visual basic macro- changing the colour of specific text -

im new visual basic , macros. have been trying create macro through whole document , check see if of font red;if red want change red font white font. i know code wrong can tell me doing wrong? sub red() if font.color =wdcolorred font.color = -603914241 end sub you can use following quick (no looping required each sheet). sub macro1() application.screenupdating = false 'disable screen updating, i.e, avoid excel redrawing screen after each color change make application.findformat.font.color = 255 application.replaceformat.font.color = 16777215 cells.select selection.replace what:="", replacement:="", matchcase:=false, searchformat:=true, replaceformat:=true application.screenupdating = true 'enable screen updating end sub font colors can little tricky. find out color want, select cell , change color color need know number for. go developer screen , view -> immediate window (or hit ctrl+g). in immediate window (should @ bottom of

ios - Why a singleView application doesn't load a storyboard if a storyboard is added later to the project? -

Image
i created new singleview application without storyboard (say firstproject) , single view application storyboard (say secondproject)and added storyboard in application didn't have storyboard previously. went in firstproject , changed class of storyboard viewcontroller class in identity inspector. after opened other files in 2 projects individually , made changes in code same in corresponding files in 2 projects. now when run project had storyboard @ time of creation shows white blank screen other application (in storyboard added later) shows black screen no errors , no warnings.. difference in these 2 files? what missing. how tell application should load view storyboard , not xib file there none? i second "good job" building scratch grok storyboards. you need delete template code , return yes; in application:didfinishlaunchingwithoptions: complete process create new project using "empty application" template. new file, user interface, st

unix - How to get the PID of matlab when using the MATLAB Engine? -

when using matlab engine interface , how can process id of matlab process started? or how can launch matlab process in way allow me pid? the reason why need able interrupt calculations when take long. on *nix systems seems work sending sigint signal matlab. won't kill matlab, interrupt current calculation. evaluate following in matlab pid: feature('getpid') i found here .

regex - C# regular expressions for URL query strings -

i got following scenario: i affiliate network url , need append appropriate url parameter tracking purposes (subid). the actual problem: in cases 1 affiliate network supports different query string formats. example: 1) http:/ /impde.sampleaffiliate.com/imp?pop(over)g(xxxxx)a(xxx)subid(subidvalue) or 2) http:/ /clkde.sampleaffiliate.com/click?p=xxx&a=xxx&g=xxx&subid=subidvalue the recognition of affiliate network pretty simple [url.contains("sampleaffiliate")] , query string format, i'm using regular expressions: //query string parameter values in brackets, e.g. ?a(12312)b(12343432)c(4242) regex parametersinbrackets = new regex(@"^[\?]{1}\w+(\(.*\))+$"); //query string parameter values separated ampersands , equal signs, e.g. ?a=12312&b=12343432&c=4242 regex parameterswithampersand = new regex(@"^[\?]{1}.+(\&\w+\=.+)+$"); those work fine "normal cases". but here comes additional difficulty - @ foll

HTTP error 403 in Python 3 Web Scraping -

i trying scrap website practice, kept on getting http error 403 (does think i'm bot)? here code: #import requests import urllib.request bs4 import beautifulsoup #from urllib import urlopen import re webpage = urllib.request.urlopen('http://www.cmegroup.com/trading/products/#sortfield=oi&sortasc=false&venues=3&page=1&cleared=1&group=1').read findrows = re.compile('<tr class="- banding(?:on|off)>(.*?)</tr>') findlink = re.compile('<a href =">(.*)</a>') row_array = re.findall(findrows, webpage) links = re.finall(findlink, webpate) print(len(row_array)) iterator = [] the error is: file "c:\python33\lib\urllib\request.py", line 160, in urlopen return opener.open(url, data, timeout) file "c:\python33\lib\urllib\request.py", line 479, in open response = meth(req, response) file "c:\python33\lib\urllib\request.py", line 591, in http_response 'http

android - When Zooming an ImageView the image scales to the corner instead to center -

so i'm running error image zoom, instead of zooming midpoint of 2 fingers, zoom corner of original picture. creates unnatural user interface. @override protected void ondraw(canvas canvas) { canvas.save(); canvas.translate(mposx, mposy); canvas.scale(mscalefactor, mscalefactor); super.ondraw(canvas); canvas.restore(); } with ontouchevent, myscale.ontouch send program scalelistener scaling information @override public boolean ontouchevent(motionevent event) { super.ontouchevent(event); midpoint(mid,event); myscale.ontouchevent(event); switch (event.getaction() & motionevent.action_mask){ case motionevent.action_down: { final float x = event.getx(); final float y = event.gety(); mode=drag; // remember started mlasttouchx = x; mlasttouchy = y; mactivepointerid = event.getpointerid(0); break;

garbage collection - Python: cracking the gc enigma -

i trying understand gc because have got large list in program need delete free badly needed memory. basic question want answer how can find being tracked gc , has been freed? following code illustrating problem import gc old=gc.get_objects() a=1 new=gc.get_objects() b=[e e in new if e not in old] print "problem 1: len(new)-len(old)>1 :", len(new), len(old) print "problem 2: none of element in b contain or id(a): ", in b, id(a) in b print "problem 3: reference counts insanely high, why?? " imho weird behavior isnt addressed in docs . starters why assigning single variable create multiple entries gc? , why none of them variable made?? entry variable created in get_objects()? edit: in response martjin's first reponse checked following a="foo" print in gc.get_objects() still no-go :( how can check being tracked gc? the result of gc.get_objects() not tracked; create circular reference otherwise: >>> import g

jquery - Live handling does not work with event.stopPropagation(); -

i'm using event.stoppropagation() , having problems using .live() handler on parent. //does not work $("#testlink").live({ click: function(event) { alert('testlink'); } }); //works great! $("#testlink").click(function() { alert('testlink'); }); i have use .live() because content loaded ajax. can me problem? how can use more classes or ids this? $('#div1', '#div2', '#div3').on('click', 'a.testlink', function(){ alert('testlink'); }); how possible? use on() (as @techfoobar mentioned, live() deprecated in version 1.7 , removed of version 1.9) , event delegation if content dynamically generated: $('#container').on('click', '#testlink', function(){ alert('testlink'); }); where #container element containing dynamically loaded #testlink element (you use document , using container element here reduce

jquery - Displaying an optional input field triggered by a radio button -

as can see here, have bulleted list. last option on list "other". when other selected, want "if other, please describe here:" element , respective input box displayed. if "other" not selected, i'd keep hidden. is possible? <div class="section section_required"> <asp:label id="pleaseselect" runat="server" text="please select type of content:"></asp:label> <br /> <br /> <asp:radiobuttonlist id="radiobuttonlist1" runat="server" width="675px"> <asp:listitem value="content1">alumni achievement/ alumni profile</asp:listitem> <asp:listitem value="content2">list of training sites or locations our graduates working</asp:listitem> <asp:listitem value="content3">employer/ advisory board testimonials</asp:listitem> <asp:listitem

css - Drop down menu in mobiles -

i have drop down menu in website , it's working fine in laptop in browser there problem in mobiles , tables. in laptop, when hover menu, drop down automatic , when remove mouse menu closes, , that's fine.. in mobiles , laptops, when click on menu, drop down automatic , closes after 1 second, , problem. need menu keep open until close manual clicking anywhere else! what can in css? media queries important website view in different device mobiles , tablets, need insert media queries in css,this website responsive , work in both devices. http://www.techbian.com/dell-xps-12-worlds-first-2-in-1-4k-convertible-pc/ so, use below code , modify insert on website's css. @media screen , (max-device-width: 480px) { }

java - How threads work -

i have problem understanding how threads work: class threadtest implements runnable{ synchronized void methoda(long n){ (int i=1;i<3;i++){system.out.print(n+" "+i)} } public void run(){ methoda(thread.currentthread.getid()); } public static void main(string ... args){ new thread(new threadtest()).start(); new thread(new threadtest()).start(); } } as understand, because methoda synchronized loop in method, must finish before next thread calls method -- result must 4-1 4-2 5-1 5-2... is possible have result 4-1 5-1 5-2 4-2 ? if yes, how? is possible have result 4-1 5-1 5-2 4-2.? it possible. if yes how? you using this reference object locked synchronized . since you've got 2 distinct instances of threadtest , each method locks own instance , mutual exclusion not achieved. so, must understand semantics of synchronized : there defined object involved monitor acquire

java - My Swing GUI does not update. Why? -

Image
so, making gui in user has ability add or remove panels. simulate that, made timertask takes name of target jpanel , parent contains jpanel . counts down 0 , after removes jpanel parent , calls repaint() on parent , grandparent. although old panel gets removed, other components contained in parent not come take place. can seen in picture scroll bar still indicated 2 components. i have manually drag scroll bar down see change , when component below comes take place. why happening? here how components nested: jscrollpane (grandparent) | |-> jpanel (parent) | |-> jpanel (target) sscce not possible because jpanels populated data xml file , uses jaxb .. not possible :( here snippet timertask import java.util.timertask; import javax.swing.*; public class removertask extends timertask{ studentpanel s; jpanel h; jscrollpane p; public removertask(studentpanel s,jpanel holder,jscrollpane pane){ this.s = s; h = hol

c - Cannot pass a variable of my own (non-standard) type to a function -

i'm writing program must normalize audio *.wav file. there task "to display header's data": chunkid , chunksize , on. i want make function named display_hdr (in order have less code in main.c file, become esier read code). have pass function header's variable (variable of type header) argument, writes functions.h|1|error: unknown type name 'header'| main.c : typedef struct fmt { char subchunk1id[4]; int subchunk1size; short int audioformat; short int numchannels; int samplerate; int byterate; short int blockalign; short int bitspersample; } fmt; typedef struct data { char subchunk2id[4]; int subchunk2size; int data[]; } data; typedef struct header { char chunkid[4]; int chunksize; char format[4]; fmt s1; data s2; } header; header's variable declared in way: header hdr;

java - Is it possible to use Hibernate with EJB3? -

i can't find example i'm starting doubt whether possible or not... asked build webapp both of them... yes. possible.. please check below link http://www.techbits.de/2006/04/17/ejb3-persistence-with-hibernate

html - How to center the links in the very middle of the button/link? -

here work far can't center text of links in middle. how do it? thank all! http://jsbin.com/icafoq/1/edit you can use line-height:40px in case. see jsbin here: http://jsbin.com/icafoq/2/edit

syntax - use of ! in Ruby -

i new ruby! , trying learn use of "!" . i aware ! included user's string modified in-place; otherwise, ruby create copy of user_input , modify instead. but in following case both programs getting same output.why? print "please enter input" user_input = gets.chomp user_input.downcase! print "please enter input" user_input = gets.chomp user_input.downcase in ruby, bangs (!) used inform programmer method calling destructive . it's ruby's way of saying "hey! method going change object called on!". number of safe methods in string , array, enumerable`, etc classes have destructive counterparts. example: my_str = "hello, world!" my_str.downcase # => "hello, world!" my_str # => "hello, world!" my_str = "goodbye, world!" my_str.downcase! # => "goodbye, world!" my_str #> "goodbye, world!" as can see, while both methods return string's lower

objective c - TableView Delegate Messages Not Being Called -

solved: not solution, used .xib rather trying use storyboard thing. whatever trying storyboard somehow messing tableview delegate methods being called. insight guys provided. i have uiviewcontroller contains uitableview should populated array. unfortunately uitableview not populated array (which not empty). my .h file: @interface directory : uiviewcontroller <uitableviewdelegate, uitableviewdatasource, uisearchbardelegate> { nsarray *listdata; nsarray *savedlistdata; mkmapview* mapui; uisearchbar* searchbar; nsarray * originallistdata; uitableview* placelist; dirinfolisting *infoinst; nsstring *searchinit; nsstring *openinit; nsmutablearray *buildings;} @property (nonatomic, retain) nsarray *listdata; @property (nonatomic, retain) nsarray *savedlistdata; @property (nonatomic, retain) iboutlet uisearchbar* searchbar; @property (nonatomic, retain) iboutlet uitableview* placelist; - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil list: (ns

cordova - PhoneGAP Build - Unsupported devices on Google Play -

when publishing apk generated pgb - google play says app "not supported" 267 devices, including google nexus 7. the config.xml: <?xml version="1.0" encoding="utf-8"?> <widget xmlns = "http://www.w3.org/ns/widgets" xmlns:gap = "http://phonegap.com/ns/1.0" id = "com.test" version = "1.0.0"> <name>test</name> <description>test</description> <author href="http://www.test.com/" email="info@test.com">test</author> <preference name="phonegap-version" value="2.5.0" /> <!-- all: current version of phonegap --> <preference name="orientation" value="default" /> <!-- all: default means both landscape , portrait enabled --> <preference name="target-device" value="universal&

c++ - Conversion warning. and Class error -

i'm learning c++, , in assignment i'm doing right now, bunch of warnings suspect causing 2 errors i'm getting well. problem lines warnings show lines (one of which) gave us, think code must right. leads me believe there issue in class declaration or constructor. can spot wrong? the warning (for each line of fillsystemcommandlist function) conversion string literal 'char *' deprecated and errors undefined symbols architecture x86_64: "command::command(char*, int)", referenced from: fillsystemcommandlist() in system_utilities.o ld: symbol(s) not found architecture x86_64 clang: error: linker command failed exit code 1 (use -v see invocation) you can skip on parsecommandline function, think it's fine. included have entire file (this isn't main btw.) other notes: -the systemcommands array supposed of command pointers of length number_of_commands (i think did right) -the fillsystemcommandlist function supposed populate syste

socket.io - socketio client: How to handle socketio server down -

i've got socketio server/client working together, want start writing events when server offline on page load or during normal run. i'm including remote socket.io code in header: <script src="<?=node_host?>/socket.io/socket.io.js"></script> <script> var nodehost = '<?=node_host?>'; </script> and in client controller have if(typeof io != 'undefined') this.socket = io.connect(this.settings.server); else this.handledisconnect(); the function have attempt re-connect on , on if a) socket disconnect occurs during normal operation, or b) server down on page load botcontroller.prototype.handledisconnect = function() { $.getscript(nodehost+"/socket.io/socket.io.js").done(function(script, textstatus) { bot.control.socket = io.connect(bot.control.settings.server); }).fail(function(jqxhr, settings, exception) { settimeout(function() { bot.c

return dynamic value in java REST / Spring / Hibernate -

i've inherited rest api using jboss, spring, hibernate, etc. , i'm new these please forgive seems dumb question (to me). the basic flow when performing build entity list add modelandview object return it. question: how can add calculated value response? i don't want store calculated values in database, nor want add member each entity being returned (ie arraylist<athletes> , add "points behind leader" member athletes class). want perform calculation on each request , append member json response dynamic value so: { "athlete1" : {"name" : "bob", "somedynamicvalue" : "124548412" } } seems relatively common can't seem find simple solution.....maybe i'm not sure how ask question correctly. any appreciated. ps - thought me returning entities in rest api spring answer never addressed questions, how add dynamic values response. edit: per request here's simplified code public m

c# - Weird serialization error when entity is serializable -

i following error when trying serialize object: type 'test.common.testobj`1+<>c__displayclass1`1[[test.common.testentity, test.common, version=1.0.0.0, culture=neutral, publickeytoken=null],[system.boolean, mscorlib, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089]]' in assembly 'test.common, version=1.0.0.0, culture=neutral, publickeytoken=null' not marked serializable. i have [serializable] attribute both on testobj entity, it's base entities , entities related properties. else can cause "is not marked serializable" error? and c__displayclass1`1 means?? googled c_displayclass1'1 , found following: http://rantdriven.com/post/2011/07/09/the-mysterious-2b3c3ec__displayclass1.aspx it has links , explanations how might event handler you're trying serialize. this seems helpful comment: the main issue has what's being serialized. default, event handlers internally represented compile-time g

Strange Happenings With SyntaxHighlighter On Blogger -

i've added syntaxhighlighter blog powered blogger. first, single quotes within <pre> tag, converted double quotes on viewing post. however, when edit post, single quotes still there. when try use &apos; or &#39; instead, gives me single quote & double quote. second, when show example of <b:else /> conditional tag use in syntaxhighlighter, add's closing </b:else /> (there's no such thing) conditional tag. again, when go edit post, </b:else /> not there. appears on post view. here i'm using: <pre class="brush: xml"> <b:if cond='data:blog.pagetype == "item"'> standard content (if statement true) <b:else/> alternative content (if statement false) </b:if> </pre> appears as: <b:if cond=""data:blog.pagetype" =="item""> standard content (if statement true) <b:else> alternative content (if statement false) </b

C - How do you ignore certain code depending on the OS (so one source code to fit all) -

i want make source of program cross-platform, , far good. have couple of functions differ in syntax, checking defines @ start see if windows or linux , setting variable 1 or 0 depending on 1 is. thinking if statement check on variable skip incorrect syntax usage. have realised won't compile because compiler still 'sees' offending code. can you #ifdef to compartmentalize functions , call them within code? suggestions? you have enclose entire non cross-platform section between #ifdef s. for instance: int gettimeofday(struct timeval *tp, void *tzp) { #ifdef win32 struct _timeb timebuffer; _ftime(&timebuffer); tp->tv_sec = timebuffer.time; tp->tv_usec = timebuffer.millitm * 1000; return 0; #else tp->tv_sec = time(null); tp->tv_usec = 0; return 0; #endif } like compiler won't see offending code since removed @ pre processing step.

python - No return in my code -

if execute piece of code, works partially. tried empty string , code works. tells me false when character in string! def isin(char, astr): """char single character , astr alphabetized string. returns: true if char in astr; false otherwise""" # base case: if astr empty string if astr == '': return('the string empty!') #return false # base case: if astr string of length 1 if len(astr) == 1: return astr == char # base case: see if character in middle of astr equal test char midindex = len(astr)/2 midchar = astr[midindex] if char == midchar: return true # recursive case: if test character smaller middle character,recursively # search on first half of astr elif char < midchar: return isin(char, astr[:midindex]) # otherwise test character larger middle character, recursively # search on last half of astr else: return isin(char, astr[midindex:]) astr = str(raw_

How can I read an Excel File with JavaScript (without ActiveXObject) -

my friend asked me make simple application generate charts (bar, curves) excel file. opted use javascript language since know powerful chart.js. before using chart.js, have gather data excel file. how read excel file via javascript? after research have managed internet explorer (using activex), need work across browsers. there javascript libraries allow xls & xlsx parsed in pure javascript. tested chrome (albeit on windows) , worked fine.

asp.net - How to detect wrong encoding declaration? -

Image
i building asp.net webservice loading other webpages , hand clients. have been doing quite character code treatment, reading meta tag html use codeset read file. nevertheless, less educated users don't understand code sets. declare specific encoding method e.g. "gb2312", in fact, using normal utf8. when use gb2312 decode text, turns out holy mess. how can detect whether text decoded? loaded page ie, correctly use utf-8 decode page. how achieve that? based on bom can tell encoding used. bom , encoding if want detect character set use c# port of mozilla's character set detector. chardetsharp if want make sure using correct one, maybe looking special characters not supposed there. not include "óké". looking such characters , try use different encoding/character set process file. actually hard make application "fool-proof".

javascript - DropDown Menu Display Issue -

what want in website have following code displayed appears timeout closing menu when hovering on menu section (at bottom problematic code). this achieved without having troubles (but without timeout when hovering on menu sections) css: .menu { list-style:none; position:relative; } ul.menu ul { list-style:none; display:none; position:absolute; /* position relative <li> contains <ul> */ left:5em; /* there no overlaping on <li> */ top:-1em; } ul.menu li:hover > ul { display:block; } html: <ul class="menu"> <li>equipos <ul> <li>masculinos <ul> <li><a href="#">aguilas</a></li> <li><a href="#">cef 18</a></li> <li><a href="#">celtas</a></li> <li><a href="#">indi