Posts

Showing posts from May, 2011

regex - Python testing if whitespace(\s) symbol is in string -

i have problem testing if "\s" symbols present in string. example '\sgoogle\s.com' must show there is. # use raw strings ignore escapes: s = r'\sgoogle\s' print s, s.find(r'\s') != -1 # , regex: import re print re.search(r'\\s', s) gives: \sgoogle\s true <_sre.sre_match object @ 0x7f2d696fc850>

sql - Sqlite on Android: select time only from datetime -

i have date , time (saved plain text string) in sqlite in following format: yyyymmddhhmm (hours , minutes in end). can make select based on time - day between 18:00 , 20:00? you can extract parts of datetime stamp substr() , use regular comparison operators < , > or between on it. example: select * tablename substr(timestampcolumn, 9, 4) between '1800' , '2000';

javascript - Drop down menu toggle -

i'm making site that's responsive. when page <=830px of page changes. i need figuring out way toggle sub menus 1 @ time. wordpress generates same .sub-menu class name each submenu. i'm using code toggle menus both go @ same time. need make browser less 830px see i'm talking about. $(".about").click(function() { $(".sub-menu").slidetoggle("fast"); return false; }); //.click $(".projects").click(function() { $(".sub-menu").slidetoggle("fast"); return false; }); //.click thank help. http://www.mackeyshotrods.com/store/?page_id=2 $(document).ready(function () { $("#na ul li").click(function () { $(this).siblings().find('ul').slideup(400); $(this).find('ul').slidetoggle('fast'); }); }); demo: http://jsfiddle.net/7p3df/1/

clojure - Leiningen compilation order? -

i'm learning how lein , , i'd use java source class created deftype in clojure source. wasn't covered in basic tutorial , can't work properly. the problem java source can't import clojure class, since hasn't been compiled yet. , clojure class isn't compiled, since compilation aborted java source. i give minimal example: create new project with: lein new app javafoo add project.clj :aot :all :java-source-paths ["src/java"] put src/javafoo/core.clj : (ns javafoo.core) (deftype ppoint [x y]) put src/java/javafoo.java : package foo.java; import javafoo.core.ppoint; public class javafoo { public static void main(string[] args) { system.out.println("javafoo"); } } try compile lein compile it fails package javafoo.core doesn't exist . have to comment out :java-source-paths compile uncomment :java-source-paths compile it works. there way make work start? add line project.clj : ...

python - How to force genfromtxt read csv as record array? -

i'm trying read csv following line: raw_data = genfromtxt(datafile,delimiter='\t',dtype=none) ok, function reads file record array when meets string data in datafile. far understand, when dtype none, file should read record array too. correct? however, if there no string data , numeric 1 presented, function reads data ndarray. if no, there convenient way force function read file record array? the problem ndarray code built in order process record arrays. upd1 in case try it, here brief solution. possibly 1 not best, @ least works: read file csv ndarray raw_data = genfromtxt(datafile,delimiter='\t',dtype=none) generate default names , datatypes columns: names_=['f'+str(i) in range(raw_data.shape[1])]; names=[(name,raw_data.dtype) name in names_]; and finaly, create record array: raw_data_as_ra = raw_data.ravel().view(names); you use recfromcsv , derived genfromtxt , instead: if file looks like: col1,col2,col3 1.1, 2.4, 3...

Kendo UI dropdown list - different background color to each list item -

how provide different background colors each list item (non-selected) in kendo ui dropdown list rather giving common background color whole dropdown? you should defined template sets appropriate color. example: define datasource as: var colors = [ "red", "green", "pink", "blue", "yellow" ]; and template as: <script id="template" type="text/kendo-script"> <div style="background-color: #= data #">#= data #</div> </script> then dropdownlist definition should as: var template = kendo.template($("#template").html()) $("#dropdownlist").kendodropdownlist({ datasource: colors, template : template }); working example here: http://jsfiddle.net/onabai/mzlrs/

ios7 - iOS 7 Translucent Tab Bar and Nav Bar -

Image
i having issue translucent uinavigationbar , uitabbar in ios 7, whereby if have uinavigationbar translucent works expect to, set uitabbar translucent strange effect happening in 1 out 4 tabs in app. let explain images: this image shows interface nav bar set translucent: with image showing result of user scrolling content , under nav bar: now, how expect look, , when user scrolls content under nav bar looks did before. if set uinavigationbar translucent, , scroll content under nav bar, result different second image: event tab bar doesn't right me. next image shows of nav bar if different before, when content scrolled underneath it: again, don't thing of tab bar correct, next image shows different tab content underneath it, subtle change of tab bar: has else had similar issues this? (this set in storyboard) well, annoying one. added fifth tab had mkmapview in it. on running app , selecting fifth tab, tint colour nav , tab bars removed, d...

android - g sensor(accelerometer) curve on HTC One M8 -

i used extract accelerometer data android sdk on samsung galaxy s4, , encounter strange problem when change platform htc 1 m8. here statement experiment: once move device place place b straight(negative direction of device), read accelerometer data , compute displacement between , b. curve of acceleromter data on s4 correct. contains 2 pick different sign , shape 's' lie on floor. but when use m8, give me curve wrong obviously. looks 'w' p.s. motion , program of 2 totally same. can give me reason difference? g-sensor on m8 problem? i'm stuck on it. thanks. from understand trying use moves app, due lack of support of accelerometer when device's display off. i looking way change , if find update here. update: it seems due new hardware not being supported yet. quote leads me believe "...are low-powered, listening "smart sensors." accelerometers nothing new, htc's can used apps day long without significant drain on the ba...

How can I set the "directory" bit in unix permissions -

i did a: chmod 7777 mydata on mydata directory. no-longer recognised unix (cygwin actually) directory: -rwxrwxrwx+ 1 administrators domain users 63 apr 4 10:19 mydata how can set first character being "d"? you can't. d isn't permission, it's attribute. you'll see '-' or 'd' you'll see selection of others if browse /dev . i'm bit surprised you've managed turn directory file in way. entirely sure mydata directory start off with? of 4 modes you've set, should have got file (or directory!) with: user/group/other read/write/execute setgid, setuid, , 'sticky' bit set. chmod shouldn't able turn directory flat file, unless you've found really strange bug.

Generating 8 digit random number in matlab -

how can generate 8 digit random number in matlab 10000000 99999999 ? i trying using rand function problem is, produces 4 digit numbers. want result in format 87322343 , not 6.4 * 1.0e7 . try: r = rand * (99999999 - 10000000) + 10000000

python list element from decimal into string -

i have 1 element in each list: ['39.95811864900048'] how can convert string. tried join: "".join(item['longitude']) it rounds off 2 decimals , returns 36.95 what need whole number string: 39.95811864900048 why not first element: a = a[0] example >>> = ['39.95811864900048'] >>> = a[0] >>> '39.95811864900048' >>> item['longitude'][0] '39.95811864900048'

css - Techniques for placing text over a background image -

have @ website http://startbootstrap.com/templates/grayscale/ introductory text placed on background image. in case - use table display text .intro { display: table; width: 100%; height: auto; padding: 100px 0; text-align: center; color: #fff; background: url(../img/bg.jpg) no-repeat bottom center scroll; background-color: #000; -webkit-background-size: cover; -moz-background-size: cover; background-size: cover; -o-background-size: cover; } of course way of achieving use absolute positioning taking mobile-first approach - i'm curious know lightweight solution (least amount of css) while keeping best practices! i guess it's background: url styling that's crux of it. can use on div though. rest of styling div (text colour/div size). here's minimalist example - works fine on android phone: <html> <head> <style type="text/css"> div { background: url(http://www.thewebbery.co...

asp.net mvc - Compile Error - MVC -

i have try reprogram aspx cshtml in mvc , error shows is: compilation error description: error occurred during compilation of resource required service request. please review following specific error details , modify source code appropriately. compiler error message: cs0115: 'asp._page_views_user_index_cshtml.execute()': no suitable method found override source error: line 59: } line 60: line 61: public override void execute() { line 62: begincontext("~/views/user/index.cshtml", 80, 14, false); line 63: i have no idea error... ideas...

php - .htaccess apache URL rewriting -

i have performed multiple searches , have yet find looking for. i need perform url rewrites don't have expertise , knowledge code rewrites. have begun learning regex , apache url rewriting. onto problem. website use these re-directs on .com domain users coming multiple countries. on website there online shop. on initial landing page able select country , take www.domain.com/*country*/ which has online shop. now gets complicated. depending on country user clicked, append countries name url after have clicked on product , entered shop. e.g "www.domain.com/*country*/*product-category*/ at moment, when click on product after selecting country goes www.domain.com/*product-category*/ the site running wordpress. not sure other information required. thanks guys! if have control on implementation of online shop implementation solution might quite easy: said somehow have make sure urls sent out shop, urls 1 can click/select inside shop navigation, carry...

html - onsubmit javascript and form -

the problem onsubmit not working when click on submit ,it go on action not on submit <form action="http://www.client.ad-saver.com/registration/simpleregister? email=yusuyaauu@gmail.com" onsubmit="return myfuncmyfunc();" method="post"> <input class="email" type='text' name='email' placeholder='e-mail' value=""/> <input class="submit" id="sub" type="submit" value='Регистрация' name='reg'/> </form> this js: function myfuncmyfunc () { var crossdomainrequest = { callbackcounter: 0, fetch: function (url, callback) { var fn = 'jsonpcallback'; window[fn] = this.evaljsonp(callback); url = url.replace('=jsonpcallback', '=' + fn); var scripttag = document.createelement('script'); scripttag.src = url; ...

python - Error during NearDuplicatesDetection 0.2.0 installation -

i wanted install nearduplicatesdetection 0.2.0 using pip install git://github.com/parkr/near-dup-detection.git#egg=nearduplicatesdetection but got error: 184, in get_url_rev url, rev = super(git, self).get_url_rev() file ".../anaconda/lib/python2.7/site-packages/pip/vcs/__init__.py", line 124, in get_url_rev assert '+' in self.url, error_message % self.url assertionerror: sorry, 'git://github.com/parkr/near-dup-detection.git' malformed vcs url. format <vcs>+<protocol>://<url>, e.g. svn+http://myrepo/svn/myapp#egg=myapp how can fix this? thank in advance! the correct syntax combine git pip is: pip install git+https://github.com/parkr/near-dup-detection.git#egg=nearduplicatesdetection

iphone - ios 7: Low memory & game crashes -

Image
i developing game crashes due low memory. checked memory profiling , saw memory allocation increasing while doing nothing in game, run project again - issue same: memory allocation increasing time while wasn't tapping single button after 5 mints live bytes 36.15 mb can please explain behaviour?

chat - SQL with limit by result -

i making simple chat, , need way 10 "messages" pr. conversation, can't figure out how so. this have tried. sql: select c.* chat c inner join users su on su.id = c.sender_user_id inner join users ru on ru.id = c.receiver_user_id sender_user_id='1234' or receiver_user_id='1234' order created asc now messages user id 1234 ... want 10 messages pr. conversation. hope make sense the standard sql way use window/analytic functions: select t.* (select c.*, su.name sender_name, ru.name receiver_name, row_number() on (partition c.conversation order c.created desc) seqnum chat c inner join users su on su.id = c.sender_user_id inner join users ru on ru.id = c.receiver_user_id sender_user_id = '1234' or receiver_user_id = '1234' ) t seqnum <= 10 order created asc; note need better job of selecting columns want in subquery. using * result in duplicate c...

java - Why Eclipse doesn't show local variables values when I debug class file from JDK? -

Image
i have following problem. i want debug class files. example jdk.i downloaded sources , attached it. public file[] listfiles(filenamefilter paramfilenamefilter) { string[] arrayofstring = list();//now here if (arrayofstring == null) return null; .... } then type f6 , move next line. after try watch arrayofstring value see next: expression view: is normal situation? is there way debug ? update1 update2 update 3 the problem source/class files jdk compiled without debug information , therefore eclipse can't inspect these vars. see this answer more information. to solve problem need different rt.jar or compile yourself

How to set firefox full screen with addon SDK (no html5 api)? -

how set firefox full screen addon sdk (no html5 api)? thank much. i guess ask f11 version of full screen. const { getmostrecentbrowserwindow } = require('sdk/window/utils'); getmostrecentbrowserwindow().browserfullscreen();

Computing the pseudo inverse of a matrix in R -

i trying compute pseudo inverse of matrix, call m, might following way: m=matrix(c(-1,-1,1,0,0,1),nrow=2,ncol=3) what need left inverse of matrix, such that: m_inv_l m=i using mass package, able find right inverse: m_inv_r=ginv(m) where m m_inv_r=i. is there way compute left inverse instead of right inverse? haven't been able find answer on forum. thanks i don't think possible in general - you're trying solve 9 linear equations 6 values. specifically, @ top row of inverse: -1* minv[1,1] + -1*minv[1,2] = 1 [1] 1* minv[1,1] + 0*minv[1,2] = 0 => minv[1,1]=0 [2] 0* minv[1,1] + 1*minv[1,2] = 0 => minv[1,2]=0 [3] it should clear substituting [2] , [3] [1] produces contradiction.

c - printf ipv6 address using struct in6_addr and ipv4 address using u_int32_t -

this question has answer here: expand ipv6 address can print stdout 2 answers i want printf values of ipv6 address type struct in6_addr , ipv4 address type u_int32_t console. i have tried type casting yields error error: aggregate value used integer expected printf("---------------- ipv4= %zu ipv6 = %zu ",(size_t)ipv4, (size_t)ipv6); i have tried %s ,%lu , many other ways after going through old question in stack overflow , other places . if has solution shall thankful . in6_addr struct contains union, can't cast size_t , hope work. should use inet_ntop convert human-readable form. see http://www.beej.us/guide/bgnet/output/html/multipage/inet_ntopman.html more info.

Get Re payment from card number already used in authorize.net payment gateway php -

i have integrate authorize.net payment gateway php application. e.g. if make payment transaction successfully, have saved card number , transactionid in own database, response generated authorize.net requirment make payment capture transaction using card number , transactionid(if needed). using php script. i have used url refund authorize.net exist card number , transactionid. e.g $response = file_get_contents('https://secure.authorize.net/gateway/transact.dll?x_version=3.1&x_type=credit&x_amount='.$amount.'&x_card_num='.$cardnumber.'&x_delim_data=true&x_relay_response=false&x_login=36h3ramp5x&x_tran_key=6vtf765y5mx238mt&x_trans_id='.$transactionid); in url x_type=credit i have used x_type=auth_capture but gives invalid card number error please let me know answer asap. thanks in advance

c# - RichTextBox delete old output, and set new output when clicking a button -

in c# project have read-only richtextbox , textbox input , button. when user types text, output written in richtextbox when push button. but if type more text, old text still in richtextbox , new text appended. how can delete old output clicking button , @ once indicate new output? thank indeed! -valeria- string newstring =txtinput.text; richtextbox.text+=newstring;

javascript - Store the longtitude and the latitude of a placemark into array -

so i'm working on webpage using google earth api shuttle moves around town , picks passengers. passengers predefined array of objects , separate javascript file due length. here code function populate populates 3d map placemarks: function populate() { // mark houses (var house in houses) { // plant house on map new google.maps.marker({ icon: "https://google-maps-icons.googlecode.com/files/home.png", map: map, position: new google.maps.latlng(houses[house].lat, houses[house].lng), title: house }); } // current url, sans filename var url = window.location.href.substring(0, (window.location.href.lastindexof("/")) + 1); // scatter passengers (var = 0; < passengers.length; i++) { // pick random building var building = buildings[math.floor(math.random() * buildings.length)]; // prepare placemark var placemark = earth.createplacemark(""); placemark.setname(passengers[i].name + "...

git - Failed to download zendframework/zendxml from dist: -

failed download zendframework/zendxml dist: must enable openssl extension download files via https trying download source - installing zendframework/zendxml (1.0.0) cloning 559b34f426d33a11c3db118e00ce14bb8dc64e5f [runtimeexception] failed clone git@github.com:zendframework/zendxml.git, git not found , check installed , in path env. 'git' not recognized internal or external command, operable program or batch file. i can't able install zend in system please body me this, every time when start exploring zend same error repeated again please me this composer trying install zendframework/zendxml package. in order that, either need openssl php extension installed/enabled (so php can download https urls), or git installed (so composer can download source). fix either of these issues (i'd suggest openssl) , should go.

URL masking in html -

i have masked url in html page follows: <head> <base href="http://www.abc.com" /> <meta name="description" content=""> <title></title> </head> <frameset rows="100%,*" frameborder="no" framespacing=0 border=0> <frame src="https://www.xyz.com/login.htm" name="mainwindow" frameborder="no" framespacing="0" marginheight="0" marginwidth="0"></frame> </frameset> <noframes> </head> the https://www.xyz.com/login.htm outsourced link , not have access source code. when user clicks login button on page, user logged in. on login separate page loaded user.htm . however, due masking applied (above), see masked url after login. view original url once user logs in. can prevent that? edit: got access login.htm file. placed on server. file contains login button not button image: <input target="_top"...

ssis - Http Request Timeout using Cozyroc for connecting to Salesforce -

i have ssis package transferring data sql server salesforce , back, using cozyroc ssis+ library. package composed of multiple data flow tasks. seems fail due http connection timeout @ 1 particular executable in 1 of tasks. executable, basically, tries fetch data account object in salesforce. there other executables, earlier in package connect , download data salesforce fine, including account object. stack trace follows: event name: onerror message: system.net.webexception: operation has timed out @ system.net.httpwebrequest.getrequeststream(transportcontext& context) @ system.net.httpwebrequest.getrequeststream() @ cozyroc.sqlserver.ssis.gzipwebrequest.getrequeststream() @ system.web.services.protocols.soaphttpclientprotocol.invoke(string methodname, object[] parameters) @ cozyroc.sforce.service.sforceservice.query(string querystring) @ cozyroc.sqlserver.ssis.sforcesource.preexecute() @ microsoft.sqlserver.dts.pipeline.managedcomponenthost.hostpreexecut...

c - Creating a structure for linked list -

experts, having simple doubt in linked list , structure. want create list subset. example structure typedef struct { uint16 a; uint8 b; uint8 c; uint8 d; }subset_t; typedef struct node{ subset_t list; uint8 set_no; struct node *link; }all_list: but think structure not expect, example there set number 15, in set there should different subset(a,b,c,d). ex. set subset 15 a=10; b=1; c=17; d=12 a=00, b=43; c=21; d=15; 10 a=10; b=1; c=17; d=12 a=00, b=43; c=21; d=15; how can defined structure this ?. main reason want create different structure delete of subset easily. so want like: typedef struct subset_t { uint16 a; uint8 b; uint8 c; uint8 d; struct subset_t *next; }subset_t; typedef struct node{ subset_t list; uint8 set_no; struct node *link; }all_list: (note subset_t added first line). run...

java - Create multiple excel files from a large data set and zip the excel files -

i have huge data set. im using apache poi create excel file data set. problem data set size exceeds 40 lakh rows in excel. split data set, make multiple excel files , zip , provide user downloadable zip file. im using restful services way. retrievedata class: public map<integer, object[]> exportxlsxdata(string dim, string client, string type) { int count = 1; map<integer, object[]> data = new treemap<integer, object[]>(); stringbuilder querybuilder = new stringbuilder(); try (connection con = datasource.getconnection()) { string dimname = getname(dim, client); data.put(count, new object[] {dimname, "job", "a", "b", "c", "d", "e", "f"}); statement stmt = con.createstatement(); if(type.equalsignorecase("u")){ system.out.println("exporting unmapped!!"); querybuilder.append("select * ta...

mysql - Want to edit database with update query -

i want update records database got error , record isn't getting updated. my problem: dealing database first run select query , second insert data database. select query , insert query working when update records , want edit in other page got error my code <?php $con=mysqli_connect("localhost","root","","new"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $result = mysqli_query($con,"select * img"); echo "<table border='1'> <tr> <th>name</th> <th>age</th> <th>phonenum</th> <th>email</th> <th>date</th> </tr>"; while($row = mysqli_fetch_array($result)) { echo '<form action=""> '; echo '<input type="hidden" name="rec_id" value="'.$row[...

sql server - I try to update to SQL but it show this error " object reference is not set instance of an object " -

private sub button1_click(sender object, e eventargs) handles button1.click dim con sqlconnection con = new sqlconnection("data source=.;initial catalog=pantiendatabase;integrated security=true") con.open() try 'cmd.commandtext = "update patient_detail set (name ='" & textboxname.text & "',age = '" & textboxage.text & "',sex = '" & textboxsex.text & "',address = '" & textboxaddress.text & "',check_in = '" & textboxchin.text & "',check_in_illness = '" & textboxchinl.text & "',sevice = '" & textboxservice.text & "',check_out_illness = '" & textboxchoutl.text & "',check_out = '" & textboxchout.text & "',transfer = '" & textboxtransfer.text & "',patient_result = '" & combobo...

c++ - Can i make assignment operator to work like copy constructor? -

hello got class looks this: class myclass{ public: //other consturctors //copy constructor: myclass (const myclass & x) : c1(x.c1), c2(x.c2), c3(x.c3), s1(x.s1) {}; //other functions myclass & operator = (const myclass & x); private: const otherclass1 c1; const otherclass2 c2; const otherclass3 * c3; string s1; } and problem assingment operator, because compiler doesnt allow me in copy constructor. thats problem because classes need assign doesnt have assign operator implemented , cant edit them cant this: myclass & operator = (const myclass & x) { c1=x.c1; // -> compile error c2=x.c2; // -> compile error c3=x.c3; s1=x.s1; return *this; } so i've tried implement assign operator like: myclass & operator = (const myclass & x) { static myclass tmp(x); return tmp; } althoght working little bit, think causing problems in program inserting vector of myclasses doesnt work well. could guys give me advice how correctly...

android - Problems with Sqlite cursor.getString() in if statement -

i'm having problems if-statement , comparing strings. did check out know more string comparing. how compare strings in java? if understood right "cursor.getstring(0)" return string. anyway everthing in sqlite table of type "text" guess. can print log.d string "name" , show correct word. when gets compare strings in if-statement not match anything. have no problem sqlite or other parts of code. if-statement not work here code: string food = "food"; while(cursor.movetonext()){ string name = cursor.getstring(0); log.d("name", "name: " + name); //this sprints: name: food if(name.equals(food)){ // ...do } else if (food.equalsignorecase(name)){ // ...do else } } it continue print rest of column want "do something" if find...

Plain text editor (or plugin) with ability to copy line into clipboard in just one mouse click -

i'm looking plain text editor (or plugin) ability stay on top , copy entire single line clipboard clicking somewhere within line. without need make selection or press key(s) first, click , line copied clipboard. next click inside editor's window gets line opened file copied clipboard, , on. thanks. i don't think such app exists. coz single click changes caret position only. in synwrite editor u can click line, , press ctrl+c. (first set option "copy current line if no selection made" on).

ios - Strange selection behaviour of UITableViewCell -

i'm developing project both devices - iphone , ipad. both devices have appropriate storyboard. because paradigm of ipad little different iphone, created iphone , ipad different controllers same views. other controllers use in both storyboards. faced strange bug. in table view selection occurs 1 finger touch (for iphone) in ipad same table view cell can selected double touch. has faced such strange behaviour? btw, didn't have gesture recogniser in problem table view. so, fixed strange behaviour changing way of navigation in slide controller. notices "bug" appeared when added gesture recogniser table view.

java - Sieve of Atkins, unexpected results -

so working on sieve of atkins problem 10. question: "the sum of primes below 10 2 + 3 + 5 + 7 = 17. find sum of primes below 2 million." i believe following steps correctly it's failing give right answer. import java.util.arraylist; import java.util.hashmap; import java.util.map; import java.util.map.entry; public class level_10 { public static void main(string[] args) { //sieve of atkins int limit = 2000000; long sum = 0; int ins = 2; int limitsq = ((int)math.round(math.sqrt(limit))); arraylist<long> results = new arraylist<long>(); //2, 3. , 5 primes results.add(2l); results.add(3l); results.add(5l); map<long, boolean> sieves = new hashmap<long, boolean>(); //composite list //adding sieves (int = 5; <= limit; i++) sieves.put((long) i,false); long n; (int x = 1; x < limitsq; x++) { (int y = 1; y < l...

mysql - SQL variables in queries in Java -

i want use several times same values. if use in dbforge mysql next query, set @v1 = 123, @v2='2014-04-11', @v3 = 'user1', @v4='title1'; insert test_table (tid, created, owner, title) values (@v1,@v2,@v3,@v4) on duplicate key update created=@v2, owner=@v3, title=@v4 it correctly executes, in java, when use code final string dbquerry = "set @v1 = %s, @v2='%s', @v3 = '%s', @v4='%s';\n"+ "insert test_table (tid, created, owner, title)\n" + "values (@v1,@v2,@v3,@v4)\n" + "on duplicate key update\n" + "created=@v2, owner=@v3, title=@v4"; string currentquerry = string.format(dbquerry, t.getparam("id"), t.getparam("date"), t.getparam("user"), ...

How to delete .dat file in Java? -

i want delete .dat file. code not work. string searchcust = searchcust.gettext(); file file = new file(searchcust + " booking.dat"); if (file.delete()) { joptionpane.showmessagedialog(null, "info deleted"); } else { joptionpane.showmessagedialog(null, "delete failed"); } basically when run, file not deleted , "delete failed" message appear file.delete() return true only if deletes file. meaning return false if file not exist. ensure file.exists() returns true prior invoking file.delete() : if (file.exists()) { if (file.delete()) { } else { } } also see files.deleteifexists() may provide more information, via ioexception , in event of failed deletion attempt: import java.io.ioexception; import java.nio.file.files; import java.nio.file.path; import java.nio.file.paths; try { final path p = paths.get(searchcust + " booking.dat"); if (files.dele...

java - returning a value with jOOQ and PostgreSQL serial and RETURNING -

i have postgresql uris table serial (autoincrementing) uri_id column , string uri column. can query table fine using jooq: createdslcontext().select(fieldbyname("uri_id")).from(tablebyname("uris")) .where(fieldbyname("uri").equal(uri.tostring())).fetchone(0, integer.class)) that returns java integer . when insert new uri, want generated uri_id key, try this: createdslcontext().insertinto(tablebyname("uris"), fieldbyname("uri")) .values(uri.tostring()).returning(fieldbyname("uri_id")).fetchone().getvalue(0, integer.class) this time error: exception in thread "main" java.lang.illegalargumentexception: field 0 not contained in list just test, tried supplying literal value uri_id in insert statement, still got error. it looks correct sql being generated: insert "uris" ("uri") values ('http://example.com/') returning "uri_id" but returned record emp...

Cannot reference method on Javascript object -

i'm writing version of pong in javascript. have game object , i'm using prototype property define methods on it. i'm getting following error: "undefined not function". being thrown in game.prototype.step function this.update undefined in there. here's code game object: (function(root) { var pong = root.pong = (root.pong || {}); var game = pong.game = function() { this.canvas = document.getelementbyid('canvas'); this.canvas.width = 800; this.canvas.height = 400; this.context = canvas.getcontext('2d'); this.maxstartspeed = 10; this.keysdown = {}; this.player2 = new pong.player({'player': 2}); this.player1 = new pong.player({'player': 1}); this.ball = new pong.ball(400, 200); } game.prototype.update = function() { this.player1.update(); this.player2.update(); this.ball.update(player1.paddle, player2.paddle); }; game.prototype.render = function() { this.context...

twitter - how to train a maxent classifier -

[project stack : java, opennlp, elasticsearch (datastore) , twitter4j read data twitter] i intend use maxent classifier classify tweets. understand initial step train model. documentation found have gistrainer based train method train model. have managed put simple piece of code makes use of opennlp's maxent classifier train model , predict outcome. i have used 2 files postive.txt , negative.txt train model contents of positive.txt positive positive best positive fantastic positive super positive fine positive nice contents of negative.txt negative bad negative ugly negative worst negative worse negative sucks and java methods below generate outcome. @override public void traindataset(string source, string destination) throws exception { file[] inputfiles = fileutil.buildfilelist(new file(source)); // trains both positive , negative.txt file modelfile = new file(destination); tokenizer tokenizer = simpletokenizer.ins...

javascript - Setting up Symfony2 and Backbone.js using Require.js -

i've got simple app, similar todo, entity called subject. symfony2 serve rest api , backbone app take care of happens client-side. i've been trying set project require.js loads base model , set of simple views, error: "networkerror: 404 not found - http://localhost:8000/bundles/pfiuser/js/app/.js" followed with error: script error for: http://requirejs.org/docs/errors.html#scripterror in require.js line 166 and timeout: error: load timeout modules: http://requirejs.org/docs/errors.html#timeout i don't know require.js well, reckon comes 1 of defines doesn't work. here require's configuration (i've been basing work off this tutorial ): requirejs.config({ baseurl: '{{ asset('bundles/pfiuser/js/app/') }}', paths: { text: "vendor/requirejs-text/text", jquery: 'vendor/jquery/dist/jquery', underscore: 'vendor/underscore/underscore', backbone: 'vendor/ba...

c# - Pass data from Form1 to class1 using delegate and event -

i know how pass data using event , delegate form2 form1 (backwards actually). know how appropriately form1 (main form) form2. imagine form2 , center form show progress (with progressbar) common plenty of other forms. this how like: public partial class form2 : form { public delegate void progressevent(object obj); public event progressevent onprogressshowing; public form2() { } private void showingprogress(object obj) { //calling method form1 //but must private! } } how it? like? form2 f2 = new form2(); f2.onprogressshowing += new forms.progressevent(?? ?what put inside here?? cannot access private method on form2 ???); i know 1 option create delegate , event on form1, , pass form1`s reference form2, , subscribe event form2. not like. have plenty of delegates , events in each of other forms call form2. since first form creating instance of second form , "owning" instance, appropriate des...

soap - Compilation error in scalaxb generated code (xmlprotocol.scala) - found: Boolean, required: Option[Boolean] -

i'm getting compilation error in xmlprotocol.scala generated latest scalaxb (1.1.2) large wsdl file: [info] compiling 10 scala sources /aw-scalaxb-test/target/scala-2.10/classes... [error] /aw-scalaxb-test/target/scala-2.10/src_managed/main/sbt-scalaxb/aw/xmlprotocol.scala:630: type mismatch; [error] found : boolean [error] required: option[boolean] [error] p2.headoption map { scalaxb.fromxml[boolean](_, scalaxb.elemname(node) :: stack) } getorelse { scalaxb.fromxml[boolean](scala.xml.text("false"), scalaxb.elemname(node) :: stack) }, [error] ^ [error] 1 error found [error] (compile:compile) compilation failed here corresponding piece of code (the error on first "p2.headoption map" line): ... (scalaxb.elemname(none, "historylastdate"))) ^^ { case p1 ~ p2 ~ p3 ~ p4 ~ p5 ~ p6 ~ p7 ~ p8 ~ p9 ~ p10 =...

java - JPA Composite Key with Object references -

i have faced issue while creating jpa composite key object references. entities show in bellow, 1) wan remove id field workflow entity , make composite key combining seqno field , template (object reference) field 2) according change updated existing relationship command entity (@joincolumn(name = "workflow_id", referencedcolumnname = "id")) thanks. template entity: @entity @table(name = "template") public class template implements serializable { @id @generatedvalue(strategy = generationtype.sequence) @sequencegenerator(name="template_se", sequencename="template_se", allocationsize=1, initialvalue=1) @basic(optional = false) @column(name = "id") private integer id; @basic(optional = false) @column(name = "name", unique = true) private string name; @onetomany(cascade = cascadetype.remove, mappedby = "template") @lazycollection(lazycollectionopt...

android - How to escape a JSON object to feed into a JavaScript function? -

really struggling one! i'm building android , iphone application shows webview ( uiwebview on ios). webview has html page loaded in contains simple javascript function defined follows: function parsejson(input) { alert("start of parsejson(...) javascript method"); var parsedjson = json.parse(input); alert("end of parsejson(...) javascript method"); } what want call parsejson(input) javascript function android/ios client passing in string input parameter. done follows xamarin.android: string json = "{}" mywebview.loadurl ("javascript:parsejson(\"" + json + "\")")); and follows xamarin.ios: string json = "{}" mywebview.evaluatejavascript ("parsejson(\"" + json + "\")"); up here, works fine. no problem. javascript function called , executes. also, know have double-escape quotation-mark character in string , follows: string json = "{\\\"key\\\"...

user interface - Timeline component for displaying profiling data -

i'm looking display data in timeline format profilers using: unity profiler nvidia visual profiler google chrome flamechart but cannot find framework create such graphs myself. i'm not looking specific language or gui framework, c++ or python preferred. the solution should open source , portable (linux , windows). i found needed in chromes trace-viewer .

ibm mobilefirst - Worklight Server dependencies servlet -

Image
i crating worklightauthenticator, dependecies in trouble. import javax.servlet.servletexception; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; i include library websphere application server v.8.5, did not come jars, image below. in project. did not have problem. image below. that's not working me either. provide version of worklight working ? meanwhile, workaround, liberty jars located in: {$yourworkspace}/com.worklight.studio.plugin_{$some_buildnumer_for_your_worklight}/liberty/wlp/lib

html - how to display telugu font on website -

Image
i have developed website local evening news paper in telugu language. have used display , i'm using lekhini.org or branah.com website generate telugu text using general english typing. working fine , displaying if i'm using generated text client using anu script manager , apple font, if copied text website not showing, instead showing special characters. here screenshot took, in top line flash news showing special characters telugu text typed in quark express software using apple keyboard. remaining content typed in lekhini.org website. please me how display text written apple font. in advance

javascript - Alternative solution to browser reading the contents of local file system -

i absolutely understand browser cannot read contents of local file. client still has following requirements need cater: 1). there installer create folder bunch of html , js files. html files refer js files using tag. 2). web application (running through http:/localhost/) have link, on click read required html file. i aware 1 approach using activexobject, ie specific. there alternative approach can assist me with? or should respond no solution exists such kind of scenario?

r - How to find the means of all columns of a matrix simultaneously -

i have matrix , want find means of columns @ same time. can this? below data. dta=matrix(c(11,12,10,9,15,8),nrow=2,ncol=3) how find means of columns simultaneously. function colmeans right that: > colmeans(dta) [1] 11.5 9.5 11.5

Filter Python list to remove similar values -

so have list around 100 float values between 0 , 1 , like: [0.642918256477056, 0.6429182558639024, 0.6429182466700671, 0.6429182068585415, 0.6429180997884363, 0.6428178743476422, 0.6428174651415239, 0.6428167927406518, ... ] what need way create more simple list, values same during 4 decimals removed , keep first. example: number 0,6429... repeated several times in original list, need once. after still need know values (indexes) removed can "remap" them. example: len(original_list) # result: 100 | remap 0:1 range (index0 0, index 100 1) len(filterted_list) # result: 10 for example, if index 5 of filteres_list index 80 in original_list, need know original remapped value 0.8. sorry if can't explain better, if me first part help. thank guys. use set , round: li=[0.642918256477056, 0.6429182558639024, 0.6429182466700671, 0.6429182068585415, 0.6429180997884363, 0.6428178743476422, 0.6428174651415239, 0.6428167927406518] seen=set() data...

Popup window in non activity class Android -

i want open popup window in activity want implement popup class. i'm using tutorial app crashes. call methods init() , popupinit() activity , else here: package com.example.victwo; import android.app.actionbar.layoutparams; import android.content.context; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.linearlayout; import android.widget.popupwindow; import android.widget.textview; public class popupaudio implements onclicklistener { linearlayout layoutofpopup; popupwindow popupmessage; button poprecord, popstoprecord, popplay, popstopplaying; textview popuptext; public void popupinit() { poprecord.setonclicklistener(this); popstoprecord.setonclicklistener(this); popupmessage = new popupwindow(layoutofpopup, layoutparams.wrap_content, layoutparams.wrap_content); popupmessage.setcontentview(layoutofpopup); } public void init(...

html - how to select a class which is children of many elements -

<div class="rightsidebox"> <div class="item-info-list"> <p>model: aidcu</p> <div class="product-details"> <p></p> <div class="price-box"> <span class="regular-price" id="product-price-1617-related"> <span class="price">$8.99</span></span> </div> <p></p> </div> </div> i want make style price , make color green in case in rightbox div , want use css , cannot change structure because theme , should not have conflict other prices in other themes i can use div.rightsidebox>div.item-info-list but cannot go further because of paragraph in there how can solve it? have weakness in using ">" , multiple classes in each other .rightsidebox .price { color: green !important; } // important override other styles...

java - Finding if a specific character exists at a specific index -

so i'm trying figure out how create condition decision structure. i'm making program converts military time conventional time. when times entered, must in xx:xx format, x equals digit. i'm wondering, how can make validation checks make sure ":" exists colon , in same spot? mystring.charat(5) == ':' just change 5 whatever need, , check string length before this, don't ask past end of short string.

Rails 4.0.4, ruby 2.1.0, Ubuntu 12.04 rake db:create fails, postgresql making me sad -

using ubuntu 12.04 i know problem isn't new, googled extensively, check stackoverflow, followed solutions suggested letter - alas, no avail. i have app in rails 4.0.4, ruby 2.1.0, deploy heroku. have: installed pg 0.15.1 (tried 0.17.1 well) gem, sudo apt-get installed postgresql, added host: localhost database.yaml file, edited /etc/postgresql/9.1/main/postgresql.conf , uncommented listen_addresses = 'localhost', added user 'postgres' password 'blah' psql database, tried rake db:create - failed spectacularly. please advise. fatal: password authentication failed user "postgresql" fatal: password authentication failed user "postgresql" /usr/local/lib/ruby/gems/2.1.0/gems/activerecord-4.0.4/lib/active_record/connection_adapters/postgresql_adapter.rb:848:in `initialize' /usr/local/lib/ruby/gems/2.1.0/gems/activerecord-4.0.4/lib/active_record/connection_adapters/postgresql_adapter.rb:848:in `new' /usr/local/lib/ruby...