Posts

Showing posts from February, 2014

PHP LOAD DATA LOCAL INFILE Realtime Update MySQL -

good evening, i having problems trying achieve in php/mysql. i have text file (in real time) taking 1 row of numbers i.e. 1.43 etc sensor on com port. information needs sent mysql pretty in real time. as test have used text document without real time using php load data local infile seems sending data mysql database. my question is, how send data 1 second, next second send latest information not on mysql database, otherwise have loads of duplicate data? my current code follows: <?php $username = "root"; $password = ""; $hostname = "localhost"; // connect database , table $dbhandle = mysql_connect($hostname, $username, $password) or die("unable connect mysql"); echo "connected mysql<br>"; $selectdatabase = mysql_select_db("data",$dbhandle) or die("could not select iwemsdata"); echo "connected iwemsdata<br>"; // text file read in $textfile = 'data.txt'; mys

webos - enyo mixin: Is this proper usage? -

i have following code, looks following: var shared = { create: function(){ //do stuff on create } } enyo.kind(enyo.mixin({ name: "custominput", //properties unique input. kind: enyo.input },shared)); enyo.kind(enyo.mixin({ name: "customtextarea", //properties unique input. kind: enyo.textarea },shared)); enyo.kind(enyo.mixin({ name: "customselect", //properties unique input. kind: enyo.select },shared)); i'm being informed peers incorrect way of doing things, , potentionally break something, or confusing because they've never seen mixins used in way. my question is, there wrong doing this, in way? if extending kinds mixins, here newer way this: enyo.createmixin({ name: 'mymixin', mymethod: function() { // stuff } }); enyo.control.extend({ mixins: ['mymixin'] }); this mix in before instantiation. if wish add properties @ run time,

android - Clear Data on update -

i'm maintaining long living app on android, , i've decided change data model behind merging few sqlite databases single new one. the thing is, if create new db , stop using old ones, every app user out there still have old sqlite files in local storage. is there way force "clear data" upon new version of app? (i'm looking "right" way it, know can check if new db exists , act according, think there may better way) thanks whenever database needs upgraded(when user downloads new version of app, example), change in database version number calls onupgrade() method, can override thiis method provided sqliteopenhelper class: @override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { log.w("taskdbadapter", "upgrading version "+oldversion +" "+newversion +", destroy old data"); (string string : table_names) db.execsql("drop table

hibernate - Order second table before joining -

i have topicentity contains many postentity . each postentity belongs 1 topicentity . need sort topics last post creation date, creationdate property of newest post in topic. what think needs happen: get topics join posts belong topic sort posts creation date get newest post each topic , use date sort topics this have currently: this.session.createcriteria(topicentity.class, "topic") .createalias("topic.posts", "post", criteriaspecification.left_join) .addorder(order.asc("post.creationdate")).list(); this not sort topics in way. believe because not perform points 3 , 4 list. anyway, hint me proper way of achieving desired result? prefer criteria, if hql required, that's fine.

vb.net - Get file from "Windows Explorer - Open With" -

i'm not quite sure start this. on right-clicking on generic file in windows explorer (e.g. *.doc word document) 1 can choose "open with...". 'd know how program knows file has been "passed" (is right word?). done via arguments? how can implement in own application? i tried manually adding file path arguments of 1 of applications when run, path includes spaces (which denotes new argument). how windows round this/what need solve this? regards, robbie to retrieve arguments used command line: private sub form1_load(sender object, e system.eventargs) handles me.load dim smsg string = "" each sarg string in my.application.commandlineargs smsg &= sarg & ": " next msgbox(smsg) end sub place code in winform _load, console main, etc. if above run with: hello world command line hello: world: display.

Is there a Java/JVM server that supports streaming binary over websocket? -

does there exist open source java server/library/framework supports bidirectional streaming of binary on websockets? looked @ couple of them couldn't find them mentioning binary support. this explains want do, think: http://binaryjs.com/ want java/jvm server instead of node.js. so, want send raw bytes , forth between client , server little overhead possible. if there one, direct link documentation using binary appreciated. tomcat 7 has built in support web sockets via org.apache.catalina.websocket.websocketservlet . there example of writing binary data using subclass of class here: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/examples/web-inf/classes/websocket/echo/echostream.java?view=markup high level root of how-to here: http://tomcat.apache.org/tomcat-7.0-doc/web-socket-howto.html

android - Light Sensor collecting inaccurate data -

i collecting data light sensor amount of time: msensormanager.registerlistener(this, lightsensor, sensormanager.sensor_delay_fastest); the problem values collected not accurate , frequent. "not accurate", mean if start sensor @ time, first reading old 1 of long before began collecting data. also, since delay declared sensormanager.sensor_delay_fastest , lot of values , sometime 100s of records in 1 second , sometime not 1 reading in 3 seconds. can explain issue might , if there solutions please? i believe because these light sensors send data when there change in light. not readings if light level not change, if wave hand in front of or turn dimmer switch slowly, 100s of readings.

I use mkdir in Perl. It makes dir, but sometimes it adds a ? to the end of the directory name -

here code: foreach $name ( @unique_gene_list ) { print "$name\n"; chomp $name; unless(mkdir $name, 0700) { die "unable create directory called $name\n"; } } this works, mostly. reason, 1 of directories given name ends ?. should note directory name showing in terminal window shows question mark. in finder, there no question mark @ end of directory's name. use perl v.5.12.3, on mac os 10.7.5. the file reading has lines ending in crlf. removing lf chomp , cr (represented ^m) isn't removed. instead of chomp; , use s/\s+\z//; . while (<$fh>) { s/\s+\z//; ... }

Grabbing values from Hash ruby -

bit lost on one. grabbing table data http://www.bbc.co.uk/sport/football/tables using nokogiri. sort unsure how grab of data wanted, kindly provided example of looks so require 'open-uri' require 'nokogiri' url = 'http://www.bbc.co.uk/sport/football/tables' doc = nokogiri::html.parse(open url) teams = doc.search('tbody tr.team') keys = teams.first.search('td').map |k| k['class'].gsub('-', '_').to_sym end hsh = teams.flat_map |team| hash[keys.zip(team.search('td').map(&:text))] end puts hsh im little unclear of this, can see final output hsh gives hash example {:statistics=>"", :position=>"no movement 20", :team_name=>"reading", :played=>"33", :home_won=>"4", :home_drawn=>"7", :home_lost=>"6", :home_for=>"23", :home_against=>"31", :away_won=>"1", :away_drawn=>&qu

sql - Row repeating when using TOP on odd number of rows -

i'm using following queries produce 2 forms, each displaying half of items in table. selects top half: select top 50 percent * products order products.product_id; and selects bottom half select top 50 percent * products order products.product_id desc; the obvious problem when items odd, middle item displays on both forms. tried solving using count() function in various ways not work top. how else can this? ignore odd number of rows issue when define first half. define second half rows not present in first half. use subquery in() , left join approach faster. select secondhalf.* products secondhalf left join ( select top 50 percent product_id products order product_id asc ) firsthalf on secondhalf.product_id = firsthalf.product_id firsthalf.product_id null; the subquery, firsthalf , same first query in question. in situation, need product_id subquery. left join in main query means return rows products ...

report - Show multiple drillthrough tables in a single Excel sheet -

i need create report (for printing) has 2 sections. top section contains scorecard, , bottom section contains drillthrough information "red" items in scorecard. the scorecard powerpivot table conditional formatting. if scorecard has 3 "red" cells, can double-click on each of red cells drillthrough details. however, display 3 drillthrough tables in same worksheet below scorecard, can print both scorecard , drillthrough details @ once. i'm looking solution automated. each time print out report, can lot of copy , paste, rather not. i'm looking solution automated possible - bottom section of report contain details red in scorecard. i'm open using vba. thanks! i suggest use vba. first store list of sheets in 1 of sheets vba code use. create following subroutine in workbook code section have trigger when new sheet selected: private sub workbook_sheetchange(byval sh object, byval target range) now add code subroutine verify if sheet selec

c++ - Empty borderless window not showing? -

i'm trying use following code show empty border-less window, no windows appear @ all. followed documentation: hwnd hwnd = createwindowex(ws_ex_topmost,null,null,ws_popup,0,0,1000,1000,null,null,null,null); showwindow(hwnd, sw_show); hwnd hwnd = createwindowex(ws_ex_topmost, l"static", null, ws_popupwindow, 0, 0, 100, 100, null, null, null, null); showwindow(hwnd, sw_show);

Ways to improve AngularJS performance even with large number of DOM elements -

i'm evaluating whether or not use angularjs web project, , i'm worried performance feature need implement. know if there's better way implement functionality i'm trying in angularjs. essentially, seems me time takes angularjs react event dependent on number of dom elements in page, when dom elements aren't being actively changed, etc. i'm guessing because $digest function traversing entire dom.. @ least experiments, seems case. here's play scenario (this isn't i'm trying do, close enough testing purposes). i have angularjs highlight word hover on it. however, number of words in page increases, there's larger delay between when hover on word , when highlighted. the jsfiddle shows this: http://jsfiddle.net/czerwin/5qfzg/4/ (credit: code based on post peter bacon darwin on angularjs forum). here's html: <div ng-app="myapp"> <div ng-controller="controllera"> <div >

r - Predicting LDA topics for new data -

it looks question has may have been asked few times before ( here and here ), has yet answered. i'm hoping due previous ambiguity of question(s) asked, indicated comments. apologize if breaking protocol asking simliar question again, assumed questions not seeing new answers. anyway, new latent dirichlet allocation , exploring use means of dimension reduction textual data. extract smaller set of topics large bag of words , build classification model using topics few variables in model. i've had success in running lda on training set, problem having being able predict of same topics appear in other test set of data. using r's topicmodels package right now, if there way using other package open well. here example of trying do: library(topicmodels) data(associatedpress) train <- associatedpress[1:100] test <- associatedpress[101:150] train.lda <- lda(train,5) topics(train.lda) #how can predict topic(s) "train.lda" each document in "test&quo

reduce CPU usage in while loop -

how limit cpu of while loop? (cpu usage 100%) in case, code inside while loop: sub start() listenerthread = new thread(addressof listen) listenerthread.isbackground = true listenerthread.start() end sub enter code here sub listen() try listener = new tcplistener(new ipendpoint(ipaddress.any, port)) listener.start() a: while (true) thread.sleep(600) dim c new connection(listener.accepttcpclient) addhandler c.gotinfo, addressof gotinfo addhandler c.disconnected, addressof disconnected end while catch ex exception goto end try end sub

php - add edit button to each row in html table, to edit database -

i relatively new php, , need program doing internship... on page trying create, queried records in mysql database, , inserted them html table. trying do, add edit button in separate column of each row of table, rows can edited.. know how button there, not know how can values out of particular row, php variable can perform more queries edit, delete, etc... have been looking couple days, , looks may possible javascript, have never used javascript before, not know im looking at... appreciated basically: <html> <table border="1"> <th>suspended</th> <th>device name</th> <th>ip</th> <th>depend</th> <th>email</th> <?php $sql = "select * table;" while($row=mysql_fetch_assoc($sql)) { echo "<tr><td>".$row[0]."</td><td>".$row[1]."</td><td>".$row[2]."</td><td>".$row[3]." </td><td>&quo

hadoop - Will reducer out of java heap space -

Image
i implementing program using hadoop. question how deal java out of space problem, added property configuration xml file, didn't work. increasing number of reducers doesn't work me either. because in program every reducer needs large sparse whole matrix, , not allowed change logic. yet every reducer receive entry column id key, , column vector value.is there way can out of dilemma? ps:i first thinking reducer take column 1 one, , won't cause out of memory issue. seems not way. actually, trying implement algorithm described in paper. algorithm reducer listed below. line 11 column mentioned, , each reducer has every column of matrix. the reason why use hadoop because cant fit entire data set memory. either don't change logic , try find computer that's big enough or parallel-ize algorithm , exploit hadoop.

Arduino Serial write -

i trying use arduinon serial.write(buf, leng). here code byte buf[] = {125, 126, 127, 128, 129}; void setup() { // initialize serial: serial.begin(9600); } void loop() { int = serial.write(buf, sizeof(buf)); serial.println(i); delay(1000); } however, when open serial monitor prints out }~ 5 }~ 5 }~ 5 }~ 5 first off, read write writes binary data serial port , print ascii characters. how come see ascii characters? the second question how come nothing on 127 appears? whenever serial.write(>127) shows in serial monitor goofy output? is because of computer's side of serial? my main goal write 32 bytes serial @ once in same payload of xbee transmitting package. ?? the output correct. writing binary data, trying see them ascii, that's why see example } instead of 125 , because 1 byte 125 represents } in ascii. 125 take 3 bytes show ascii. you seeing weird stuff when write byte greater 127, because ascii includes definitions 12

android - java.lang.SecurityException: Destination must be on external storage -

in android tv, u disk mount /mnt/usb/sdb4, use android downloadmanage, file pathyr = new file("/mnt/usb/sdb4"); uri downloaduri = uri.parse(download_file); downloadmanager.request request = new downloadmanager.request(downloaduri); request.setdestinationuri(uri.fromfile(new file( pathyr,"100mb.jpg") )); 04-20 10:54:05.593: w/dalvikvm(2315): threadid=1: thread exiting uncaught exception (group=0x40f771f8) 04-20 10:54:05.665: e/androidruntime(2315): fatal exception: main 04-20 10:54:05.665: e/androidruntime(2315): java.lang.securityexception: destination must on external storage: file:///mnt/usb/sdb4/100mb.test.test 04-20 10:54:05.665: e/androidruntime(2315): @ android.os.parcel.readexception(parcel.java:1327) 04-20 10:54:05.665: e/androidruntime(2315): @ android.database.databaseutils.readexceptionfromparcel(databaseutils.java:181) 04-20 10:54:05.665: e/androidruntime(2315): @ android.database.databaseutils.r

.htaccess - How to perform htaccess rewrite -

here summary of problem. i have created facebook button. works correctly of time, not when following link somebody's actual "like" post. seems facebook adding more info url. instance, have www.example.com/blog.php/6 but facebook adds www.example.com/blog.php/6?fb_action_ids=10201090685057512&fb_action_types=og.likes&fb_source=aggregation&fb_aggregation_id=288381481237582 when user follows link mysql syntax error. if follow first link there no problem. thought strip off text url. i created .htaccess file , placed in root directory on godaddy. tried several different rewrites. nothing has worked. latest thought tried: options +followsymlinks rewriteengine on rewritecond %{query_string} ^(.*&)?fb_action_ids= rewriterule ^(.*)$ $1?%1 [r=301] do need change .htaccess file or there way solve problem? thanks help.

java - Why is my program catching / throwing a FileNotFoundException when the file exists? -

java newbie here! i'm writing program practice reading input , writing output files. i've finished coding program, when run it, program catches , proceeds filenotfoundexception. the file in source folder program, , i've tried placing in every folder related program. i've tried: declaring exceptions in method header surrounding section-in-question try/catch block. both of above together. here's relevant code causing problems. there sticks out i'm missing? public static void main(string[] args) throws filenotfoundexception { scanner keyboard = new scanner(system.in); string playerhighestscore = "", playerlowestscore = ""; int numplayers = 0, scorehighest = 0, scorelowest = 0; system.out.println("enter input file name: "); string inputfilename = keyboard.nextline(); string outputfilename = getoutputfilename(keyboard, inputfilename); file

mysql - php variable isn't visible inside of IF statement -

i have 2 steps sign form. first step i'm picking email , username , second step want pick first name , lastname , add db. problem variables i've got first post form, $bridge_username exact, not available in if statement below (the first 1 bottom). thing visible anywhere else, not inside particular if statement. i've tried everything, including sessions. can see variable still there (using vardump or echo ing out), everywhere not need it... i'll happy hear advises. $bridge_email = $_post['email']; $bridge_username = $_post['username']; $bridge_pass = $_post['password']; $bridge_pass_conf = $_post['passconf']; $bridge_terms = $_post['terms']; $bridge_pass_counted = strlen($bridge_pass); $bridge_username_counted = strlen($bridge_username); if (isset ($_post['email']) , isset ($_post['password']) , isset ($_post['passconf']) , isset ($_post['username'])) { if ($bridge_email != '' ,

javascript - How do I refer to a variable stored in an array instead of its value? -

i have set of variables represent prices , number of items sold in 2d array. have sorted in order find lowest price. i'd set second variable (number sold) of first item (player a) value (200) referring array. for example: var playerasold; var arr=[ [playeraprice,playerasold], [playerbprice,playerbsold], [playercprice,playercsold]]; arr[0][1]=200; this doesn't work, because playerasold has value of 0 , trying set 0=0. how refer variable , not value of variable? javascript has no notion of c's pointers or c++'s references, you'll have in different way. rather trying store references in array, try making array sole holder of data. might this: var players = [ { price: 5, sold: 1 }, { price: 3, sold: 6 }, { price: 9, sold: 2 } ]; then rather than, say, playerbsold , can use players[1].sold . can use variable in place of 1 if wanted.

ios - NSURLErrorDomain error -1021 -

i'm developing app integrated dropbox. login done i'm able create folder in dropbox. when try load file i'm getting error following error i'm getting error making request /1/files_put/dropbox/info.plist - error domain=nsurlerrordomain code=-1021 "the operation couldn’t completed. (nsurlerrordomain error -1021.)" userinfo=0x6859bc0 {destinationpath=/info.plist, sourcepath=/users/bcod/library/application support/iphone simulator/5.0/applications/0e1ee43c-8f6b-40fa-8696-d3992da2dce5/dbroulette.app/info.plist} i'm not getting error when i'm creating folder. i had same problem ios 5.0 on iphone, iphone 6.1 simulator worked without creating error messages. i took dropboxsdk / dbrestclient.m, last lines of uploadfile:topath:frompath:params , implemented categorie 'exbody' on dbrequest add connection:neednewbodystream method: #import "dbrequest+exbody.h" @implementation dbrequest (exbody) #pragma mark nsurlconnection

c++ - A *a = new A(); Does this create a pointer or an object? -

a *a = new a(); does create pointer or object? i c++ beginner, want understand difference. both: created new instance of a (an object), , created pointer called a . you separate 2 statements: a *a; // declare `a` of type: pointer `a` = new a(); // create new instance of `a` , // assign resulting pointer `a`

magento - Getting the category name of multi level -

i'm working on website , got name of parent category of category. how can name of main category contain multiple subcategory. main category "a" has "b" sub category inturn has "c" subcategory, subcategory called "d". managed name of category "a" if products in category "b". not getting how category name "a" if products in category "d". please in this. code parent name goes this. $currentcat = mage::registry('current_category'); $parentid = mage::registry('current_category')->getparentid(); $parent = mage::getmodel('catalog/category')->load($parentid); $parentname = $parent->getname(); the above code fetch parent category name of current category. how multi level parent name. please me on this. i'm newbie magento. ` $parentid = mage::registry('current_category')->getparentid(); $parent = mage::getmodel('catalog/category')->load

jquery - Dynamically change the content of the tooltip in kendoui -

i have drag , drop functionality. when element dragging, want dynamically set position of element , display in tooltip . how can able using kendoui. i have defined like: <div id='drag'><p>drag me</p></div> i have defined tooltip like: $("#drag").kendotooltip({ position:"top", content: "initial" }); thne dragging $("#drag").draggable({ drag: function(){ $("#drag").data("kendotooltip").content("dragging"); }, stop: function(){ $("#drag").data("kendotooltip").content("drag stopped"); } }); and want show tool tip on div continuously on dragging . how can appreciated try 1 friend, $("#drag").data("kendotooltip").options.content = "set content here..."; $("#drag").data("kendotooltip").refresh();

How do I pass a variable to the layout using Laravel' Blade templating? -

in laravel 4, controller uses blade layout: class pagescontroller extends basecontroller { protected $layout = 'layouts.master'; } the master layout has outputs variable title , displays view: ... <title>{{ $title }}</title> ... @yield('content') .... however, in controller appear able pass variables subview, not layout. example, action be: public function index() { $this->layout->content = view::make('pages/index', array('title' => 'home page')); } this pass $title variable content section of view. how can provide variable whole view, or @ least master layout? if you're using @extends in content layout can use this: @extends('master', ['title' => $title])

php - preg_replace not ignoring [] from string -

this code : $string = "hello text [readmore] , remaining text"; echo preg_replace("[readmore]","",$string); this expected output : hello text , remaining text this actual output : hello text [] , remaining text question simple how ride of "[]" ? you need escape [ & ] . try below regexp, preg_replace("/\[([^\[\]]++|(?r))*+\]/", "", $string); output: hello text , remaining text codepad demo.

javascript - I would like to call setinterval, and when set interval completes, change the page -

i use set interval, , when interval completes, change page - however, below, changes page after 1 interval run when want to change page when mynumber >= 300. i'd grateful of help, thanks var mynumber = 0; function openportal() { var myinterval = window.setinterval(myzoom,2); document.location.href ="http://next page"; } function myzoom () { if(mynumber>=300){ clearinterval(myinterval); } mynumber++; } the problem calling document.location.href ="http://next page"; in openportal method, set interval , redirect page new location. var mynumber = 0, myinterval; function openportal() { myinterval = window.setinterval(myzoom,2); } function myzoom () { if(mynumber>=300){ clearinterval(myinterval) document.location.href ="http://next page"; } mynumber++; }

raspberry pi - Raspberrypi Python bus.read_byte -

is there python function respond wire.available function in arduino data on wire rather having specify how many bytes grab? this have now, , works fine, have know how data coming down wire, or provide unexpected results. for in range(0, 13): data += chr(bus.read_byte(address)); thanks! not perfect solution, found way around knowing how many bytes on way. on arduino, specified max size of buffer, (128), add data, 0 out rest, , send whole thing. on pi, receive whole buffer, , first thing happens filter \x00 characters. it's not perfect, works now. for in range(0, 128): data += chr(bus.read_byte(address)) print repr(data) #prints whole string received data = filter(lambda a: != '\x00') print repr(data) #prints string without '\x00' characters.

heap - How does Windows keeps track of the size of VirtualAllocdBlocks? -

i wonder how windows keeps track of size of "virtualallocdblocks". according windbg memory blocks managed in doubly linked lists. struct (_list_entry) contains 2 pointer. how can size (in windbg) of such block , size stored in memory? 0:008> dt _heap 0x00150000 ntdll!_heap ... +0x050 virtualallocdblocks : _list_entry [ 0x3e40000 - 0x13950000 ] ... 0:008> dt _list_entry 0x3e40000 ntdll!_list_entry [ 0x3f50000 - 0x150050 ] +0x000 flink : 0x03f50000 _list_entry [ 0x4050000 - 0x3e40000 ] +0x004 blink : 0x00150050 _list_entry [ 0x3e40000 - 0x13950000 ]

c# - Loop through checkbox dynamically to check it is true or not -

i have 37 checkboxes on form. have kept each check box names like: p1 p2 p3 ......... p36 p37 . in vb.net use loop through controls doint string control casting , values of checkboxes. the below vb.net code, use , works. dim start integer = 0 dim stradd string = "" integer = 1 37 const chk string = "p" dim chkbox checkbox = ctype(per_box.controls(chk & i), checkbox) if chkbox.checked = true if start = 0 stradd = stradd + "1" start = 1 else stradd = stradd + ":1" end if else if start = 0 stradd = stradd + "0" start = 1 else stradd = stradd + ":0" end if end if next however, while creating c# application, tried

ruby on rails - Cannot access sinatra app through the local network -

Image
i have rails application. if start rails s (port 3000), works both on machine , every device on local network via ip address (192.168.0.3 in case). have sinatra application. if start ruby app.rb (port 4567), works on machine, it not accessible other devices on local network. both application use thin app server. is related how sinatra works? try ruby app.rb -o 0.0.0.0 or ruby app.rb -e production . either should work.

unity3d - Mass-Replacing Objects using Unity's label tags? -

im working on exercise, want create technical design documentation. therefore, need evaluate possible solutions bunch of problems coming fictional project. here's quick glance @ exercise: the game's art & core game design split harshly - basically, core system, game mechanics , design created abstract, in order allow them work wide variety of art settings. also, 1 of restrictions re-use many assets, levels & designs possible. now question: i want level designers create levels using "template" objects (object have technical features required, ie slots attachments, correct scale, textures etc) , later replace these objects set of assets receive outsourcer. since dont want manually replace objects whenever new set of assets, wanted do: each template object gets descriptive label, , each asset delivered outsourcer needs have exact same label name corresponding template-counterpart stored in (for example custom attribute, channel, or in name). i

How to form connection between HSQLDB and C# .net? -

how form connection between hsqldb , c# .net ? have looked @ sharphsql , h2sharp not able connect hsqldb. try this: make sure you've add hsqldb.dll, ikvm.openjdk.core.dll, ikvm.openjdk.jdbc.dll reference. if don't have ikvm library, can download here . at c#: using java.sql; //add this. for create connection: private connection getconnection() { drivermanager.registerdriver(new org.hsqldb.jdbcdriver()); connection conn = drivermanager.getconnection("jdbc:hsqldb:hsql://[host]/[db name]", "[username]", "[password]"); return conn; } how use it: public void loadsetting(string userid) { connection conn = null; try { //connect it! conn = getconnection(); string query = "select a.* table a"; preparedstatement ps = conn.preparestatement(query); resultset rs = ps.executequery(); while (rs.

Vertical Scroll bar with Horizontal Scroll Android -

Image
running "unable scroll" issues i trying customized vertical scrollbar working ability scroll horizontally. i trying put 7 vertical scrollbars (@+id/verticalseekbar, @+id/verticalseekbar_2 etc.) in horizontal scrollbar. i (with of stackoverflow) able custom vertical scrollbar. however, unable scroll through horizontally. want able scroll horizontally doesn't work. attached image of how want be. here code activity_vertical_slider <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <com.example.verticalsliderandroid.hscroll android:id="@+id/hscroll" android:layout_width="400dp" android:layout_height="wrap_content"> <relativelayout android:id="@+id/relative_layout_sample"

c# - Open folder issue -

i want open folder file had been saved , select file, use little code: var psi = new processstartinfo("explorer.exe", "/select," + dlg.filename); process.start(psi); it works perfectly. i need put code in several places decided create method, there condition in method: private static void openfolderandselectmyfile(string filename) { if (mysettings.default.openfolder == true) { var psi = new processstartinfo("explorer.exe", "/select," + filename); psi.windowstyle = processwindowstyle.maximized; process.start(psi); } } this doesn't work expected: opens parent folder (of folder containing file). selects folder. why difference in behavior , how solve it? the way occur, filename isn't in original code. code same, , work expected, if filename in fact in original code location. it's filename full path folder rather full path file including file na

html - CSS positioning of error messages exactly above the input text box inline -

Image
hi looking design css html pages , below m problem. have 2 text boxes side side put in inline container. i validating inputs , want display error message above respective text box. so, have created spans , put them in inline-container of lesser height , thought of displaying. problem is: case-1 : validation message second text box shifts left if length of error message short. how avoid this? case-2 : if validation message input text box 1 long, making error message of text box 2 shift extreme right. in case, want validation message of text box 1 in multiple lines above area of text box 1 my html: <div class="inline-container1"> <ul><li><span class="validationmessage" data-bind="validationmessage: firstname" /></li> <li><span class="validationmessage" data-bind="validationmessage: lastname" /></li> </ul> </div> <

c# - Resharper with COM interop complains "Cannot access internal constructor" -

i have ocx file built using vb6 i'd access c#. added reference ocx in c# project, , added code instantiate object ocx: var blah = new blah(); this compiles fine, without errors or warnings, , seems work expect - can call methods on blah object , seem expect them do. however, if go resharper / inspect / code issues in solution, resharper complains above quoted line "c# compiler error", saying "cannot access internal constructor 'blahclass' here". since it's claiming it's c# compiler error, yet seems compile (and in fact work) fine, i'm guessing it's issue resharper itself. however, i'm pretty new this, , i'd make sure. perhaps i'm doing not correct way of instantiating object ocx, or that? i using vs2012 professional , resharper 7.1.3. the c# compiler looks @ coe , sees invocation of "dynamic" code (code objects may have new methods/properties available after execution started) , can't

c# - Stay in Datagrid edit mode when data is not valid -

i'm new wpf. windows forms , datagridview can force user stay in edit mode if value entered in grid not valid (for example when entering letters in column valuetype set double) code this: datagridview grid = new datagridview(); grid.dataerror += (sender, e) => { }; i'm trying have similar behavior wpf datagrid no luck. tried following binding options: datagrid.columns.add(new system.windows.controls.datagridtextcolumn() { header = "aheader", binding = new system.windows.data.binding("aproperty") { validatesondataerrors = false, validatesonexceptions = false } }); but can't see change @ all. entering non valid data causes app crash. idea please?

How to control an animation by touch position along a path in Unity3D? -

Image
i have gameobject want animate along specific path/curve, animation should controlled mouse/touch position. when touch/click on gameobject , move finger/mouse on/near path (or maybe easier move down) gameobject should follow defined path. i itween, think not possible find solution using here, right? edit: added image: it's quite simpler task might think. basically it's question of remapping function (that takes input parameter) function (that express position along path). there several ways of doing that, depending on precise effect want implement. the important choices have take are: how describe path/curve how handle input example for path easy , flexible way use sort of spline curves, such cubic bézier curve . it's easy implement , unity3d provides built-in functions draw them. have @ handles.drawbezier . basically bézier function takes input parameter t in domain [0,1] , return result point in space (2d or 3d prefer). b(0) gives point

javascript - regex match numbers with potential letters -

i need match js: a number, which potentially can followed letter (or two), and may separated space or hyphen for example: 23 4545a 1b 554 cs 34-s regex not strong suit, i've got this... ^[0-9a-za-z ]+$ updated: ^(0-9a-za-z )+$ aaaaand, mine hybrid of other answers. :) /^\d+[ -]?[a-z]{0,2}$/i \d+ = 1 or more digits [ -]? = optional space character (note: space only, not "whitespace") or dash [a-z]{0,2} = 1 or 2 alpha characters (note: lowercase @ moment, keep reading . . .) the i @ end of pattern makes case insensitive, [a-z] match upper or lower-case alphas edit - okay, found error in of our answers. lol because alpha pattern allow 0 characters @ end , space , dash optional, regexes we've provided far result in false positive following test data: 123- , 456 <--- space @ end the second 1 resolved using $.trim() on value (if allowed trying test), first 1 can't. so . . . brings new regex handle situat

linux - Parsing a file which is separated by "categories" -

here issue: a) i'm scripting newbie b) have file need data separated csv style table, problem there 3 areas of data (see below): (area 1, not relevant) total ipv4 packets captured: 2245686 # l4 protocol # packets relative frequency[%] protocol description 1 5602 0.249456 internet control message protocol .... (more data here) (area 2, relevant) total tcp packets: 2238186 # port # packets relative frequency[%] protocol description 22 2138555 95.548583 secure shell (ssh) protocol .... (more data here) (area 3, relevant) total udp packets: 1623 # port # packets relative frequency[%] protocol description .... (more data here) (area 4, relevant) total scp packets: 0 # port # packets relative frequency[%] protocol description .... (more data here) (this tranalyzer _protocols output) so need make output like: # port,# packets,relative frequency[%],protocol description 22,2138555,95.548583,the secure shell (ssh) protocol,(more data...

apache - Android FTPClient ftpClient = new FTPClient(); causes crash only in release version -

i using apache commons-net-3.3 jar , have researched previous threads make sure configured correctly in build path. my android app works fine in debug mode on several tablets when release code using ant , publish it, code falls on @ :- ftpclient ftpclient = new ftpclient(); with no error message on same tablets: code follows. import org.apache.commons.net.ftp.ftp; import org.apache.commons.net.ftp.ftpclient; @override protected string doinbackground(void... params) { file file = new file(mdbpath); try{ ftpclient ftpclient = new ftpclient(); inetaddress mhostname; mhostname = inetaddress.getbyname(mserverip); ftpclient.connect(mhostname, mport); ftpclient.login(mlogin, mpassword); ftpclient.changeworkingdirectory(mworkingdir); if (ftpclient.getreplystring().contains("250")) { ftpclient.setfiletype(f

javascript - Jquery stopwatch with milliseconds (accurate) -

i'm trying create stopwatch miliseconds accurate possible. of course browser/server/cpu or whatever need more 1 ms execute function , display digit on watch. thought want reset ms 0 each time second goes up. jquery code looks this. (function($) { $.fn.stopwatch = function() { // element html code added var clock = $(this); var timestamprunningms; var timestampstartms; var milliseconds = 0; // predefinition of timestamprunningseconds variable var timestamprunningseconds; var display = clock.find("#display"); var time = clock.find("#time"); // predefinition of seconds variable // value 0 because used define // timestampstartseconds variable in click-event var seconds = 0; // predefinition timestampstartseconds variable var timestampstartseconds; // predefinition timer variable var timer; // time variab

objective c - Strikethrough Text with Animation iOS -

what best way display strikethrough animation? when user swipes finger across uitableviewcell, animate thin line across cell.textlabel.text the 2 ways i've thought of far using animation or somehow displaying custom image , revealing left right? have advice on this? i have swipe gestures working, need know how make animation happen: add gesture recognizer: //add left swipe gesture recognizer uiswipegesturerecognizer *recognizer = [[uiswipegesturerecognizer alloc] initwithtarget:self action:@selector(handleswipeleft:)]; [recognizer setdirection:(uiswipegesturerecognizerdirectionleft)]; [self.tableview addgesturerecognizer:recognizer]; //add right swipe gesture recognizer recognizer = [[uiswipegesturerecognizer alloc] initwithtarget:self action:@selector(handleswiperight:)]; recognizer.delegate = self;

r - GBM multinomial distribution, how to use predict() to get predicted class? -

i using multinomial distribution gbm package in r. when use predict function, series of values: 5.086328 -4.738346 -8.492738 -5.980720 -4.351102 -4.738044 -3.220387 -4.732654 but want probability of each class occurring. how recover probabilities? thank you. take @ ?predict.gbm , you'll see there "type" parameter function. try out predict(<gbm object>, <new data>, type="response") .

java - Reading file from JApplet -

i need read certificate file ( private.der ) japplet create privatekey rsa, getting error access denied ("java.io.filepermission" "private.der" "read") i have learned japplet running in sandbox , can't access files long not assigned. correct me if wrong. i signed , worked: keytool -genkey -keyalg rsa -alias mykeyname keytool -export -alias mykeyname -file mycertname.crt jarsigner "rsa.jar" mykeyname but still error filepermission error. java code file f = new file("private.der"); fileinputstream fis = new fileinputstream(f); datainputstream dis = new datainputstream(fis); byte[] keybytes = new byte[(int) f.length()]; dis.readfully(keybytes); dis.close(); pkcs8encodedkeyspec spec = new pkcs8encodedkeyspec(keybytes); keyfactory kf = keyfactory.getinstance("rsa"); privatekey key = kf.generateprivate(spec); if there flag / parameter disabling sandbox in google chrome, please give me. testing anyway --all

android - Unit Test Interaction Between Activity and Service -

how can test interaction between activity , service? for example, have service manages current music player play queue , activity displays play queue user. want test activity correctly displays play queue. public class viewavailablesongsactivitytests extends activityinstrumentationtestcase2<viewavailablesongsactivity> { public viewavailablesongsactivitytests() { super(viewavailablesongsactivity.class); } public void testoneavailablesong() { songparcel song = new songparcel("test title", "test artist", "content://testuri"); addsongtoavailablelist(song); activity activity = this.getactivity(); listview lstavailablesongs = (listview) activity.findviewbyid(r.id.lstavailablesongs); assertequals(1, lstavailablesongs.getcount()); assertlistviewitemiscorrect(lstavailablesongs, 0, song); stopmyservice(); } public void test3availablesongs() { songparcel son

c# - String.Where Comparatively Poor Performance -

i have 2 methods take string , remove 'invalid' characters (characters contained in hashset). 1 method uses linq.where, uses loop w/ char array. the linq method takes twice long (208756.9 ticks) loop (108688.2 ticks) linq: string linq(string field) { var c = field.where(p => !hashchar.contains(p)); return new string(c.toarray()); } loop: string chararray(string field) { char[] c = new char[field.length]; int count = 0; (int = 0; < field.length; i++) if (!hashchar.contains(field[i])) { c[count] = field[i]; count++; } if (count == 0) return field; char[] f = new char[count]; buffer.blockcopy(c, 0, f, 0, count * sizeof(char)); return new string(f); } my expectation linq beat, or @ least comparable to, loop method. loop method isn't optimized. must missing here. how linq.where