Posts

Showing posts from June, 2014

javascript - Regular expression for excluding file types .exe and .js -

i using jquery file upload plugin, giving value option accept files need regular expression tells file types restricted. need restrict both exe , js achieved using below expression (\.|\/)(!exe|!js)$ but expression not allowing other files tried adding 1 extension below (\.|\/)(!exe|!js|pdf)$ with above regular expression accepting pdf , not accepting exe , js. need enable file extentions except exe , js. difficult add extensions expression. can mention how in expression accept other filetypes except exe , js in similar format above. regular expression js. thanks, vinay this exclude .js , .exe @ end of string, allow else: /^[^.]+$|\.(?!(js|exe)$)([^.]+$)/ broken down: ^[^.]+$ matches string no dots \.(?!(js|exe)$)([^.]+$) matches dot if not followed js or exe @ end of string. the following allowed: something.js.notjs somethingelse.exee /something.js/foo the following not allowed: jquery.js outlook.exe note: excluding file extens

post - Yii postback value for dropdownlist -

like described in title, i' trying use dropdownlist post page. post receive in controller value selected empty. here dropdownlist <?php echo chtml::dropdownlist('groupe',$groupe, array("a"=>"a","b"=>"b","c"=>"c","d"=>"d","e"=>"e","f"=>"f","g"=>"g","h"=>"h"), array( 'prompt'=>'--choisir un groupe--', 'submit'=>ccontroller::createurl('classement'), //'data'=>array('groupe'=>'js:this.value'), )); ?> and here controller public function actionclassement($groupe="") {echo $groupe; if(isset($_post['groupe'])){echo $_post['groupe']."ici=".$groupe; $groupe = $_post['groupe']; }echo 'test'; $model = team::model()

ios - How to format the layout of an NSDate without converting to NSString -

i'm looking change way date object being put nsdictionary currently, date object being entered in following format: 2014-04-22 17:28:47 +0000 however i'd entered as 22-04-2014 i tried using nsdateformatter i've used it's put string nsdateformatter *formatter = [[nsdateformatter alloc]init]; [formatter setdateformat:@"dd-mm-yyyy"]; nsstring *thedate = [formatter stringfromdate:date]; how achieve changing layout yyyy-mm-dd hh:m:ss ???? dd-mm-yyy maintain date object? after having discussion op, been concluded following go long way in achieving desired result. create new class looks this //fooditem . h nsstring *fooditemname; nsstring *fooditemdate; //you can add more stuff calorie intake etc //have custom init method -(id)initnewfooditemname:(nsstring*)name withdate:(nsstring*)dateinput; //then in //fooditem.m //make sure synthesise properties above. -(id)initnewfooditemname:(nsstring*)name withdate:(nsstring*)dateinput{

java - How to avoid HTTP Status 415 when sending ajax request to the server? -

i have ajax call should return json document function getdata() { $.ajax({ url: '/x', type: 'get', data: "json", success: function (data) { // code omitted } }); } my server side simple. @requestmapping(value = "/x", method = get, produces = "application/json") public @responsebody list<employee> get() { return employeeservice.getemployees(); } but request can't controller. error is: http status 415 - server refused request because request entity in format not supported requested resource requested method. how can fix it? add @consumes("text/html") before code in server side, @consumes("text/html") @requestmapping(value = "/x", method = get, produces = "application/json") public @responsebody list<employee> get() { return employeeservice.getemployees(); }

node.js - angularjs ng-include not showing file -

i'm trying implement basic node-express angular app includes ng-include directive. this structure of app: app: server.js package.json public: js css index.html partials: header.html partial-about.html partial-homt.html the content of server.js following: var express = require("express"); var app = express(); var port = process.env.port || 8080; app.configure(function () { app.use(express.static(__dirname + "/public")); app.use(express.logger("dev")); }); app.listen(port); console.log("app listening on port: " + port); this content of index.html: <html lang="en"> <head> <meta charset="utf-8"> <title>angularjs uirouter demo</title> <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"> <link rel="stylesheet" href="./css/style.css"> <script s

ios - Where does filterContentForSearchText:scope: method come from? -

recently, noticed filtercontentforsearchtext:scope: appeared in multiple tutorials regarding how implement search bar. however, looked references of both uisearchdisplaydelegate , uisearchbardelegate . found filtercontentforsearchtext:scope: neither required nor optional method. i wondered if filtercontentforsearchtext:scope: conventional method name filtering search results? yes, convention common method called uisearchdisplaydelegate methods - (bool)searchdisplaycontroller:(uisearchdisplaycontroller *)controller shouldreloadtableforsearchstring:(nsstring *)searchstring; - (bool)searchdisplaycontroller:(uisearchdisplaycontroller *)controller shouldreloadtableforsearchscope:(nsinteger)searchoption; the current "simple uisearchbar state restoration" sample project apple not use convention: - (bool)searchdisplaycontroller:(uisearchdisplaycontroller *)controller shouldreloadtableforsearchstring:(nsstring *)searchstring { nsstring *scope; nsi

django - Success variable message is assigned referenced before assignment -

i'm trying show success message after posting data on form. def addcostumer(request): form = costumerform(request.post or none) if form.is_valid(): save_it = form.save(commit=false) save_it.save() message = "data sent!" return render_to_response('nuevocliente.html', {'message': message}, context_instance=requestcontext(request),) you need check if request indeed post , show message if form submitted indeed valid. also, looks forgot send actual form in context. def addcostumer(request): form = costumerform() message = none #set message none default if request.method == 'post': form = customerform(request.post) if form.is_valid(): save_it = form.save(commit=false) save_it.save() message = "data sent!" #set message if object saved successfully. return render_to_response('nuevocliente.html', {'message

database - Failed to read row 0, column 1 from a CursorWindow (Android) -

i have created table players in oncreate() method in mysqlitehelper.java: string create_players_table = "create table players (id integer primary key autoincrement, name text, password text, score integer)"; db.execsql(create_players_table); and have update method in same class like: public int playerupdate(player pl) { // 1. reference writable db sqlitedatabase db = this.getwritabledatabase(); // 2. create contentvalues add key "column"/value contentvalues values = new contentvalues(); values.put("name", pl.getname()); values.put("password", pl.getpassword()); values.put("score", pl.getscore()); // 3. updating row int = db.update(table_players, // table values, // column/value key_id + " = ?", // selections new string[] { string.valueof(pl.getid()) }); // selection args // 4. close db.close(); return i; } and when call func

mysql - Exception while dropping database in JavaFX -

private void delete() throws classnotfoundexception, sqlexception { class.forname("com.mysql.jdbc.driver"); connect = drivermanager .getconnection("jdbc:mysql://localhost:3306/delete?" + "user=root&password=virus"); statement = connect.createstatement(); preparedstatement = connect .preparestatement("drop database delete"); preparedstatement.executeupdate(); preparedstatement = connect .preparestatement("create database delete"); preparedstatement.executeupdate(); } this code delete database in javafx. when ran code gives me exception. details - com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception: have error in sql syntax; check manual corresponds mysql server version right syntax use near 'delete' @ line 1 @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newi

r - Get "embedded nul(s) found in input" when reading a csv using read.csv() -

i reading in csv file. code is: mydata = read.csv("mycsv.csv", header=true, sep=",", quote="\"") get following warning: warning message: in scan(file = file, = what, sep = sep, quote = quote, dec = dec , : embedded nul(s) found in input now cells in csv have missing values represented "". how write code not above warning? your csv might encoded in utf-16. isn't uncommon when working windows-based tools. you can try loading utf-16 csv this: read.csv("mycsv.csv", ..., fileencoding="utf-16le")

c++ - I am having an issue storing a character in a pointer to a structure. -

string* substr(string* str, int start, int end) { string* substr = new string; for(int = start; < end; i++) { substr = str->text[i]; } return substr; } //the problem in substr method. substr supposed store part of string separated delimiter. since substr pointer object of string struct, should point object's array of chars. this: string* substr(string* str, int start, int end) { string* substr = new string; for(int = start; < end; i++) { substr->text[i] = str->text[i]; // char = char } return substr; } depending on way handle array of chars, might face further problems size of it.

code snippets - Vim-snipMate doesn't expand insted removes the trigger -

i using snimpmate vim-snippets plugin, , fine. until tried remove vim-snippets , use custom , snippets 'ruby.snippets' on '.vim/snippets'. think snippets being loaded when fire tab or whatever trigger removes text... , leave blank space. def hello if |tab| end results in def hello end is same problem here you provide little information troubleshooting. here's 1 function (from snippetcompletesnipmate plugin ) lets access defined snippets: to able access snippets, snipmate must patched. open ~/.vim/plugin/snipmate.vim , insert following function @ bottom: fun! getsnipsincurrentscope() let snips = {} scope in [bufnr('%')] + split(&ft, '\.') + ['_'] call extend(snips, get(s:snippets, scope, {}), 'keep') call extend(snips, get(s:multi_snips, scope, {}), 'keep') endfor return snips endf you can check snippets defined current buffer via :echo keys(getsnipsincurrent

php - Read the form field type after the submit? -

using php, after form has been submitted via "post"... i trying detect if input type hidden. fyi: each hidden input has different name , different id. example: <input type="hidden" id="uniqueid1" name="somename1" value="99" /> any suggestions welcome. do this: assign fields array names. <input type="hidden" id="uniqueid1" name="hidden[somename1]" value="99" /> after form submit, in php. <?php if (! empty($_post)) { foreach ($_post $k => $v) { if ($k == 'hidden') { // here if field hidden one. if (! empty($v)) { foreach ($_post $hidname => $hidvalue) { } } } } } ?>

tcp ip - TCP/IP server/client multiconnection using C# and receiving public ip address of client -

i need write application using c#, connect client server static ip address. the server , clients must able send , receive message @ same time. also, need log information respect of clients public address well. how can make using c#? shall use tcplistener / tcpclient or there other method can make multiple connections? if want go low level tcp/ip , own message parse/serialize/deserialize, can use socketasynceventargs high performance code, not easy tcplistener/tcpclient. http://msdn.microsoft.com/en-us/library/vstudio/system.net.sockets.socketasynceventargs http://www.codeproject.com/articles/83102/c-socketasynceventargs-high-performance-socket-cod question is, why not use example wcf/iis ?

objective c - ideal way for detecting collisions in sprite kit? -

-(void)handlecontact:(skphysicscontact*)contact{ nsarray *nodenames = @[contact.bodya.node.name, contact.bodyb.node.name]; if ([nodename containsobject:player] && [nodename containsobject:window] { //player , windows defined strings set in skspritenode names window } else if ([nodename containsobject:player] && [nodename containsobject:door]) door } //continue 10 times different defined strings except player } would sort of code ideal collision detection or there better way can face this?

testing - How to compile and run QTP script from command line -

i want use text file containing source code of qtp script, , compile (create usr,cfg,usp etc files created when manually "save" script in qtp) using command line. there way both? all files in qtp/uft when you're doing "more" writing script. stores test description, associated repositories, parameters, recovery scenarios, etc. if you're writing test logic in text file, there's chance you're not using of stuff either. take blank qtp/uft test create "template" of valid test. have replace 'action1/script.mts' file contents of text file. if want of command-line, you'll need write simple console-based application heavy lifting you.

jquery - Order DIV's by Value Username Value within -

i have following dom structure. each 'contactsbodymaindisplaymembercontainerdiv' shows member photo, name etc. i need able re-order these containerdiv's h2 username z. so below need move 'contactsbodymaindisplaymembercontainerdiv' pieces of dom it's ordered adam, bob, eric. note: need move whole piece of dom each user. <div id="contactsbodymaincontainerdiv"> <div class="contactsbodymaindisplaymembercontainerdiv"> <div class="contactsbodymaindisplaymemberwrapperdiv"> <h2 class="contactsbodymaindisplaymemberusernameh2">eric</h2> </div> </div> <div class="contactsbodymaindisplaymembercontainerdiv"> <div class="contactsbodymaindisplaymemberwrapperdiv"> <h2 class="contactsbodymaindisplaymemberusernameh2">adam</h2> </div> </div> <div class="contactsbodymaindisplaymembercontainerdiv&q

cordova - Phonegap heading example code not working -

i completly new 'phonegap'. have tested example code displays current heading , works in local ripple emulator. however when deploy android not work? nothing , no error written page. the following code should display compass heading screen: <!doctype html> <html> <head> <title>compass example</title> <script type="text/javascript" charset="utf-8" src="phonegap-1.0.0.js"></script> <script type="text/javascript" charset="utf-8"> // wait phonegap load // document.addeventlistener("deviceready", ondeviceready, false); // phonegap ready // function ondeviceready() { navigator.compass.getcurrentheading(onsuccess, onerror); } // onsuccess: current heading // function onsuccess(heading) { document.write('heading: ' + heading); } // onerror: failed heading // function onerror() { document.write('error'); } </script> </head>

python - What is wrong with this ternary operator? -

for in str1: (newstr += chr(ord(i)+2)) if i.isalpha() else (newstr += i) it seems grieving += operator. know both variables strings though, don't understand why not concatenate them try following: for in str1: newstr += (chr(ord(i)+2) if i.isalpha() else i) edit : from python documentation : conditional_expression ::= or_test ["if" or_test "else" expression] expression ::= conditional_expression | lambda_expr and pointed @flornquake, assignment var += value statement, not expression.

r - Running multiple regressions is there a smart way to vectorize -

i have written believe semi-quick ols-regression function ols32 <- function (y, x,ridge=1.1) { xrd<-crossprod(x) xry<-crossprod(x, y) diag(xrd)<-ridge*diag(xrd) solve(xrd,xry) } now want apply following (vapply(1:la, function(j) me %*% ols32((nza[,j]),(cbind(nzaf1[,j],nzaf2[,j],nza[,-j],momf))) [(la+2):(2*la+1)],fun.value=0)) where nza,nzaf1,nzaf2 , momf 500x50 matrixes , la=50 , me vector of length 50. do regression use beta-coefficients momf multiply me. nza.mat<-matrix(rnorm(500*200),ncol=200) nza<-nza.mat[,1:50] nzaf2<-nza.mat[,101:150] momf<-nza.mat[,151:200] nzaf1<-nza.mat[,51:100] me<-nza.mat[500,151:200] is there imediate way of making things faster or need use someting rcppeigen? tks p so came faster way of solving rewriting ols-function calculates 2 crossproducts once whole matrix. new function looks this: ols.quick <- function (y, x, me) { la<-dim(y)[2] xx.cross<-crossprod(x) xy.cross<-crossprod(x, y) diag(xx

c# - Copy file into different folder directory name -

i create code copy don't know how combine copy code if filename not in jpeg , bmp , png or gif copy different folder name( c:\dump ) if filename extension exists file copy ( c:\destionation ). public static void copyfile( string[] args ) { copyfolder( @"c:\source", @"c:\destination" ); console.readline(); } static public void processdirectory(directoryinfo directory) { foreach (fileinfo file in directory.enumeratefiles("*.jpg,*.bmp,*.png,*.gif,*.jpeg")) { //how combin process directory info copy folder statement// } } static public void copyfolder( string sourcedir, string destfolder ) { if (!directory.exists( destfolder )) directory.createdirectory( destfolder ); string[] files = directory.getfiles( sourcedir ); foreach (string file in files) { string name = path.getfilename( file ); string dest = path.combine( destfolder, name ); file.copy( file, dest); } }

vb.net - Project to project reference - type not CLS compliant -

i have problem regarding public declaration in 1 project makes reference class in different project. the parent project references dependent project without problem. however, i'm getting warning type member 'user' not cls-compliant. it's declared public user user this declaration made in parent project. user class in supporting project can use type on form without fail. now, try pass off on form - in parent project: private olduser user olduser = frmusermgt.user and thing crashes. stepping through code shows olduser nothing. i built brand new solution , tested exchange without fail. i've searched solution , project settings until i'm blue in face , can't find difference. it's vs2012 vb solution. can post code needed if above description isn't sufficient - appreciated.

Modify Get Request of a Kendo UI treeview -

i'm having trouble kendo ui treeview, displays same node each time click go deeper tree. my problem regular request looks this: something/getchildren/3432fdsf8989/apr222014083453am when click next node request looks this: something/getchildren/3432fdsf8989/apr222014083453am?identifier=2323eded7664 and want have this: something/getchildren/2323eded7664/apr222014083453am is possible change url kendo ui hierarchicaldatasource? web service ignoring identifier , still using initial id. function inittreeview(date, targetid) { var requesturl = "something/getchildren/"+ targetid + "/" + date; var datasource = new kendo.data.hierarchicaldatasource({ transport: { read: { url : requesturl, datatype : "json" } }, schema: { model: { id: "identifier", haschildren: true, //all items may have children } } }); $("#treeview").ken

ios - How to retrieve list id by list name in Twitter API -

i've call twitter api's method https://api.twitter.com/1.1/lists/statuses.json?list_id=12345 to retrieve tweets user in list. customer provide me name of list , i've no idea how list id using list name. list this: https://twitter.com/datasportnews/lists/i-campioni-di-brasile2014 . i've tried method https://api.twitter.com/1.1/lists.json?screen_name=i-campioni-di-brasile2014 to id list return message {"errors":[{"message":"your credentials not allow access resource","code":220}]}. i'm logged api key , api secret , token well, method doesn't work. ideas ? the list name in url referred slug. when want request statuses list using slug , need pass owner_screen_name . for example, in case: /1.1/lists/statuses.json?slug=i-campioni-di-brasile2014&owner_screen_name=datasportnews more details on over endpoint's doc page @ https://dev.twitter.com/docs/api/1.1/get/lists/statuses

c# - Must manually close StreamWriter in Usings? -

at 2nd iteration, "file being used" error occurs @ "using (streamwriter" line. though streamwriter supposed auto-close after going out of usings. edit 1: real code note: mails list<mailmessage> (instantiated from/to addresses) foreach (var x in mails) { x.subject = "updated google exchange rates (" + datetime.now.tostring(new cultureinfo("en-us")) + ")"; stringbuilder emailbody = new stringbuilder(); emailbody.appendline("abc"); //<-- simplified x.body = emailbody.tostring(); _txtname = x.subject.replace(...); //replaces invalid file-name chars //note _txtname unique due x.subject's dependency on datetime using (streamwriter sw = new streamwriter("./exchange rate history/" + _txtname)) {

c# - Clicking on Html.ActionLink refreshing the layout view -

i have mvc 3 project created default template in visual studio. in project in layout view added dropdownlist using view , html.action like in _layout.cshtml @html.action("index", "ddldept") in index.cshtml of ddldeptcontroller.cs @model passingvaluesinviews.models.ddldeptviewmodel @html.dropdownlistfor(m => m.selecteddeptid, new selectlist(model.depts, "id" , "deptname")) when run project , click on 1 of default links home controller <li>@html.actionlink("home", "index", "home")</li> the page refreshed , whatever selected in dropdownbox cleared , default valued selected again. why dropdownbox refesh , how prevent that. my objective have common dropdown box couple of views. thanks help. @html.actionlink refresh page. same action occur if clicked on link generated traditional tags. if needed reload small section, you're looking ajax call via @ajax.actionlink.

ios - Set button title programatically -

i made button in storyboard , associated ibaction in header file. how can set title of button variable made displayphone , have call number well? .h #import <uikit/uikit.h> #import <parse/parse.h> @interface ibthirdviewcontroller : uiviewcontroller @property (nonatomic, strong) pfrelation *agentrelation; @property (nonatomic, strong) nsarray *agent; @property (weak, nonatomic) iboutlet uilabel *agentname; @property (strong, nonatomic) iboutlet uilabel *agentphone; @property (strong, nonatomic) iboutlet uilabel *agentemail; @property (strong, nonatomic) iboutlet uiimageview *agentimage; - (ibaction)phonebutton:(id)sender; @end .m #import "ibthirdviewcontroller.h" #import "ibagentstableviewcontroller.h" @interface ibthirdviewcontroller () @end @implementation ibthirdviewcontroller - (void)viewdidload { [super viewdidload]; } - (void)viewdidappear:(bool)animated { [super viewdidappear:animated]; //find agent ,

Python Change Button Image and change it back -

so have code changes image of button when clicked. now, if wanted have button change when clicked , return normal? (like normal button) can't add .config method skip first 1 , keep button same image. can not wait freezes program , produces same result. playup = photoimage(file=currentdir+'\up_image.gif') playdown = photoimage(file=currentdir+'\down_image.gif') #functions def playbutton(): pbutton.config(image=playdown) return #play button pbutton = button(root, text="play", command=playbutton) pbutton.grid(row=1) pbutton.config(image=playup) the best way make button image change real button press images this. define photos: playup = photoimage(file=currentdir+r'\up_image.gif') playdown = photoimage(file=currentdir+r'\down_image.gif') define functions: def returncolor(): pbutton.config(image=playup) def playbutton(): pbutton.config(image=playdown) pbutton.after(200,returncolor) initialize button:

performance - Javascript memory leak setTimeout issue -

Image
does 1 know why memory consumption stays constant here ? var count = 0; $(init); function init(){ var node = document.queryselector('.logs'); function check(){ var uarr = new uint16array(100); log(node, uarr.length); settimeout(check,100); } settimeout(check,100); } function log(node, text){ if( count % 30 == 0 ){ node.innerhtml = ''; } var child = document.createelement('div'); child.innertext = 'count ' + (count++) + " arr len " + text; node.appendchild(child); } http://jsfiddle.net/v99eb/11/ reason why should linearly increase memory allocation is: 'check' method calls inside it's definition, closure variables available inside check method execution, again creates execution context test function , on. also, in every execution, create memory block of uint16array, believe allocated in heap, , should never de-allocated since reachabl

git - how to make a flag in shell cli app -

i rewriting old git plugin made ( git-build ) has 2 commands want turn 1 command --flag run() { require_clean_work_tree rebase "please commit or stash them." source git-build.sh git add . git commit -m 'build $version' git tag $version } run-deploy() { require_clean_work_tree rebase "please commit or stash them." source git-build.sh git add . git commit -m 'build $version' git tag $version git push -tags } i wish have run-deploy turn run --deploy . unless there special magic involved git plugins that's simple as run() { require_clean_work_tree rebase "please commit or stash them." source git-build.sh git add . git commit -m 'build $version' [ "$1" = '--deploy' ] && git tag $version }

ios - IBOutletCollection for UITextView -

can please tell me steps in interfacebuilder connect set of uitextview objects iboutletcollection? in xib file (say myfile.xib) have row of 8 uitextview objects. in myfile.h file declare iboutletcollection: @property (nonatomic, retain) iboutletcollection(uitextview) nsarray *textviews; now want connect xib uitextview objects iboutletcollection. tried ctrl drag first uitextview in xib fileowner, didn't show me iboutlets. tried ctrl click (right click) on fileowner , popped little black menu. showed textviews outlet collection, tried dragging little circle textviews uitextview objects in xib, didn't anything. searched google find sort of info on this, found statements "connect uitextview iboutletcollection in usual way." don't know "the usual way" is. please help. are sure were dragging correct "little circle" text views, because works fine me. another way connect outlet opening assistant editor can see both xib file , control

android - java.lang.IllegalArgumentException: the bind value at index 2 is null -

just wondering few android devices getting below mentioned exception: caused by: java.lang.illegalargumentexception: bind value @ index 2 null @ net.sqlcipher.database.sqliteprogram.bindstring(sourcefile:237) @ net.sqlcipher.database.sqlitedatabase.updatewithonconflict (sourcefile:1794) @ net.sqlcipher.database.sqlitedatabase.update(sourcefile:1730) @ com.sample.android.sqdbhelper.onupgrade(sourcefile:276) @ net.sqlcipher.database.sqliteopenhelper.getwritabledatabase (sourcefile:123) @ com.sample.android.sqdbcontroller.read(sourcefile:431) @ com.sample.android.ui.mainactivity.oncreate(sourcefile:42) @ android.app.activity.performcreate(activity.java:5372) @ android.app.instrumentation.callactivityoncreate (instrumentation.java:1104) @ android.app.activitythread.performlaunchactivity sample code contentvalues contentvalues = new contentvalues(); contentvalues.put("col_value1", value1); contentvalues.put("col_value2", value2); contentvalues.

linux - Upgrade MySQL with Replication Master-Slave 5.0 to 5.6 -

i know on mysql website there's information , official documentation although i'm looking recipe on how-to upgrade mysql. if point blog, website or document great! details: linux (oracle linux/redhat, debian ) latest versions. upgrade map mysql 5.0 5.6. (5.0 5.1, 5.1 5.5 , 5.5 5.6) master , slave replication enviroment i appreciate information given. thank !

mysql - Getting error on executing prepared statement in PHP -

i have code follows giving me error on prepared statement line: homepage.php <html> <head> </head> <body> <ul id="list"> <li><h3><a href="#">tops</a></h3></li> <li><h3><a href="#">suits</a></h3></li> <li><h3><a href="#">jeans</a></h3></li> <li><h3><a href="newpage.php?name=women">more</a></h3></li> </ul> </body> </html> newpage.php <?php $mysqli = new mysqli('localhost', 'root', '', 'shop'); if(mysqli_connect_errno()) { echo "connection failed: " . mysqli_connect_errno(); } ?> <html> <head> </head> <body> <?php session_start(); $lcsearchval=$_get['name']; //echo "hi"; $l

javascript - HTML5 Canvas transparency for all overlapping content -

i made drawing app html5, it's basic paint/brush tool works good. problem is, don't know how make overlapping path have same opacity. i tried use globalalpha property overlap content bolder , bolder everytime draw line. ctx.beginpath(); // init @ onmousedown ctx.lineto(x, y); // @ onmousemove ctx.stroke(); // @ onmousemove edit: ok got wrong. need redraw canvas "background" before draw lines. it looks have this: http://jsfiddle.net/4namg/2/ and think want this: http://jsfiddle.net/4namg/1/ the difference in second case redraw background. since don't special clear canvas: ctx.clearrect(0, 0, c.width, c.height); edit: same example mouse button management , multi-path: http://jsfiddle.net/4namg/3/ (nb: cheated in case of single-point paths sake of clarity).

Excel VBA : Multiple lookup values -

i have 2 sheets. result needed in sheet1 required results column depicted below. results populated checking values in sheet2. noun modifier required results name1 value1 name2 value2 name3 value3 name4 value4 name4 value4 abrasive belt abrasive belt : 5in x 2in type wafer width length 5in thickness 2in diameter 2m abrasive belt abrasive belt : 11in x 6in x 3m type lugged width 11in length 6in thickness 3in diameter 3m abrasive belt abrasive belt : 12in x 7in x 3m type lugged width 12in length 7in thickness 3in diameter 4m sheet2 noun modifier attribute name fill abrasive belt type 0 abrasive belt width 1 abrasive belt length 2 abrasive belt thickness 3 abrasive belt diameter 0 abrasive rod ty

sql - MYSQL translate escaped HEX liked string to human readable -

this supposed spanish words. imported words dictonary in txt format. spanish 1 got translated these. thing cant search word. not find anything. how can convert these in mysql human readable , searchable string ? create table if not exists `es_words` ( `id` int(11) not null auto_increment, `word` varchar(255) character set utf8 collate utf8_unicode_ci not null, `user` int(11) not null, primary key (`id`) ) engine=innodb default charset=latin1 auto_increment=660099 ; insert `es_words` (`id`, `word`, `user`) values (1, 'ÿþa\0\r\0', 0), (2, '\0a\0-\0\r\0', 0), (3, '\0a\0a\0r\0ó\0n\0i\0c\0o\0\r\0', 0), (4, '\0a\0a\0r\0o\0n\0i\0t\0a\0\r\0', 0), (5, '\0a\0b\0a\0\r\0', 0), (6, '\0a\0b\0a\0b\0a\0\r\0', 0), (7, '\0a\0b\0a\0b\0i\0l\0l\0a\0r\0s\0e\0\r\0', 0), (8, '\0a\0b\0a\0b\0o\0l\0\r\0', 0), (9, '\0a\0b\0a\0c\0á\0\r\0', 0), (10, '\0a\0b\0a\0c\0a\0l\0\r\0', 0), etc i don't know many span

javascript - Highlight active (opened) link -

i want highlight active (opened) link . color must maintained time when link open. not on mouse click or hover. here js way tried: <script type="text/javascript"> $(document).ready(function(){ $("a.nav1").click(function () { $(".active").removeclass("active"); $(this).addclass("active"); }); }); </script> html links: <div id="navigation"> <ul> <li><a class="nav1" data-tab="#home" id="link-home"href="#home">home</a></li> <li><a class="nav1" data-tab="#football" id="link-football" href="#football">football</a></li> <li><a class="nav1" data-tab="#hockey" id="link-hockey"href="#hockey">hockey</a </li> </ul>

php - Generate ID based on file and line in (or something similar) -

in program need way create unique identifiers (like hash). important ids not random, same between calls same function or method. thus, if in line in file generated identifier xyz , in place should generated same identifier. i use code such instruction: $id = sha1(__file__ . __ line__); but not enough comfortable. i'd prefer use function or macro in c/c++ (i know php not have macros) follows: $id = generate_id(); the generate_id implemented below. works fine, i'm not convinced use function debug_backtrace in production code. maybe there's better solution? function generate_id() { $backtrace = debug_backtrace(); return sha1($backtrace[0]['file'] . $backtrace[0]['line']); } if intention have repeatable hash based on file, php has md5_file() method should need. $file = 'myfile.txt'; echo 'md5 file hash of ' . $file . ': ' . md5_file($file); as long file contents not change, md5 hash same each time g

javascript - Using jquery to check if element has class constantly -

i'm using stickyjs create sticky header wordpress website. have enqueued scripts , sticky working perfectly. what trying achieve check if nav element have set sticky has class called "is-sticky" , if change of css. here code have already: function stickyinit($) { $("#site-navigation").sticky({topspacing:0}); window.setinterval(check_sticky,500); function check_sticky(){ if($("#site-navigation-sticky-wrapper").hasclass("is-sticky")){ console.log ("do something"); } } } jquery(document).ready(function ($) { stickyinit($); }); this code in file have enqueued set nav sticky. as can see have used setinterval try , create loop test "#site-navigation-sticky-wrapper" element see if has class mentioned above. this code works , message in firebug console, ever once instead of repeatedly. so question is, how test element see if has class "is-sticky" can alternate nav css when does? als

Passing a total between groups in crystal reports -

group 1 = date of order group 2 = product , current on hand day1 20140423 (day 1) product 200 order 1 -20 order 2 -20 balance 160 product b 100 order 1 - 5 day 2 20140424 (day 2) product c 16 order 1 - 5 day 3 20140425 (day 3) product 160 how pass ending balance product day 1 beginning balance product day 3 pls explain in detail because novice report writer. try below approach: create formula @storevalue , write below code. local numbervar storevalue; local numbervar display; if ({date},{@group1})=20140423 , ({product},{@group2})=product a' storevalue:=//balance value of a; if ({date},{@group1})=20140425 , ({product},{@group2})=product a' display:=storevalue; else display:=//your calculation here; display; now place

arrays - plotting missing values with nan -

Image
i have plot looks hours = [0 1 2 3 4 5 6 12 13 14 15]; y = [0 1 2 nan 3 4 5 6 7 8 9]; figure(1) plot(hours, y, '-o'); as can see, x axis jumps 6 12. instead of having straight line connecting these points, have gap: hours = [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]; y = [0 1 2 nan 3 4 5 nan nan nan nan nan 6 7 8 9]; figure(2) plot(hours, y, '-o'); can done in elegant way without having manually insert nans , new 'hours' values? try - hours_new = min(hours):max(hours) nan_ind = ~ismember(hours_new,hours) y_new(~nan_ind) = y y_new(nan_ind) = nan then, plot - figure(2) plot(hours_new, y_new, '-o');

c# - FontLink with Myriad Pro in Win XP -

i have c# application running on winxp needs display symbols, i'm getting squares. did digging around , found font linking. i used arial , calibri, cannot work myriad pro. i set following in registry in hkey_local_machine–\software\microsoft\windows nt\currentversion\fontlink\systemlink (following http://msdn.microsoft.com/en-us/goglobal/bb688134 ) arial | reg_sz | segoe_ui_symbol.ttf,segoe ui symbol calibri | reg_multi_sz | segoe_ui_symbol.ttf,segoe ui symbol myriadpro | reg_multi_sz | segoe_ui_sumbol.ttf,segoe ui symbol and on myriadpro bold, bold condensed, bold condensed italic, bold italic, condensed, condensed italic, regular, semibol, semibold italic, still squares instead of characters... tried using myriad key, not work... before added entries arial , calibri had squares instead of characters, started working after added entries. what doing wrong? can not link myriad pro? thanks in advance! i managed figure wrong. apparently font

php - Combine several MySQL statements into one -

i make these 3 calls in rapid succession: update job set jstatus = '9' snum = :u , jstatus = '7' , jdate < :d delete job snum = :u , jstatus < '7' , jdate < :d delete jdate snum = :u , jdate < :d the params same each. @ present, each 1 done follows: $sth = $dbh->prepare(" update job set jstatus = '9' snum = :u , jstatus = '7' , jdate < :d"); $sth->bindparam(':u', $json['u']); $sth->bindparam(':d', $date); try{$sth->execute();}catch(pdoexception $e){echo $e->getmessage();} surely there must way combine them? i've looked @ $mysqli->multi_query , so question , both seem more complex have thought necessary. i'll provide answer under assumption you're using acid compliant engine (or mortals, engine supports transactions). what want avoid code complexity - in case it's running 3 queries bundled 1. it's pretty difficult maintai

python - Unicode object error in parsing XML using BeautifulSoup -

parsing contents of 'name' tag in xml output using beautifulsoup gives me following error: attributeerror: 'unicode' object has no attribute 'get_text' xml output: <show> <stud> <__readonly__> <table_stud> <row_stud> <name>rice</name> <dept>chem</dept> . . . </row_stud> </table_stud> </__readonly__> </stud> </show> however if access contents of other tags 'dept' seems work fine. stud_info = output_xml.find_all('row_stud') eachstud in range(len(stud_info)): print stud_info[eachstud].dept.get_text() #gives 'chem' print stud_info[eachstud].name.get_text() #---unicode error--- can python/beautifulsoup experts me resolve this? (i know beautifulsoup not ideal parsing xml. lets i'm compelled use ) tag.name attribute containing tag

python - Mix of scalars, tuples and numpy arrays as string argument -

i using python generate povray rendering code visualization of computed data. need pass lot parameters python strings of povray code. make scrips cleaner. use tuples , arrays directly arguments string formating. this: sign = -1 name = "temp1" nu = 0.245 boxmin =(0.01,0.01,0.01) # tuple boxmax =array([0.99,0.99,0.99]) # array povfile.write( ''' isosurface { function { %f*( %f - data3d_%s(x,y,z) ) } contained_by { box { <%f,%f,%f>,<%f,%f,%f> } } }''' %( sign, nu, name, *boxmin, *boxmax ) ) instead of this: povfile.write( ''' isosurface { function { %f*( %f - data3d_%s(x,y,z) ) } contained_by { box { <%f,%f,%f>,<%f,%f,%f> } } }''' %( sign, nu, name, boxmin[0],boxmin[1],boxmin[2], boxmax[0],boxmax[1],boxmax[2] ) ) supposing every element want write in string list (or iterable) - if constituted 1 element - can use workaround based on list flattening.

html - Mozilla doesn't read video -

since 2 days have nasty problem. www.y-angel.com .except mozilla every other browser open videos in showreel , shorts buttons.i tried .mp4, .webm - still in html , .ogg nothing!can this.i read lot of stuff on net nothing helped me.so, can anyone? <video width="512px" height="288px" controls="controls"> <source type="video/mp4" src="templates/angelyanakiev/videos/showreel.mp4"></source> <source type="video/webm" src="templates/angelyanakiev/videos/showreel.webm"></source> </video>

java - GWT - Error to load entry point -

i'm trying run app in gwt 2.6. project sample of webcam using elemental (library gwt-elemental). source code wich using, found example: https://code.google.com/p/elemental-getusermedia-demo/source/browse/#svn%2ftrunk%2felementalgetusermediademo when run app, error below show, can't find problem. message: 08:08:57.756 [error] [elementalgetusermediademo] unable load module entry point class com.jooink.experiments.elementalgetusermedia.client.elementalgetusermediademo (see associated exception details) java.lang.runtimeexception: deferred binding failed 'com.google.gwt.user.client.impl.domimpl' (did forget inherit required module?) @ com.google.gwt.dev.shell.gwtbridgeimpl.create(gwtbridgeimpl.java:53) @ com.google.gwt.core.shared.gwt.create(gwt.java:72) @ com.google.gwt.core.client.gwt.create(gwt.java:86) @ com.google.gwt.user.client.dom.&lt;clinit&gt;(dom.java:64) @ com.google.gwt.user.client.ui.flowpanel.&lt;init&gt;(flowpa