Posts

Showing posts from February, 2013

command - Running python script from within python script -

i new python (c++ fluent) , learning on as-need basis. wrote script takes several arguments , creates , saves matplotlib graph. has no functions, methods, classes, etc. series of instructions results in graph. write script execute script arguments possible. is possible in python? take @ stdlib's subprocess module: http://docs.python.org/2/library/subprocess.html from subprocess import call call([sys.executable, 'script.py', arg1, arg2]) for complete list of options take @ similar question: calling external command in python read docs on link provided above, specially if need call secure (make sure trust or validate params). update : as alternative (and better) option run code importing it. if clean , put in function , import , call main program dont need execute module script and, if need to, still able run standalone script easily: # script.py def func(param1, param2, param3) #... if __name__=="__main__": # params...

.net - Assembly.Location doesn't returns dll location -

i'm looking way return assembly location @ runtime, can't use assembly.location because returns shadow-copied assembly's path when running under nunit. use codebase property instead, return original dll location rather shadow copied dll location. for example: assembly assembly = gettype().assembly; uri codebaseuri = new uri(assembly.codebase); string path = codebaseuri.localpath;

sql server 2005 - Unique Constraint doesn't appear to be constraining anything -

i have table called models set follows: id - pk, identity manufacturer fk - int32 primodel fk - int32 secmodel fk - int32 formfactor fk - int32 active char(1) what want columns 2,3,4,5 accept unique set of values. ran: alter table dbo.models add constraint uc_models unique (manufacturer, primodel, secmodel, formfactor) the command reported completed , see index added, not constraint. able create duplicate of cols 2-5 insert , update commands. i'm not sure if issue foreign keys or else altogether. use [inventory_v2] go /****** object: table [dbo].[models] script date: 4/8/2013 2:01:41 pm ******/ set ansi_nulls on go set quoted_identifier on go set ansi_padding on go create table [dbo].[models]( [id] [int] identity(1,1) not null, [manufacturer] [int] not null, [primodel] [int] not null, [secmodel] [int] not null, [formfactor] [int] not null, [active] [char](1) not null,

asp.net mvc - Is there a better way to add a child record using MVC 4 and Entity Framework 5? -

i learning mvc , dealing stateless nature in combination entity framework. question is, there more elegant way of handling scenario below? i have 2 poco entities: public class contest { public long id { get; set; } .... ..... public icollection<contestprize> prizes { get; set; } } public class contestprize { public long id { get; set; } public contest contest { get; set; } } i have mvc view displays contest , prizes associated them. on view have "create prize" link create new prize passes id of contest contestprize controller so: @html.actionlink("create prize", "create", "contestprizes", new { contestid = model.id }, null) the contestid persisted hidden field in form submits new prize can retrieve on create. create method on prize controller below: [httppost] public actionresult create(int parentid, contestprize contestprize) { if (modelstate.isvalid) {

linux - Why does strftime uppercase flag '^' not work? -

i have following command $(perl -e 'use posix;print strftime "%d-%^b-%y",localtime time-86400;') works on red hat linux box, not on sun solaris 9 box. question 1: read here , '^' provided glibc... correct? question 2: how find out why it's not working on solaris box? (and ultimately, how make work?) solaris not linux , although it's unix :-), system calls behave differently on different system, that's why see lots of #ifdef in c programs. can compile this c example of time functions on redhat , solaris , see difference (convert %b %^b , see not print in uppercase). best solution use perl's uc function.

How do I play an audio file with jQuery? -

i'm having difficult time getting audio work jquery. i've tried both .wav , .ogg formats. (firefox 19.0.2) clicking start button yields: typeerror: buzzer.play not function i'm not sure if jquery selectors return array, i've tried capture audio file both: var buzzer = $('buzzer'); and var buzzer = $('buzzer')[0]; regardless, can't audio elements play. <!doctype html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script> </head> <body> <audio id="buzzer" src="buzzer.ogg" type="audio/ogg">your browser not support &#60;audio&#62; element.</audio> <form id='sample' action="#" data-ajax="false"> <fieldset>

c# - How can i create an avi video file in real time while my application is processing? -

edit: this did: in form1: screencapture sc; avifile af; in form1 constructor: sc = new screencapture(); af = new avifile(); in form1 timer1 tick event: private void timer1_tick(object sender, eventargs e) { if (playimages == true) { timer1.enabled = false; play(); timer1.enabled = true; } else { af.createavi(this.sc); } } the avifile class after changed it: using system; using system.collections.generic; using system.componentmodel; using system.drawing; using system.data; using system.text; using system.windows.forms; using avifile; using screenshotdemo; namespace screenvideorecorder { class avifile { avimanager avimanager; bitmap bmp; public avifile() { avimanager = new avimanager(@"d:\testdata\new.avi", false); } public void createav

visual studio 2010 - Right click in VS2010 editor (c++) just flashes - no context menu -

i can build project fine, if right click to, say, jump definition or pull menu nothing. if highlight variable or method , right click, ide title bar flashes couple of times, never see menu. i've never seen error message either makes hard diagnose. c# projects behave fine. seems affect c++ projects. wasn't issue in vs2008 or 2005. [edit: running in safe mode gets me need.]

ios - PhoneGap/Cordova: Fine in Simulator, suddenly not working on device: Can't find jQuery -

this began happening: boss took phone development copy of app on short business trip, , reported error couple days trip. assumed had made changes json returning server , broke it, have back, doesn't seem related work on server @ all. here error message in console: error in success callback: geolocation3 = referenceerror: can't find variable: jquery or error in success callback: geolocation3 = referenceerror: can't find variable: $ so clearly, can't find jquery. executes 'deviceready' fine. works fine in simulator. using jquery cdn both jqm , jq , can access both via browser. so gives? why not able find jquery - , on device? i see lot of similar questions on web, none of them have clear answer. "clean , rebuild" others simple typos.... nothing this. it's not location permissions issue. it's not connection issue. it's not url whitelist issue. your appreciated always. thanks! i'll give code can below: <head>

Google app engine CNAME redirection -

i have application running on gae. use custom url , have configured cname per instructions on google. end getting ssl error though cname works fine. wondering if there's special setting need enable on gae side? * find cname settings , enter following cname value or alias: status set cname destination following address: ghs.googlehosted.com * the specific error getting is: error 107 (net::err_ssl_protocol_error): ssl protocol error.

java - Mysterious Ant script -

i have problem ant script. have run junit test on ant run . my current script looks like: <property name="src" location="src"/> <property name="build" location="build"/> <property name="doc" location="doc"/> <property name="dist" location="dest"/> <property name="lib" location="lib"/> <property name="app" value="${ant.project.name}.jar"/> <presetdef name="javac"> <javac includeantruntime="false"/> </presetdef> <target name="clean"> <delete dir="${build}"/> <delete dir="${dist}"/> </target> <target name="compile" depends="clean" description="compile"> <mkdir dir="${build}"/> <javac srcdir="${src}" destdir="${build}"

sql - Query quirks with DB2, no-op coalesce halves the runtime -

i'm working on optimizing queries db2 database. of them running fine, few rather large returned datasets (up 30k rows or so) giving me trouble. there's nothing terribly complicated these queries. select perhaps 15 different columns dozen joins, inner joins , left joins. there few in clauses reduce dataset parameters , subqueries. it's nothing special. i've been looking @ indexes, without great deal of luck. thing is, in attempting force use of new index wasn't being utilized, stumbled upon nifty trick in db2: no-op coalesce in predicate can potentially reduce cost , runtime. basically, works this: select ... join b on a.id1 = b.id1 , a.id2 = b.id2 --more inner , left joins-- b.type_code in (:parameter) , a.x in (--subquery--) , coalesce(b.type_code,b.type_code) = b.type_code the coalesce nothing logical standpoint , b.type_code never null. however, tricks db2 optimizer estimating lower number of rows, explanation here: http://www-01.ibm.com/support/doc

pragma - How to generate user-defined warning messages in VB.NET -

i generate user-defined warning message in vb.net done in c# (see below): how use #pragma message generate user-defined warning messages in visual c++ is possible? no, unfortunately not possible using vb.net

machine learning - Searching for binary range coincidence over many dimensions -

i've clarified , simplified question: i have data looks this: 011100111110100111 111111111111110010 111100001111000011 1d lanes of streams of data. each row signifies presence of type 1 or 0. types tend exist in chunks across stream. vertical order of rows doesn't matter. i seeking patterns dimensions coincide @ 2 or more indices, both @ start of '1' group's , , where '1' groups overlap across rows/dimensions. pattern can offset nearby adjacent indices, if it's proportion maintained. d = dimension/row n = index in stream (( d1(n), d25(n+4), d900(n-1) ), ( 3, 67, 90, 3000 )) an example of pattern match migh occur @ multiple places. dimension01 @ n, dimension25 @ index n + 4, dimension900 @ index n -1 occur @ indices 3, 67, 90 , 3000. the returned patterns: are ordered number of matching indices or number of dimensions in pattern. match @ least 2 dimensions @ at least 2 points how can go this? as far understand, a

c# - Using LDAP/AD to find mailing lists user is subscribed to -

i looking getting list of mailing distribution lists user subscribed to. have never used active directories before, , after reading various answers here , on msdn, i'm confused. i have query set this: directorysearcher search = new directorysearcher(); search.filter = string.format("ldap://cn={0},ou=<value here>,dc=<value>...", username); search.searchscope = searchscope.subtree; search.propertiestoload.add("memberof"); searchresult result = search.findone(); if(result != null) { // stuff here } here questions: what searchroot property within directorysearcher do? need set have query return value? do need set searchscope value subtree list 1 ou base ou , have search sub ous? is string sent in propertiestoload.add() generic, or need string defined company? thanks advice! (1) searchroot property within directorysearcher do? need set have query return value? it defines starting point of search; compare file system

arrays - Python - Principal component analysis (PCA) error -

i trying make principal component analysis (pca) using python. here code: import os pil import image import numpy np import glob matplotlib.mlab import pca #step1: put database images 3d array filenames = glob.glob('c:\\users\\karim\\downloads\\att_faces\\new folder/*.pgm') filenames.sort() img = [image.open(fn).convert('l') fn in filenames] images = np.dstack([np.array(im) im in img]) # step2: create 2d flattened version of 3d input array d1,d2,d3 = images.shape b = np.zeros([d1,d2*d3]) in range(len(images)): b[i] = images[i].flatten() #step 3: pca results = pca(b) results.wt but getting error runtimeerror: assume data in organized numrows>numcols i tried replacing b = np.zeros([d1,d2*d3]) b = np.zeros([d2*d3, d1]) got valueerror: not broadcast input array shape (2760) shape (112) can me? if change b = np.zeros([d2*d3, d1]) should change loop afterwards otherwise try put d1 dimention array d2*d3 one. you should rid of second erro

HTTP error (406): Ruby on Rails and Savon -

well i'm using savon consume wash_out soap server. everything seems right because can send soap messages , server can save them mysql database. my problem comes after client send request because i'm receiving http error (406): coming request looks this: response = client.call(:crear_articulo) message texto: ":3", titulo: ":'(" end in server have following code: soap_action "crear_articulo", :args => { :texto => :string, :titulo => :string }, :return => :string and method handling request this: def crear_articulo @ar = articulo.new @ar.titulo = params[:titulo] @ar.texto = params[:texto] if @ar.save render :soap => "correcto" else render :soap => "error" end end i guess error in server but, can't see is. thank much.

vb.net - OK. Taking the Leap to C++. Right Descision? -

ok. in past, have tried best master vb.net (which unsuccessful, taught me basics of programming, through research , experience. got know programming jargon, types, declarations, arrays etc.). before continue invest lot time spent elsewhere, on developing knowledge of vb.net, considering learning c++ moment onward. my reasons wanting learn c++ are: - powerful, , both low , high-level (ish) language. - quite(or very?) portable - has been around long time - lot of software companies write applications in - quite hard read (for me), allows more concise definitions etc., , overall, more compact code. - quite specific ways in things (i because keeps things strict , creates standard) - if not mistaken (which may be), perhaps harder dissassemble, decompile etc. - not reliant on things windows or .net framework (i may wrong here) these few things attracted me it. let me explain unexperienced language, have viewed few simple "hello world!" apps etc. (only console apps) al

Linux file sort with incomplete columns -

i need sort file first column, if there numerical entry, , second column when there none in first. looks this: 3 - foo bar 1 1 foo bar - 5 foo bar 2 2 foo bar - 4 foo bar and need output be 1 1 foo bar 2 2 foo bar 3 - foo bar - 4 foo bar - 5 foo bar is there nice way in linux single command? thanks! on output follows format can use basic sort command: sort -k 1,2 foo.txt

In MySQL, which is more efficient: IFNULL or NULLIF? -

these 2 mysql functions same thing: ifnull(column_name, 'test') = 'test' or nullif(column_name, 'test') null which 1 more efficient? they both efficient each other - functions have same overhead each other. but more efficient either: (column_name null or column_name = 'test') because function doesn't need invoked. you may find putting more commonly encountered test first improves performance. with questions this, simplest , more reliable way discover relative performance try them , compare query timings. make sure have production-sized , realistic-valued datasets test fair.

testing - How to test remote server deployment of Rails app with Cucumber and Capybara -

i developing rails 3.x app under windows 7 , using cucumber , capybara testing. i have set ubuntu vm , deployed app that. i want use cucumber / capybara test app on vm after each deployment - after all, different os , want leverage power of test suite test different browsers (firefox, chrome , ie) against deployed site. in theory, seems though have 3 main options: 1) run cucumber locally, local browser , hit remote server (vm guest) 2) run cucumber locally remote browser hitting remote server 3) connect vm guest , run cucumber locally under vm it seems me option 1) best simulates real world, ie not running browser on remote server. however, not sure if possible, or how configure things achieve it. in particular not clear whether or not need selenium server in case, , if do, whether should deploying locally (on windows dev machine) or remotely (in guest vm app deployed). i have done fair bit of google searching issue , have looked @ such posts as: problems connecting

visual studio 2010 - MSVC2010: Why does my C++ Win32 project require a target .Net framework? -

Image
i've avoided using clr/managed project , yet still asks me target framework. i created project in vs 2012 , same thing asked for. i ignored it , there no dependency on .net framework far can see in created solution. looks ui issue only.

mysql - Passing PHP variables onclick -

say have 2 files, fileone.php , filetwo.php . fileone.php generates list of links, items mysql database, every 1 of these items have unique integer id (1,2,3,4...). filetwo.php contains php function uses id create page displaying item clicked in fileone.php . depending on item click in fileone.php see different image, text , more in filetwo.php . my problem: how @ send id fileone.php filetwo.php ? use forms $_get variable? purely hypothetical situation , have no code show, need input on how approach this. yes, pass id via $_get fileone.php... <a href="/filetwo.php?id=1">1</a> <a href="/filetwo.php?id=2">2</a> <a href="/filetwo.php?id=3">3</a> filetwo.php if(isset($_get['id'])) { //do somethign $_get['id'] } you should pdo or mysqli receive , sanitize input. not use mysql_ functions deprecated.

javascript - Activate SWFUpload trigger with plain anchor -

this might simple question simple fix, unable figure out solution. i using swfupload on site facilitate file uploads (obviously), however, requires placing placeholder using span or of likes: <span id="swf_placeholder_etc"></span> and calling swfupload replaces span with: <object id="swfupload_1" type="application/x-shockwave-flash" data="/swfupload/flash/swfupload.swf?preventswfcaching=1365470153721" width="120" height="35" class="swfupload"> <param name="wmode" value="transparent"> <param name="movie" value="/swfupload/flash/swfupload.swf?preventswfcaching=1365470153721"> <param name="quality" value="high"> <param name="menu" value="false"> <param name="allowscriptaccess" value="always"> <param name="flashvars" value="all settin

join - SQL Query different value from same column -

was required query data tables products , customers . expected results below: cust_name(from) | product_name | product_desc | eta | cust_name(to) the cust_name(from) , cust_name(to) both same table ( customers ). how query sql statement query 2 different value column? you need join customer twice on table products because there 2 columns dependent on it, select b.name custnamefrom, a.product_name, a.product_desc, a.eta, c.name custnameto products inner join customer b on a.cust_from = b.id inner join customer c on a.cust_to = c.id sqlfiddle demo to further gain more knowledge joins, kindly visit link below: visual representation of sql joins

objective c - iOS executable file without main function -

i created test app , exported ipa file. used ida pro executable binary file. found main function called start subsroutine: blx _main so concluded entry point of mach-o executable start subroutine, call main function. however, when tried opening executable file of other apps (which grabbed using clutch), found there no _main function @ all, instead thing sub_2a4c. i know why there such difference? you conclusion not right. true entry point start subroutine, true start subroutine calls main function declared in code. however, if choose yes in option 'deployment postprocessing' , 'strip linked product 'in xcode build setting, symbol stripeed, won't see main function _main anymore, obfuscated such sub_2a4c.

xml - How to bind Time to paragraph? -

i working on application should bind time each paragraph of text (utf-8). so should kinda of index file can navigate 1 paragraph another. and here got stuck index file structure... i guessed use xml <paragraph start="00:00:05"> chapter </paragraph> <paragraph start="00:00:08"> down rabbit-hole </paragraph> <paragraph start="00:00:11"> alice beginning tired of sitting sister on bank, , of having nothing do: once or twice had peeped book sister reading, had no pictures or conversations in it, `and use of book,' thought alice `without pictures or conversation?' </paragraph> basically have keep list of time , text tags (in order find , select paragraph). my current solution create custom object ( which dictionary in fact ) , save via binary writer , when read after deserialize it. but not sure if technically approach correct one. and here questions: how many text have keep find paragraph? i

string - Why is `sData` a non-nil value? -

execution of code here on eval.in smessage = "<hjpotter92> +help|" local _, _, scmd, sdata = smessage:find( "%b<>%s[%+%-%*%/%!%#%?](%w+)%s?(.*)|" ) print( _, sdata, scmd ) the output of print says sdata value empty string. why value not nil ? created entire project based on sdata being nil such case, , find not so. i've resolved trouble using block if sdata:len() == 0 sdata = nil end so, i'm not seeking solution make work. i'm asking, why not nil value? why should nil ? getting successful match of pattern .* empty string. nil means "no match found". example

java - I need help on boolean arrays -

i'm stuck on array problem , use help. the first visitor occupy middle position: _ _ _ _ _ x _ _ _ _ the next visitor in middle of empty area on left side, longest sequence of unoccupied places: _ _ x _ _ x _ _ _ _ etc... i have made start , need continuing. here's code , please me. have boolean array created cant figure out how print out contents of or , see know elements true or false can fill out rest of array. import java.util.scanner; public class homework06 { public static void main(string[] args) { scanner keyboard = new scanner (system.in); int answer = 0; string start=""; answer=promptfornumberofstalls(); int[] stalls=new int[answer]; boolean firstperson[]=new boolean[answer]; start=firstperson(answer); occupyonemore(answer, start, firstperson); } public static int promptfornumberofstalls (){ int answer =0; scanner keyboa

gawk - Using multiple threads/cores for awk performance improvement -

i have directory ~50k files. each file has ~700000 lines. have written awk program read each line , print if there error. running fine, time taken huge - ~4 days!!!! there way reduce time? can use multiple cores (processes)? did try before? awk , gawk not fix themselves. there no magic "make parallel" switch. need rewrite degree: shard file - simplest way fix run multiple awks' in parallel, 1 per file. need sort of dispatch mechanism. parallelize bash script maximum number of processes shows how can write in shell. take more reading, if want more features check out gearman or celery should adaptable problem better hardware - sounds need faster cpu make go faster, i/o issue. having graphs of cpu , i/o munin or other monitoring system isolate bottleneck in case. have tried running job on ssd based system? easy win these days. caching - there amount of duplicate lines or files. if there enough duplicates helpful cache processing in way. if

regex line not containing word? -

i'm hoping can me possibly simple regex question. need match lines contain set of words, not contain word. e.g. file searching contains following: bob has hat. bill has hat. fred has hat. what want match lines have 'has hat.' unless line contains bob. does make sense ? this has basic regex, not code or entering text file parse program. ^(?=.*\bhas hat\b)(?!.*\bbob\b).* matches entire line if contains has hat anywhere , doesn't contain bob anywhere (in order). of course, not match line fred has hat. bob doesn't .

java - how to remove selected jtree from several jtrees by right clicking on -

in gui have load several xml files according jtree structure 1 one, if want edit or remove complete jtree or value right clicking on, how can efficiently? clue? i process xml file jtree below, /* tree implementation. */ xmltree = new jtree(); xmltree.setrootvisible(false); xmltree.seteditable(true); scrollpane.setviewportview(xmltree); frame.getcontentpane().add("center", scrollpane); ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tn = processelement(xmldoc.getrootelement()); ((defaulttreemodel) xmltree.getmodel()).setroot(tn); ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // open xml file gui. private defaultmutabletreenode processelement(element el) { defaultmutabletreenode node = new defaultmutabletreenode(el.getname()); string text = el.gettextnormalize(); if ((text != null) && (!text.equals("")))

How to login to ASP.Net MVC website (Forms authentication) using HttpClient in Windows Store App? -

first created httpclienthandler cookie container cookiecontainer cookies = new cookiecontainer(); httpclienthandler handler = new httpclienthandler(); handler.cookiecontainer = cookies; handler.usecookies = true; var hc = new httpclient(handler); then hit base url cookie "__requestverificationtoken" string r = await hc.getstringasync(baseurl); then post username/password login url httpcontent content = new formurlencodedcontent(new[] { new keyvaluepair<string, string>("username", "admin"), new keyvaluepair<string, string>("password", password), }); httpresponsemessage response = await hc.postasync(loginurl, content); then server error "the required anti-forgery form field "__requestverificationtoken" not present". but when check request in fiddler, can see "__requestverificationtoken" added in cookies of request. then tried login manually in ie, , check kind of request ie sent.

Conflicts in binary files - git -

this question has answer here: resolving git conflict binary files 9 answers i working on git .i merging 1 binary file gave me conflicts. can please tell me why binary files conflicts. causes.is because of uncommitted changes on current branch or because of different versions of binary files? if binary file changed in more 1 branch part of merge, git always create conflict since cannot apply merge strategies designed text files. because can't move binary chunks around without corrupting file. also, semantics of e.g. merging image file? it's decide want do. might want keep 1 of versions, or perhaps, if it's image files, want "manually merge" them using graphics manipulation program. git can't here.

ios - NSXML Parser find parent's child nodes -

i'm totally new xml parse, have xml structure like.. <chapter name = "chap1"> <pages>one.html</pages> <pages>two.html</pages> </chapter> chapter name = "chap2"> <pages>one.html</pages> <pages>two.html</pages> </chapter> <chapter name = "chap3"> </chapter> i want take each chapters pages separately... i.e if chapter has pages node want yes else no. how can parse..i'm using nsxml parser you have try this, - (void)parser:(nsxmlparser *)parser didstartelement:(nsstring *)elementname namespaceuri:(nsstring *)namespaceuri qualifiedname:(nsstring *)qname attributes:(nsdictionary *)attributedict { if ([elementname isequaltostring:@"chapter"]) { chapteroneflag = yes;//use bool } } - (void)parser:(nsxmlparser *)parser foundcharacters:(nsmutablestring *)string { buffcontent=[buffcontent s

use php functions as function argument -

can call php function in custom function argument. example function customfunction(trim($args),addslashes($args_second)) { //other code } that gave parse error: syntax error, unexpected '(', expecting '&' or t_variable error. correct way.? i know can inside function why can not way.? what trying impossible php. information may passed functions via argument list, comma-delimited list of expressions. arguments evaluated left right. php supports passing arguments value (the default), passing reference , , default argument values . variable-length argument lists supported. read more

iphone - Get playlists from iPod library - Objective C -

i'm build app should import ipod library items. have done importing songs, want know how import playlists , albums library. provide me suggestions or example code. thank you. i hope enough give information you, read this . and if looking sample code visit this . it return albums, mpmediaquery *allalbums = [mpmediaquery albumsquery]; nsarray *albumarray = [allalbums collections];

xslt - Add text to XML child element using XSL while preserving all children and attributes of children -

i'm trying add text paragraph based on 'performance' attribute of it's 'step' parent. if step marked 'performance="optional"' resulting text (for second step below) this: "2. (optional) step 2..." <procedure> <step id="step_lkq_c1l_5j"> <para>this step 1, required.</para> </step> <step performance="optional"> <para>this step 2, optional, unlike <xref linkend="step_lkq_c1l_5j"/>. <note> <para>i don't want lose note in transformation.</para> </note> </para> </step> <step> <para>this step 3.</para> </step> </procedure> i tried using xpath match node , modify it: <xsl:template match="step[@performance='optional']/child::para[position()=1]"> , using concat() attem

mysql - Hey i m new and geting error for a simple leveshtein function -

on running below block in phpmyadmin shows #1064 - have error in sql syntax; check manual corresponds mysql server version right syntax use near '' @ line 5 create function levenshtein( s1 varchar(255), s2 varchar(255) ) returns int deterministic begin declare s1_len , s2_len, i, j, c, c_temp, cost int; declare s1_char char; -- max strlen=255 declare cv0, cv1 varbinary(256); set s1_len = char_length(s1), s2_len = char_length(s2), cv1 = 0x00, j = 1, = 1, c = >0; if s1 = s2 return 0; elseif s1_len = 0 return s2_len; elseif s2_len = 0 return s1_len; else while j <= s2_len set cv1 = concat(cv1, unhex(hex(j))), j = j + 1; end while; while <= s1_len set s1_char = substring(s1, i, 1), c = i, cv0 = unhex(hex(i)), j = 1; while j <= s2_len set c = c + 1; if s1_char = substring(s2, j, 1) set cost = 0; else set cost = 1; end if; set c_temp

multithreading - Stopping a socket using a REST WebService - JAVA -

i again issue, tried searching question/answer, none of them worked far, decided post one. have small rest jaxrs webservice in java/tomcat running, , jsp page hope send commands start , stop socket client. far achieved starting socket, not able stop it, doing wrong? edit 1: tested same socket functions (using same class plc) jframe interface 2 buttons, 1 connect , other disconnect representing rest functions, , works my rest functions newten_plc m_plc = new newten_plc(0x01, "central park", "10.80.4.10", 5001); thread m_thread; @put @path("/connect") public void connect(inputstream is) { system.out.println("connect command received"); try { system.out.println( "starting executor" ); //using thread manager //executorservice threadexecutor = executors.newcachedthreadpool(); //start thread //threadexecutor.execute(m_plc); //shutdown working thread

caching - Concurrent Cache in Java -

suppose have multiple threads accessing map (actions are: inserting, retrieving, removing), , i'm using concurrenthashmap , need else or concurrenthashmap 'covers' me? there still 'bad' can happen? because not know all scenarios of task, according have described, imho concurrenthashmap sufficient.

asp.net mvc - MVC encodig strings -

i set validateinputattribute in controller action false. in view, have textbox: <p> <%= html.textboxfor(m => m.name.lastname, new { maxlength = "100" })%> <%= html.validationmessagefor(m => m.name.lastname) %> <%= html.hidden("hiddenlastname", model.name.lastname) %> </p> now can save thourgh textbox, when displaying data see strange characters. when save <script>alert(“boo!”)</script> , open site again see result, see: <script>alert(“boo!”)</script> how can fix this? note: i'm not encoding input somewhere else in code. if want see < instead of &lt; , use httputility.htmldecode if you're saving user input in database , want them allow entering html, encode input in controler before storing in database: model.input = httputility.htmlencode(model.input); and when want dispaly input, decode in in view : @httputility.htmldecode(model.input) and inste

asp.net - How to create a .Net version 2.0 website using Visual Studio 2012? -

i have created website using visual studio 2012. working fine. problem have deploy on server has .net framework 2.0 only. created website using visual studio 2012 , set version 2.0. after copying code of single page tried run it. getting errors "unknown server tag asp:scriptmanager" , "unknown server tag asp:updatepanel". need them both have use pagemethods in page. how can create .net framework 2.0 website scriptmanager , updatepanel without error? in advance. you might have install asp.net 2.0 ajax extensions 1.0 if planning use scriptmanager , update panel in .net 2.0. prior .net 3.5, ajax available separate library.

class "jqgrid-new-row" will be added by addRow but never removed -

i've read thread bug jqgrid addrow function : http://www.trirand.com/blog/?page_id=393/bugs/class-jqgrid-new-row-will-be-added-by-addrow-but-never-removed/ could please send me code add grid.inlinedit.js ? i'm newbie in jqgrid , don't know how remove class row. oleg, appreciate if can me. the bug reported here fixed in main code of jqgrid on github . can see current code of grid.inlinedit.js here , download here . by way suggested tony (see here ) publish current version of jqgrid github new release (4.4.5) of jqgrid. answered (see here ) plan this week. wait 1-2 days , download new fixed version of jqgrid the standard download place .

How to execute a function after some time javascript -

i want write javascript code can excute function after 30 minutes. say have function called getscore , function called getresult . want functions executed after 30 minutes. it's quiz purpose, quiz duration 30 minutes, after time passes,both functions should executed. you should use settimeout() : settimeout(function() { getscore(); getresult(); }, 1800000); the '1800000' time in milliseconds after want function execute. in case, 30 minutes.

postgresql - POSTGRES foreign languages -

i have problem directly inserting foreign characters "ó,č,ĕ,ř" characters database. dont working php frontend sure there no transformation or other encoding. im using logged in psql directly , here setup : server_encoding ----------------- utf8 (1 row) and client_encoding ----------------- utf8 (1 row) database : name | owner | encoding | collate | ctype | my_db | postgres | utf8 | en_us.utf-8 | en_us.utf-8 | so guess there should no problem. i created : create table test (a text); and want insert text insert test (a) ('ó'); and there message : error: invalid byte sequence encoding "utf8": 0xf327293b is there can me please? looks ignoring input encoding or dont know. edit : my terminal configuration lang=en_us.utf-8 language=en_us:en lc_ctype="en_us.utf-8" lc_numeric="en_us.utf-8" lc_time="en_us.utf-8" lc_collate="en_us.utf-8" lc_monetary="en_us.u

CSS multilevel drop-down with additional jQuery -

i have css multilevel drop-down menu works perfectly. i add additional jquery code menu stays open when hover. have click screen close menu, (similar http://www.cssplay.co.uk/menus/cssplay-click-drop-fly.html or http://www.codenothing.com/archives/2009/multi-level-drop-down-menu/ ). i have added jquery, (see below), makes first 2 levels/uls work required, lower levels not staying open. ideas on how fix please? jsfiddle here - http://jsfiddle.net/psfk7/5/ jquery code: $('.top_level').mouseover(function(){ $('.megamenu_main').addclass('megamenu_main_over'); $('html').click(function() { $('.megamenu li.top_level ul').removeclass('megamenu_main_over'); }); }); $('li.parent').mouseover(function(){ $('li.parent ul').removeclass('children_over') $(this).children('ul').addclass('children_over'); $('html').click(function() {