Posts

Showing posts from April, 2014

c++ - Python swig-wrapped vector of vector of doubles appears as Tuple -

i have function in c++ returns vector<vector<double> > object. have wrapped python using swig. when call it, unable subsequently modify function's output using resize() or push_back() vector methods. when try this, error 'tuple' object has no attribute 'resize' or 'push_back'. swig transform vectors tuple objects when interact them in python? if that's case, assume output function in python immutable, problem. can pass object wrapped methods accept vector of vectors of doubles. can't mess using vector methods within python. explanation on why or ideas on work-arounds appreciated. here swig file reference. stl template lines towards end: /* solutioncombiner.i */ %module solutioncombiner %{ /* put header files here or function declarations below */ #include "coord.hpp" #include "materialdata.hpp" #include "failurecriterion.hpp" #include "quadpointdata.hpp"

java - OpenGl ES on android fine tuning of ray picking code -

ive implemented ray picking using min3d , code found online when implemented notice off bit times meaning when click on 1 box wrong 1 picked. 1 picked isnt on screen. took quite bit of code implemented in first place main 2 methods call following: private void raypicking(float x, float y) { //intersection near plane float[] near = new float[4]; glu.gluunproject(x, scene.getviewport()[3] - y, 0f, scene.getgrabber().mmodelview, 0, scene.getgrabber().mprojection, 0, scene.getviewport(), 0, near, 0); if (near[3] != 0) { near[0] = near[0] / near[3]; near[1] = near[1] / near[3]; near[2] = near[2] / near[3]; } number3d near3 = new number3d(near[0], near[1], near[2]); //and far plane float[] far = new float[4]; glu.gluunproject(x, scene.getviewport()[3] - y, 1f, scene.getgrabber().mmodelview, 0, scene.getgrabber().mprojection, 0, scene.getviewport(), 0, far, 0); if (far[3] != 0) { far[0] = far[0] / far[3];

coding style - How should I structure my classes and files in python? -

my code in 1 big file: # file 1: ./mainfile.py class namespace: class this: ... class that: ... mainfunc(namespace.this(), namespace.that()) i code this: # file 1: ./namespace/this.py class this: ... # file 2: ./namespace/that.py class that: ... # file 3: ./mainfile.py import ??? mainfunc(namespace.this(), namespace.that()) what changes have make can still use same call mainfunc() ? you need make package. see the documentation .

c - Writing logs to a file in multithreaded application -

i've written server-client application. now, have write happens on server log file. server written in c. can write happens screen using printf. so i'll have use fprintf instead of printf. question how should handle file? i have server.c source file there main function here basic structure of server application: server.c //.. code int main(...) { //some code //initialize variables //bind server //listen server on port while(1) { //accept client int check = pthread_create(&thread, null, handle_client,&ctx);//create new thread //.. }//end while return exit_success; }//end main handle_client function handles clients in new thread. how should make server log? have 1 text file example serverlog.log , there many clients on server. how should handle multiple access file? one way create file when start server, open it, write in it, close it. if client wants write in file, should open file write in , close it. but there still problem when

java - Superclass Common Method Implementation -

i'm new oo programming java. have question pertaining inheritance. i have printing method i'd common among subclasses. code in print method usable subclasses except response object specific each individual subclass. i'm thinking need override method in each subclass providing specific implementation. feels there slicker way keep common method in super class , while somehow supplying specific response object based on subclass accessing it. any thoughts? sorry if seems elementary.... you absolutely right, there better way. if implementations share great deal of code, can use template method pattern reuse implementation possible. define printreponse method in superclass, , make abstract. write print method in superclass common thing , calls printresponse when needed. finally, override printresponse in subclasses. public abstract class baseprintable { protected abstract void printresponse(); public void print() { // print common

How to combine both array and insert into database php -

if 1 array there example $values = array(x, y, z); i adding them database this foreach ($values $value) { $insertfunction = addvalues($value); } my arrays: $array1 = array ( 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 ); $array2 = array ( fb1, or1, fb2, or2, fb3, or3, fb4, or4, fb5, or5 ); but want both array combine , insert them database. how can please me updated: when printing post values getting out put this array ( [0] => 1 [1] => 2 [2] => 1 [3] => 2 [4] => 1 [5] => 2 [6] => 1 [7] => 2 [8] => 1 [9] => 2 ) array ( [0] => fb1 [1] => or1 [2] => fb2 [3] => or2 [4] => fb3 [5] => or3 [6] => fb4 [7] => or4 [8] => fb5 [9] => or5 ) when tried array_merge out put array ( [0] => 1 [1] => 2 [2] => 1 [3] => 2 [4] => 1 [5] => 2 [6] => 1 [7] => 2 [8] => 1 [9] => 2 [10] => fb1 [11] => or1 [12] => fb2 [13] => or2 [14] => fb3 [15] => or3 [16] => fb4 [17] =

android - In Eclipse Images are not clickable? -

ive made pretty simple wallpaper app , have used same code before. no errors reason images not clickable, missing help... here code far import java.io.ioexception; import java.io.inputstream; import android.app.activity; import android.graphics.bitmap; import android.graphics.bitmapfactory; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.imageview; public class nflwallpapers extends activity implements view.onclicklistener{ imageview display; int tophone; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.main); tophone = r.drawable.azcard1; display = (imageview)findviewbyid(r.id.ivdisplay); imageview image1 = (imageview) findviewbyid(r.id.ivimage1); imageview image2 = (imageview) findviewbyid(r.id.ivimage2); imageview image3 = (imageview) fi

postgresql - Alternate output format for psql -

i using postgresql 8.4 on ubuntu. have table columns c1 through cn . columns wide enough selecting columns causes row of query results wrap multiple times. consequently, output hard read. when query results constitute few rows, convenient if view query results such each column of each row on separate line, e.g. c1: <value of row 1's c1> c2: <value of row 1's c1> ... cn: <value of row 1's cn> ---- kind of delimiter ---- c1: <value of row 2's c1> etc. i running these queries on server prefer not install additional software. there psql setting let me that? i needed spend more time staring @ documentation. command: \x on will wanted. here sample output: select * dda u_id=24 , dda_is_deleted='f'; -[ record 1 ]------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Anyone have a launchd script for running JBoss at boot on Mac OSX Lion? -

i'm using mac os x lion , installed jboss 7.1.0.as. i'm having trouble getting jboss server run @ system startup. created below file (/system/library/launchdaemons/jboss.plist) ... <?xml version="1.0" encoding="utf-8"?> <!doctype plist public "-//apple computer//dtd plist 1.0//en" "http://www.apple$ <plist version="1.0"> <dict> <key>label</key> <string>jboss</string> <key>disabled</key> <false/> <key>keepalive</key> <dict> <key>successfulexit</key> <false/> </dict> <key>programarguments</key> <array> <string>sh /opt/jboss-as-7.1.0.final/bin/standalone.sh</string> </array> <key>runatload</key> <true/> <key>username</key> <string>davea</string> </dict> </plist> however, when restart computer, server isn't running. have working st

c++ - scanf causes loop to terminate early -

c='q'; while(c=='q') { printf("hello"); scanf("%c",&c); } why loop exit without reason on taking input? i'm going assume want user input of 'q' mean quit, , want loop exit when c == 'q' . try: c='\0'; while(c !='q') { printf("hello"); scanf("%c",&c); }

http - Display dynamic content from embedded web server -

i have embedded device running slimmed down version of http server. currently, can display static html pages. here example of how displays static html page: char *text="http/1.0 200 ok\r\ncontent-type: text/html\r\n\r\n" "<html><body>hello world!</body></html>"; ipwrite(socket, (uint8*)text, (int)strlen(text)); ipclose(socket); what i'd display dynamic content, e.g. reading sensor. thought of far have page refresh every once in awhile <meta http-equiv="refresh" content="600"> and use sprintf() attach sensor reading text variable response. is there way can without having refresh page constantly? you can try following (from experience) approach: - divide static , dynamic content, minimize dynamic content. create pseudo cgi interface, i.e. url your_embedded_site/sensor.cgi should bound generation of following http response: sprintf(cgi_str, "http/1.0 200

python - Problems with GNOME Panel applet execution -

i'm developing gnome panel applet gnome 3 (with d-bus) in python. i'm having problem this, when open add panel dialog, applet appear, when select , press on add , gnome panel never launch executable script contain applet code (the file has execution permissions). when execute script manually, added applets works fine. i have installed panel-applet file in /usr/share/gnome-panel/4.0/applets , dbus service file in /usr/share/dbus-1/services . if helps, files following: /usr/share/gnome-panel/4.0/applets/org.gnome.panel.applet.dynamicseparatorapplet.panel-applet [applet factory] id=dynamicseparatorappletfactory name=dynamic separator applet factory location=/usr/lib/dynamic-separator-applet/dynamic-separator-applet description=dynamic separator applet factory [dynamicseparatorapplet] name=dynamic separator name[es]=separador dinámico description=create separator configurable size description[es]=crea un separador con tamaño configurable icon=dynamic-separator-appl

HTML Clickable or Drillable Pie Charts Using Graphael -

background i able graphael example of dynamic pie chart working. however, i'm having problem understanding syntax... the example passes in 2 html links , seems associate links 2 labels , 2 specific slices of pie it's not obvious how correlations or associations happen in string that's passed "piechart" method. tried pass in few more links code seems randomly associate links labels. there doesn't seem obvious way ensure link1 associated label1. question does know how explain what's happening in code? how 2 links being associated 2 slices of pie? how consistently associate links labels , specific slices of pie? note i don't piechart function takes in 3 "separate" strings of values, labels, , links not collocated each other, makes code hard read. original looks follows... example pie = r.piechart(320, 240, 100, [55, 20, 13, 32, 5, 1, 2, 10], { legend: ["%%.%% - enterprise users", "ie users"], legendp

netbeans - ssl implementation in jsp -

how implement ssl (https) on localhost in java/jsp using tomcat server , netbeans ide. don't have implementation of ssl. please me.!! sites, i've visited ssl in tomcat

PDF and sharepoint integration -

is there tool allows editing , saving of pdf's similar how office documents saved in document library in sharepoint. want user able open pdf contains digital signature line in it. when sign document document automatically saved document library. direction help. my team used itextsharp quite heavily in moss environment generate pdfs on fly , serve them up. believe there couple versions available nuget packages easy consumption in project.

android - Can't change tag of fragment -

i have few pages (fragments) in viewpager. when tried remove (for instance) first one, this: mfragmentmanager.begintransaction().remove(page1).commit(); it says that illegalstateexception has occured. i don't know why. me? thanks. exception: java.lang.illegalstateexception: can't change tag of fragment page2{40586418 #2 id=0x7f080006 android:switcher:2131230726:2}: android:switcher:2131230726:2 android:switcher:2131230726:1 this old question, anyhow here information in hope someone. viewpager works adapter set via viewpager#setadapter(). in case of question, seems fragmentpageradapter used adapter (since adapter names fragments android:switcher:[x]:[y] appears in exception). one important observation fragmentpageradapter this: fragmentpageradapter owns allocated fragments used in viewpager. the user of viewpager conjunction of viewpageradapter has define subclass of fragmentpageradapter implementing getitem() method, prototyped follows: publi

service - Best practices for pubnub on android -

i'm using pubnub publish/subscribe channel between android app , server. i'm thinking of how implement this. i'm using provided library android ( https://github.com/pubnub/pubnub-api/tree/master/android ) think there problems application lifecycle if use now. (correct me if i'm wrong) i thinking of implementing service what want the service has keep on running until hour (negotiable) after last app usage. that's because want have notifications when message comes in, app not used app. how stop service after 1 hour of non-activity of app? android kill it, want control. the service must able trigger app change it's interface when specific messages come in (i thinking of sending intents service when receive pubnub message?), pubnub send data service, need way pass data application (probably save in bundle in intent?) i need listen multiple pubnub channels (max 2 @ same time), think have in multiple instances of service? i think this: create ser

javascript - How can i "getImageData" from another website? SECURITY_ERR: DOM Exception 18 -

i'm working on online app manipulate images. works fine when doing local files (on server) try source breaks. reason seems security limitation, qoute whatwg : whenever getimagedata() method of 2d context of canvas element origin-clean flag set false called otherwise correct arguments, method must raise security_err exception. so wonder can around somehow? images come google api, , want skip saving images if can. thanks. since don't have access server(s) source images being pulled from, best bet proxy files through server. essentially, send ajax request server url of image want data from. server receives request , asks image on behalf. when obtains file, base64 encodes , sends data you. since image data string, can create image object out of , manipulate via canvas without worrying originating domain. if you're willing use jquery, there's great plugin located here: http://www.maxnov.com/getimagedata/ i've used particular plugin before e

asp.net - whats wrong with my XML for document ranking? -

i wrote program in c# calculate tf-idf rank documents. i used following xml store word frequencies within documents. criticised heavily using structure. though use text of word within tag, per me efficient , consumes less space. also, can make search using xdocument pretty since nice tree structure. can me understand why criticised heavily? criticism: how can add information within meta-data? (for me innovative). <word> <siddhartha> <doc1> 4 </doc4> <doc2> 5 </doc2> <insipration> <doc1> 4 </doc1> <doc6> 5 </doc6> .... </word> i suggested this: <word> <text> siddhartha </text> <doc1> 4 </doc1> <text> inspiration </text> <doc1> 4 </doc1> ... </word> your structure, word name node, hard parse generic parsers. there no defined structure: need read whole document know it. i may hav

Android: Change background color outside of the layout -

if have layout's width , height set wrap_content, take half screen. if set layout's background white, half screen white while other half remains on default android black. there way set other half, has no layout in it, white? i want keep layout's width set wrap_content because i'm including in several activities used in top half of screen bottom half vary activity activity. well, layout contained within decor view of activity - accessible through activitys window , so: getwindow().getdecorview().setbackgroundcolor(color.green);

python - Print only the characters below a specific word in a line -

i'm trying write script 2 different things: picks random word , causes "jump" out of line, , "turns" on word. turn, mean picks random word , prints same number of characters word beneath it, , nothing else, so: this thing typing sdfas wertq wsvsd swefs this mean making "jump" out of line: thing typing my problem cannot figure out how "print [x] number of characters under x" here code, below: import random import sys s = open('sonnets.txt') counting = 0 line in s: line.strip() randomint = random.randint(1,100) counting = counting+1 words = line.split() test = 1 if (randomint < 2*counting): if (len(words) > 0): r = random.choice(words) if r in line: ind = line.index(r) wordchoice = len(r) print ((" " * (ind))+r).upper() whitespac

java - Variable might not have been initialized -

here am, thinking know java, , error variable 'storage' might not have been initialized . here code: public class robbleset { private final set<robble> storage; // error occurs here public robbleset() { storage = new hashset<robble>(); } public addrobble(robble r) { storage.add(r); // error occurs here } } storage initialized in constructor. gives? one problem you're not declaring return type addrobble ; need change this: public addrobble(robble r) { to this: public void addrobble(robble r) { i suspect the problem — compiler thinks addrobble misnamed constructor, complaining fails initialize storage — if turns out it's not the problem, it's a problem.

Learning Haskell: confusion with reverse function and recursion -

i've started learn haskell , trying write simple function takes list of strings , reverses each string in list: revcomp :: [string] -> [string] revcomp [] = [] revcomp [x] = [] ++ [reverse x] revcomp (x:xs) = revcomp [xs] when try load code in ghci, error: couldn't match expected type `char' actual type `[char]' expected type: string actual type: [string] could explain , problem is? much. the first 3 lines fine. type signature correct, second line correct, , third. (however, [] ++ [reverse x] same [reverse x] .) the fourth line, however, wrong. not not use x @ on right-hand side, have type error: revcomp [xs] calls revcomp single-element list has xs element. here, x first element of list, , xs rest of list. so, since xs has type [string] , [xs] has type [[string]] , revcomp takes [string] ! want reverse x , , prepend result of reversing rest of list. you can use revcomp xs reverse each string in rest of list, , (:) prepend value l

After update, Glassfish 3.1.2-23 fails on startup. 3.1.1 works fine -

i updated 3.1.2-23 today , thing won't start. it's brand new install , 3.1.1 worked fine. have uninstalled 3.1.2 , re-installed 3.1.1 distribution exe, , works again. made no other changes. i'm stumped. anyway, here's error after typing asadmin start-domain domain1 . ideas? launching glassfish on felix platform waiting domain1 start ..[#|2012-03-07t18:00:52.189-0600|info|glassfish3.1.2|com.sun.enterprise.server.logging.gffilehandler|_threadid=1;_threadname=main;|running glassfish version: glassfish server open source edition 3.1.2 (build 23)|#] [#|2012-03-07t18:00:52.588-0600|info|glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.services.impl|_threadid=32;_threadname=grizzly-kernel-thread(1);|grizzly framework 1.9.46 started in: 11ms - bound [0.0.0.0:7676]|#] [#|2012-03-07t18:00:52.588-0600|info|glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.services.impl|_threadid=25;_threadname=grizzly-kernel-thread(1);|grizzly framework 1.9

c++ - Printing image in receipts printer using C -

i have hengstler c56 thermal receipt printer. have been trying long time print logo printer. not able figure out how it's failing. the image trying print of * .bmp type , 50x50. printer api written in c , printer accepts unsigned char byte array write buffer. any ideas done? record image #1: fwrite("\x1d\x26\x01\x01\x08\x00" "\x00\x66\x66\x00\x00\x42\x3c\x00", 1, 14, printer_stream); print image #1 double width , double height: fwrite("\x1d\x27\x01\x03" 1, 4, printer_stream); i tried make data nice bit 7 6 5 4 3 2 1 0 .. .. .. .. .. .. .. .. 00 .. ## ## .. .. ## ## .. 66 .. ## ## .. .. ## ## .. 66 .. .. .. .. .. .. .. .. 00 .. .. .. .. .. .. .. .. 00 .. ## .. .. .. .. ## .. 42 .. .. ## ## ## ## .. .. 3c .. .. .. .. .. .. .. .. 00

objective c - Im using a simple search display controller -

i'm using simple search display controller. i'm getting error have no idea. here code plsss n thanks!!!!! - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { nsinteger rows = 0; if([tableview isequal:self.searchdisplaycontroller.searchresultstableview]) { rows = [self.searchresults count]; } else { rows = [self.allitems count]; } return rows; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"cell"]; if([tableview isequal:self.searchdisplaycontroller.searchresultstableview]) { cell.textlabel.text = [self.searchresults objectatindex:indexpath.row]; } else { cell.textlabel.text = [self.allitems objectatindex:indexpath.row]; } return cell; nslog(@"the contents of cell :%@",cell.tex

php - $.post not working when element dropped -

i'm teaching myself jquery , php , i'm having few problems. need element id posted php script once dropped on droppable div. following code not post when drag , drop element on droppable div. have tried following: i have removed apart alert box check item has been dropped does, item being seen droppable!. i have entered content div manually ensure results can been seen i have replaced name var name="test", test varible contents. the javascript file , php script reside in same directory, file names correct. javascript drag , drop script included after droppable area <script type="text/javascript" src="js/drag-drop.js"></script> i have replaced result of php script plain text see if problem variable received, nothing returns. post not seem getting php script. hope can provide few pointers! below code, html div. $(document).ready(function() { $('#carousel-ul li').draggable({ helper: 'clone',

git - How can I copy the tree of a particular commit to a non-working folder? -

this question has answer here: do “git export” (like “svn export”)? 29 answers i have local git repository , want copy of files particular revision folder outside of working directory. assuming single command. i'm missing obvious, can't life of me work out. thanks, lj simplest way: git_work_tree=../other/path git checkout -f <hash> -- *

CakePHP: Models in AppController -

i've created function in appcontroller sendemails: protected function sendemail($studentid = null, $courseid = null, $action = null) { $course = $this->course->find('first', array('conditions' => array('course.id' => $courseid))); if(! $course) { throw new notfoundexception(__('invalid course')); } } i want verify course , student, depending on controller call from, have modify $this->xxx->find statement. other solution i've came validating/sending $course/$student data head of time, i'd still run manual sql query save email log (i'd run same problem). help? i don't understand problem, but: if it's ok, or not, tel me.. come new ideea based on code. don't database structure, think works join query... $course = $this->course $student = $this->student if(!empty($student) && !empty($course)): $status = 3 endif; if(empty($student)): $status1 = 1 else:

visual studio 2010 - Managing Multiple web.config files for an MVC3 Azure application -

i have asp.net mvc 3 application running on azure. uses sql azure database. i want deploy application different instances (testing, demo, multiple productions) , each instance needs it's own unique sql database. i know new azure tools update, able manage multiple service configurations. great , solve problem. issue sql connection strings in web.config files in mvc part of project. i want exact same functionality multiple service configurations feature, sql connection strings. thanks help!! .net configuration transformations should job. azure service configurations, separate web.configurationname.config file created each instance want deploy to. building solution proper configuration (testing, demo, etc.) insert correct "instance" config values web.config.

ios - Is it necessary to develop an iPhone Native App with session token controlling at server-side? -

hello , everybody. i developing iphone native app(including webview in it) communicate server-side webservice. system has user management module user login/out, chanage theirs own information. come usual cases such web site, there must token or else security consideration. iphone native app? because webservice access app think secure enough, necessary implement @ session token way? thanks, best regards. how going identification/authentication without token? i believe when enter user/password authentication pair + device_id sent (using ssl) server, in case of successful authentication server returns session token (session unlimited time, you) device_id. login , token saved somewhere in program (e.g. in defaults key/value storage). password should never saved anywhere in program. when user launches app, app sends login, token , device_id server, server checks , ok+session_key or nok. in case of nok delete login , token app's storage , display login form again

c# - is this possible to create subdirectory in FTP using ftp.MakeDirectory? -

i have create query answer before change code.pardon me if question doesn't make sense guys. scenario 1: string path :ftp://1.1.1.1/mpg/test"; ftpwebrequest requestdir = (ftpwebrequest)ftpwebrequest.create(new uri(path)); requestdir.credentials = new networkcredential("sh","se"); requestdir.method = webrequestmethods.ftp.makedirectory; using same code create directory structure connect local filezilla ftp server job---works fine. scenario 2: used above code connect remote ftp server same job throws exception : error 550 no file found or no access. question 1 : have full permission read/write folder,if not permission issue,what else have keep in mind ? question 2 : if modified code step1: make"mpg" direcotry first step2: make"test" directory after that,works fine mean ftp.makedirectory won't support create subdirectory in main dir ? if that's case how created in local ftp server ? any appreciated. thanks in

php - Why do we close result in Mysqli -

why closing $result $mysqli = new mysqli("localhost", "root", "root", "test"); if ($mysqli->connect_errno) { echo "failed connect mysql: " . $mysqli->connect_error; } if ($result = $mysqli->query("select * user")) { while ($row = $result->fetch_object()) { //var_dump($row); } $result->close(); } your check if connection failed falls through code uses connection. won't work because it's not live connection. make sure if connection fails, code depends on not reached. (note i'm not necessary advocating use of exit or die. can make rather bad user experience. can useful, ideally should output better message , leave ugly error stuff logs [unless you're testing or it's command line script]). as close() (which alias free()): free() deallocates of stuff attached result. need understand there 2 (simpli

objective c - Requesting http://mobile.twitter.com on UIWebView -

i've been trying insert little webview (320x480) inside ipad app, simulate little "iphone screen" displaying mobile twitter. but, every time uiwebview gets nsurlrequest load http://mobile.twitter.com , app automatically gets ripped off screen, , ios opens twitter ipad. is there way change behavior? here's i'm doing: uiwebview *viewdotwitter = [[uiwebview alloc] initwithframe:cgrectmake(0, 0, 320, self.view.bounds.size.height)]; viewdotwitter.autoresizingmask = uiviewautoresizingflexibleheight; viewdotwitter.scalespagetofit = yes; [rootview insertsubview:viewdotwitter atindex:0]; [viewdotwitter loadrequest:[nsurlrequest requestwithurl:[nsurl urlwithstring:@"http://mobile.twitter.com"]]]; edited: ok, found solution, here: http://www.mphweb.com/en/blog/easily-set-user-agent-uiwebview uiwebview *viewdotwitter = [[uiwebview alloc] initwithframe:cgrectmake(0, 0, 320, self.view.bounds.size.height)]; viewdotwitter.autoresizingmask = uiviewau

php - having issues to validate form using JavaScript -

on form when enter email address correctly , leaves name field blank, page submitting , javacript not running. otherwise working fine. please me solve javascript. function validateform(data) { var validfield = ""; var namevalid=/^[a-za-z ]+$/; if(data.name.value == ""){validfield += "- please enter name\n";} else if(data.name.value.search(namevalid)==-1){validfield += "- entered name contains numbers or symbols\n";} if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(data.email.value)){ return true; } validfield += "- please enter valid e-mail address\n"; alert(validfield); return false; } <form name="data" onsubmit="return validateform(this);" action="some.php" method="post"> <div> <label>name:</label><input type="text" id="name" name="name" size="20" maxl

windows 7 - Issue with Rad Studio - Delphi 2010 IDE -

rad studio 2010 (delphi 2010) on windows 7 (64 bit) laptop. im going alot of negatives on one, cause can't seem figure out how word question title or question itself......but here goes i started issues code not running within rad studio (delphi) 2010. have been days trying figure out why. working 1 installed package after another, trying decide if culprit or not. after uninstalling packages, , uninstalling entire rad studio (and re-installing rad-studio), can't seem figure can causing delphi ide act does. cleaned registry of things related component package , rad studio (before re-installing rad studio). ok, fresh copy of rad studio installed try write simple procedure tform1.button1click(sender: tobject); begin if opendialog1.execute begin showmesage(opendialog1.filename); end; end; it compiles, , builds fine without errors, however, when run application , click on button, following message: project1.exe has stopped working problem caused program stop w

c++ - What is the most efficient way of logging very small amount of data? -

suppose logging 1 integer when function called in multi-threaded environment, best design implement mechanism ? example: void foo1 () { log(1); ... } void foo2 () { log(2); ... } following possible ways: simply log file using fprintf() . problem : isn't expensive operation call function log 1 integer ? correct me if wrong. store logged integers array buffer; , flush periodically file. problem : if thread crashes, process stop threads. possibly, may loose lot of last log info. any more suggestion efficient logging mechanism ? well, "simple" logging isn't. fprintf make jump kernel (context switch), program (also context switch). ain't fast, if speed need. you'd need very, expensive sync() make sure logging data makes disk in case of power failure. don't want go there :) i'd buffered method fastest , reasonable tradeoff between speed , reliability. i'd have buffer, synchronized safely written multiple threads. conc

iis 7 - ISAPI_Rewrite 3 doesn't work on a new website on IIS7 -

a number of programmers work have isapi_rewrite 3 set-up on local machines iis7 , works extremely well. i've created new website , isapi_rewrite 3 works there no issues. colleague of mine did same thing (added third website iis7) , new website doesn't seem want use .htaccess file. i've checked make sure virtual folders set-up correctly , iuser , system users have proper access rights. i wondering if there might have missed? this doesn't answer getting v3 work, had similar issue @ client, , solution seems helicon tech recommends upgrading helicon ape on iis7. did without trouble, since v3 rules same. we did have add/uncomment setting http_x_rewrite_url server variable work. see http://www.helicontech.com/forum/15523-how_do_i_get_http_x_rewrite_url_using_ape.html

makefile - How to undo intermediate file deletion -

i have software stack creates intermediate files part of build process. there problem come , build breaks. want have @ intermediate generated files. surprise files being deleted part of build process. removing intermediate files... rm fact_test_without_proxies.c fact_test_main.c fact_test_without_proxies.o i went through makefiles don't see explicit rules deleting them. can there implicit rules delete intermediate files. if yes how can disable implicit rules ? i see print removing intermediate files... if make executed --debug option. skmt@tux:~/coding/factorial/ut$ make --debug gnu make 3.81 copyright (c) 2006 free software foundation, inc. free software; see source copying conditions. there no warranty; not merchantability or fitness particular purpose. program built x86_64-pc-linux-gnu reading makefiles... updating goal targets.... file `check' not exist. file `test_dept_run' not exist. file `fact_test' not exist. file `fact_using_prox

java - Play Framework: Rendering custom JSON objects -

i using play framework 1.2.4 java , using jpa persist database objects. have several model classes rendered json. problem customize these json responses , simplify objects before rendering json. for instance, assume have object named complexclass , having properties id, name, property1,...,propertyn. in json response render id , name fields. what elegant way of doing this? writing custom binder objects or there simple json mapping such using template? use flexjson, it's easy. allows create jsonserializers can include/exclude fields want. check out this article examples of using play! framework. here's simple example: public complexclass { public long id; public string name; // , lots of other fields don't want public string tojsonstring() { // include id & name, exclude others. jsonserializer ser = new jsonserializer().include( "id", "name", ).exclude("*"); re

jQuery Fancybox - Append to fancybox-inner -

i'm working fancybox 2.0.5. have opening size of 450 x 500. content of long terms of use agreement. user must click accept button @ bottom. we'd able have stuck bottom of fancybox popup "static" regardless of scrolling. trying use below no avail. can't make .fancybox-inner respond anything. suggestions? $(".fancybox-inner").append("<input id='accept' type='button' value='accept'>"); since div thats rendering fancybox doesn't have content until load fancybox, need trigger code after fancybox has loaded: $(".fancybox").fancybox({ oncomplete: function(){ $(".fancybox-inner").append(""); } }); alternatively, tell fancybox not scroll , set overflow:auto container div inside content, , add (agree) button after

javascript - Timestamp from the web browser? -

possible duplicate: how can determine web user's time zone? how timestamp in javascript? i timestamp user web browser. example: if user comes website usa , comes spain, save respective time , date in usa , spain. just use new date().tostring() ;

c++ - How do I call an overloaded function from a function in the base class? -

i have class (b) inherits class (a). want call function class has been overridden. want able call overridden function independent of class inherited base (say class c : public a , want call c's version of function.) here's example class { public: void callf(); virtual void f() {}; }; class b : public { public: void f(); }; void a::callf() { //fyi, want able call without knowing super class is. f(); } void b::f() { std::cout << "i want function called, instead default f() called."; } edit: in real code, have std::vector<a> avector; . call avector.push_back(b()); . if called avector[0].callf(); , default a::f() called. answered below, have problem slicing. your construction: vector_of_a.push_back( b() ); doesn't store b in vector. constructs b , constructs a that, stores that a in vector. consequence, experience slicing. see more info: https://stackoverflow.com/a/4403759/8747

c - Sound string declaration hangs Arduino compiler -

i have string of characters 8 wav file i'm trying import arduino project. declare this const unsigned char sounddata_data[] progmem = "€€[fill these brackets in 6500 other characters]"; when try run code, compiler doesn't give me errors. hangs , never finishes compiling. know it's line because if declare shorter string, or other types of declaration (like putting commas between each char), works. is there line length limit in arduino code that's stopping me? if have accept , put commas between every character, there method? i write simple program it, have number of sound files convert , want make easy , simple read code. edit i ended writing program. converts each data byte int s delimited commas. still bothers me old way wouldn't work , way take more time, @ least have fall on #include <stdio.h> int main(int argc, char *argv[]) { file *r, *w; unsigned char ch; r = fopen(argv[1], "rb"); w = fopen(&quo

jqgrid - Frozen Columns in combination with Toolbar Searching, do not work well -

frozen columns in combination toolbar searching, not work well. please verify at: please help. in code example call filtertoolbar after calling of setfrozencolumns , did nothing describe in my answer . described steps need after toggletoolbar . same action have after filtertoolbar . a recommend better call filtertoolbar before calling of setfrozencolumns .

android - How to Control Media Sound with Phonestatelistener in my Radio App -

can me implement phonestatelistener control media sound of app on incomming call , during call ? if calling , i`m listen radio station app, want mute current sound. best solution me "mute" sound during call , not stop. so far i've found out need phonestatelistener , telephonymanager . in androidmanifest.xml <uses-permission android:name="android.permission.read_phone_state"/> and <intent-filter> <action android:name="android.intent.action.phone_state"/> </intent-filter> what have , put myradio.java ? package com.radiob.myradio; import android.app.activity; import android.app.alertdialog; import com.google.ads.*; import com.spoledge.aacplayer.aacfilechunkplayer; import com.spoledge.aacplayer.aacplayer; import com.spoledge.aacplayer.arrayaacplayer; import com.spoledge.aacplayer.arraydecoder; import com.spoledge.aacplayer.decoder; import com.spoledge.aacplayer.history; import com.spoledge.aacplayer.playercallb

c# - Astar algorithm goes in endless loop -

i working on a* search algorithm , followed this: a* search algorithm using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using mapdata.interfaces; namespace mapdata.algorithm { public class astar { idmap map; list<location2d> openset; list<location2d> closedset; list<location2d> path; dictionary<location2d, double> g_scores; dictionary<location2d, double> h_scores; dictionary<location2d, double> f_scores; dictionary<location2d, location2d> came_from; int[] arrayx = { 0, -1, -1, -1, 0, 1, 1, 1 }; int[] arrayy = { 1, 1, 0, -1, -1, -1, 0, 1 }; /// <summary> /// initing algorithm mapinfo /// </summary> /// <param name="map">dmap info.</param> public astar(idmap map) { this.map = map; } /// <