Posts

Showing posts from September, 2011

Read columns of a csv file using shell or pipe inside R - Windows -

i'm looking way of reading few columns csv file r using shell() or pipe. i found thread explains how accomplish on linux: quicker way read single column of csv file on linux works adding what argument: a <-as.data.frame(scan(pipe("cut -f1,2 -d, main.csv"), what=list("character","character"),sep= ",")) however doesn't seem work on windows. when using pipe("cut -f1 -d, main.csv") connection gets opened doesn't return anything. what functions/syntax need use in order make work on windows. is possible accomplish using shell()? thanks, diego make sure cut on path - in rtools . works me: # check cut availble sys.which("cut") # create test data lines <- "a,b,c 1,2,3 4,5,6" cat(lines, file = "in.csv") # read df <- read.csv(pipe("cut -f1,2 -d, in.csv"))

ios - Eventkit doesn't always delete events -

i working on app, gets student's school lessons online , saves iphone's calendar. every time lessons updated, want delete events calendar of week, , put in updated lessons whole week. i got no problems in adding events, events don't removed? dispatch_queue_t queue = dispatch_queue_create("com.xxxxr.xxxxxx.calendar", null); dispatch_async(queue, ^{ ekeventstore *eventstore = [[ekeventstore alloc] init]; [eventstore requestaccesstoentitytype:ekentitytypeevent completion:^(bool granted, nserror *error) { if (granted){ nsuserdefaults *defaults = [nsuserdefaults standarduserdefaults]; ekcalendar *calendaridentifier; if ([defaults objectforkey:@"calendar"] == nil || ![eventstore calendarwithidentifier:[defaults objectforkey:@"calendar"]]){ // create calendar if needed eksource *thesource = nil; (eks

awk printing lines in different order to original file -

i have csv file 6 columns. col3 id, , col4 count. want print col3, , convert col4 frequency. col1,col2,col3,col4,col5,col6 9,19,9,7,9,6 10,132,10,131,10,65 10.3,0,10.3,0,10.3,1 11,128,11,182,11,82 my command awk -f"," '{if (nr!=1) f[$3] = $4; sum += $4} end { (i in f) { print i, f[i]/sum } }' myfile.csv > myoutfile.txt unexpectedly, printing output lines in wrong order - 10.3 comes before 10. there way fix this 9,0.021875 10.3,0 10,0.409375 11,0.56875 here 1 way using awk : awk 'begin{fs=ofs=","}fnr==1{next}nr==fnr{sum+=$4;next}{print $3,(sum>0?$4/sum:0)}' file file 9,0.021875 10,0.409375 10.3,0 11,0.56875 you 2 passes file. both passes check if first line, skip doing fnr==1{next} . in first pass, create variable sum , keep adding column 4 value it. in second pass print 3rd column along frequency (4th column / sum). notice have used file file due 2 passes. can use brace expansion , file{,}

webforms - Parsing error after editing Asp.Net User Control markup -

i have asp.net webforms (.net 4.0, visual studio 2013) user control works right now. uses asp label controls , resource tags bring text in based on current user's language/culture setting. i need add text it. however, adding new asp label automatically creates parsing error. once error has appear, cannot delete label. have revert markup , designer code last commit. seems me must corrupted in designer code, have no idea start looking. below parsing error: description: error occurred during parsing of resource required service request. please review following specific parse error details , modify source file appropriately. parser error message: not load type 'onlineregistration.confirmation'. source error: line 1: line 2: <%@ control language="vb" autoeventwireup="false" codebehind="confirmation.ascx.vb" inherits="onlineregistration.confirmation" %> line 3: line 4: <asp:label source file: /web

Sending data from Android to Arduino with HC-06 Bluetooth module -

i've created android app communicate arduino using bluetooth. when i'm sending data android device arduino, arduino isn't responding i've send. able connection android device arduino. that's not problem. here's full script android. package nl.handoko.lumamini; import java.io.ioexception; import java.io.outputstream; import java.util.uuid; import android.app.activity; import android.bluetooth.bluetoothadapter; import android.bluetooth.bluetoothdevice; import android.bluetooth.bluetoothsocket; import android.content.intent; import android.os.bundle; import android.util.log; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.textview; import android.widget.toast; public class mainactivity extends activity { private static final string tag = "lumamini"; private static final int request_enable_bt = 1; privat

android - VideoView Inside Navigation Drawer -

i trying put video view inside navigation drawer. videoview working fine freezing when navigation drawer move , videoview not moving navigation drawer. ideo fix this????? please ::: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" > <framelayout android:id="@+id/drop" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignparentleft="true" > </framelayout> <relativelayout android:id="@+id/left_drawer" android:layout_width="280dp" android:layout_height="match_parent" android:layout_gravity="start" android:background="#00000000" android:choicemode="singlechoice" android:dividerheight="1dp" android:

java - How to append a string after a declared string? -

a beginner asking question might sound basic!....i still learning how walk....1 day running :) i want amend following code can insert word "great" after inputted name. names length varies therefore know have change line z.insert(5, " great "); . can please instruct correct method? regards, scanner id = new scanner(system.in); string name = " "; string surname = " "; system.out.println("please enter name: "); name = id.nextline(); system.out.println(); system.out.println("please enter surname: "); surname = id.nextline(); stringbuffer z = new stringbuffer(); z.append(name + " " + surname + " king of kings"); z.insert(5, " great "); system.out.println(z); system.out.println(); you need calculate length of name , ... int len = name.length() + surname.length() + 1; should give index point after can insert additional str

jquery - Timed AJAX request, reload if content is different -

i using following script check if content of currentshow.php , #current-show (on existing page) different. if different want replace #current-show currentshow.php : jquery(document).ready(function() { var auto_refresh = setinterval( function (){ function getcurrentshow(){ var result = null; jquery.ajax({ url: '/currentshow.php', type: 'get', datatype: 'html', async: false, success: function(data) { result = data; } }); return result; } gcs = getcurrentshow(); cs = jquery('#current-show').html(); if (gcs != cs){ jquery('#current-show').load('/currentshow.php'); }; }, 1000); )}; i console.log(gcs) , console.log(cs) , both return same thing in js console. however, content reloads every second anyway. any idea doing wrong? you

c - Add elements to struct by define -

i have problem. i'm trying add struct elements defined constant. sample code (opengl+winapi) #define engine_struct \ hglrc renderingcontext;\ hdc devicecontext; and then: typedef struct swindow { engine_struct hwnd handle; hinstance instance; char* classname; bool fullscreen; bool active; msg message; } window; is possible? yes possible, macro simple textual substitution http://www.cplusplus.com/doc/tutorial/preprocessor/ the preprocessor examines code before actual compilation of code begins , resolves these directives before code generated regular statements.

security - How to protect .asp files from editing? -

my website hacked , homepage changed again , again. there tools or asp sources can protect editing? i set attributes hidden, read , system index.asp files, well, changed hacker again. notes: my site hosted in shared server my website hacked china chopper before i have cleaned server hidden asp files.. to put bluntly, secure server stop hackers editing pages :) it sounds server has been compromised @ higher level, if hosted solution (by 3rd party company) need fix servers. unfortunately i've seen smaller hosting companies never fix problem , replace files , blame "poor coding" when problem "stupid system admins don't know doing". if case, move different host. if machine , hosting it, rebuild entire machine sounds has been compromised.

c# - Calling a method from WS, parameter input type issue -

Image
i have following operation in webservice interface: [operationcontract] list<vcard> getvcards(int[] vcardids); and error when trying write code calling it: what doing wrong? thanks you have type missmatch wrap cardlist new observablecollection() needed. e.g. before call service, 'course if it's following program semantic service.getvcardsasync(new observablecollection<int>(cardlist))

javascript - Access upload progress through http request in PHP -

is possible measure file upload progress accessing http request in php? , if how do while uploading file mysql db? require('../connect_db.php'); //gather required data $name = $dbc->real_escape_string($_files['uploaded_file'] ['name']); $data = $dbc->real_escape_string(file_get_contents($_files['uploaded_file'] ['tmp_name'])); $size = intval($_files['uploaded_file']['size']); //create sql query $query = "insert `".$user."`( name,size,data,created ) values ( '$name','$size','$data',now() )"; for file upload client side progress suggest use jquery plugin- http://runnable.com/uzkdayo3xew2aacx/how-to-upload-a-file-using-jquery-for-php and don't think storing files in db, mysql idea.

java - How Or why is there a limit on any primitive data types -

in java like, short range -32768 32767, while int, -2147483648 2147483647. looks designers created different sized buckets store range values.then have created bunch of more data types of different ranges, boiled down 8 types these ranges. reasons? instead of exposing data structure (or 2 1 number other chars) can store user defined dataset have worked. byte 1 byte, short 2 bytes, int 4 bytes, , long 8 bytes. other data types storing other types of data. numbers mentioned largest , smallest signed integers can fit within one, two, four, , 8 bytes respectively. (and 1, 2, 4, , 8 powers of two.)

Raspberry Pi is not recording from USB Microphone -

i've usb hub (plugabble) usb daffodil sound card. speakers working great, microphone not working. don't know anymore working. the usb sound card set default the arecord command records no sound recorded. the aplay play sounds nicely. here of settings: pi@raspberrypi ~ $ arecord -l null discard samples (playback) or generate 0 samples (capture) default:card=set c-media usb headphone set, usb audio default audio device sysdefault:card=set c-media usb headphone set, usb audio default audio device front:card=set,dev=0 c-media usb headphone set, usb audio front speakers surround40:card=set,dev=0 c-media usb headphone set, usb audio 4.0 surround output front , rear speakers surround41:card=set,dev=0 c-media usb headphone set, usb audio 4.1 surround output front, rear , subwoofer speakers surround50:card=set,dev=0 c-media usb headphone set, usb audio 5.0 surround output front, center , rear speakers surround51:card=set

(php) strpos offset in while loop -

i'm studying php reading tutorial in website( http://www.tizag.com/ ) below excerpt tutorial. <?php $numberedstring="1234567890123456789012345678901234567890"; $offset=0; $fivecounter=0; echo $numberedstring; if(strpos($numberedstring, "5")==0){ $fivecounter++; echo "<br />five #$fivecounter @ position - 0"; } while($offset=strpos($numberedstring, "5", $offset+1)){ $fivecounter++; echo "<br />five #$fivecounter @ position - $offset"; }?> i don't understand how offset changes. shouldn't code in while() true? seems designating offset. understand first offset 0. when goes to while($offset=strpos($numberedstring, "5", $offset+1) for first time, offset changes 1 due '$offset+1'. then, think strops($numberedstring, "5", $offset+1) becomes 4. and guess 4 becomes offset again, , start loop again, how come codes in while() can designate else? shouldn'

php - How to re-arranging an array -

i having , issue rearrange array, try of them.. try use array_merge, foreach, forloop, while loop etc. no luck my concept not clear need idea how can change array per requirements, batter if give me concept idea only, don't required code try self first code it. here array array ( [links] => array ( [song_name] => array ( [0] => aa [1] => bb [2] => cc ..... ) [singer_name] => array ( [0] => aa [1] => bb [2] => cc ..... ) [song_url_320] => array ( [0] => aa [1] => bb [2] => cc ..... ) [song_url_128] => array ( [0] => aa [1] => bb

bash - Exclude a column when pasting two data files -

i have 1 file "dat1.txt" like: 0 5.71159e-01 1 1.92632e-01 2 -4.73603e-01 and file "dat2.txt" is: 0 5.19105e-01 1 2.29702e-01 2 -3.05675e-01 to write combine these 2 files 1 use paste dat1.txt dat2.txt > data.txt but not want 1st column of 2nd file in output file. how modify unix command? paste dat1.txt <(cut -d" " -f2- dat2.txt) using cut remove column 1, , using process substitution use output in paste output: 0 5.71159e-01 5.19105e-01 1 1.92632e-01 2.29702e-01 2 -4.73603e-01 -3.05675e-01

Connection String of Windows Azure in php -

Image
i have such connection statement connect blob storage i've created in windows azure. $connectionstring = 'defaultendpointsprotocol=http;accountname=<accountname>;accountkey=<secret key>'; $echo "1"; $blobrestproxy = servicesbuilder::getinstance()->createblobservice($connectionstring); $echo "2"; when put this, "1" written, "2" isn't. does mean, $blobrestproxy isn't working? i try create container in blob storage, fails. how can fix problem? thanks. updates: this link picture shows inside of public_html http://picpaste.com/2-fjxf4kpo.jpg these links of picture shows inside of website folder http://picpaste.com/3-crea0e72.jpg http://picpaste.com/4-tjvv3br7.jpg <!doctype html> <html lang="en"> <head> <title>more</title> <meta charset="utf-8"> <meta name="description" content="description goes here">

How to know if a user has pressed the Enter key using Python -

how know if user has pressed enter using python ? for example : user = raw_input("type in enter") if user == "enter": print "you pressed enter" else: print "you haven't pressed enter" as @jonrsharpe said, way exit raw_input function pressing enter. solution check if result contains or not: text = raw_input("type in enter") if text == "": print "you pressed enter" else: print "you typed text before pressing enter" the other ways see quit raw_input function throw exception such as: eoferror if type ^d keyboardinterrupt if type ^c ...

asp.net mvc - check if user session has expired asp web api -

i experimenting in developing single page application using asp mvc 4 / web api , angularjs. i using mvc controller actions return views , web api actions return json. as web api part restfull , has no state, wondering how check if user session has expired. example: user clicking on button , leads request web api action json data. when request hits server want check if user session has expired. as said rather new combination of technologies , wondering how can achieved. example appreciated. in advance. web api introduced attribute [authorize] provide security. can set globally (global.asx) public static void register(httpconfiguration config) { config.filters.add(new authorizeattribute()); } or per controller: [authorize] public class valuescontroller : apicontroller{ ... if user authenticated(session has not expired) service work if not http 401 unauthorized returned.

How does Javascript associative array work? -

i in bit of puzzle, had worked on project use of javascript necessary. working fine need know how work eg : had dynamic variable count , use value, lets value var count = 6; now when put in array {count : count } output {count : 6} now doubt output should have been { 6 : 6} count should have been replaced value didn't happen so. why happening ? , how working ? the key value pairs treat key literal , value variable. so: var count = 6; var o = {count: count}; // results in {count: 6} but use variable key, can this: var count = 6; var o = {}; o[count] = count; // results in: {6: 6}

Multiple CSS counters not working as expected -

Image
i trying create multiple levels of counters in html table, not working expected. first counter works ok, next counters not work. somehow counters not incrementing or reset wrongly? the code: <html> <head> <title>counter demo</title> <style> table.tasksteps { counter-reset: tasksteps; } td.taskstep { counter-reset: risks; counter-increment: tasksteps; } td.risk { counter-reset: measures; counter-increment: risks; } td.measure { counter-increment: measures; } td.taskstep:before { content: counter(tasksteps) '. '; } td.risk:before { content: counter(tasksteps) '.' counter(risks) '. '; } td.measure:before { content: counter(tasksteps) '.' counter(risks) '.' counter(measures) '. '; } </style> </head> &

c++ - How to call a function using an argument supplied from the template function -

edit: clarify "t" called when casted. compiler knows , state function pointer takes argument of type int. supply null int pointer break loop because calling recursively. may bug in compiler. i trying call function template function argument. assume possible call function without explicit casting not seem case. using vc2013. template<typename t> void func(t t) { printf("calling func...\n"); if (t) { ((void(__cdecl*)(int))t)((int)nullptr); // explicit casting successful t ((int)nullptr); // compile error: ``term not evaluate function taking 1 arguments`` } } void main() { auto pe = func < int > ; auto pf = func < void(__cdecl*)(int) >; pf(pe); } you have error func<int> becomes: void func(int t) { printf("calling func...\n"); if (t) { ((void(__cdecl*)(int))t)((int)nullptr); // bad casting t ((int)nullpt

opengl - Best method to copy texture to texture -

what best method copy pixels texture texture? i've found ways accomplish this. instance, there's method glcopyimagesubdata() target version opengl 2.1, cannot use it. also, because performance important, glgetteximage2d() not option. since i'm handling video frames texture, have make copies 30~60 times per second. available options found next: create fbo source texture , copy destination texture using glcopytexsubimage2d(). create fbos source , destination textures , blit fbos. create fbo destination texture , render source texture fbo. you can ignore cost of creation of fbo because fbo created once. please don't post 'it depends. benchmark.'. i'm not targeting 1 gpu. if depends, please, please let me know how depends on what. furthermore, because difficult measure timing of opengl calls, want know not quantitative result. need advices method should avoid. if know better method copy textures, please let me know too. thank reading.

ExtJs - Renderer for remote store combobox in grid editor -

i know has been asked somewhere again , again can't find solid answer standard kind of problem. as many have done before have editor inside grid combobox uses remote store database. suppose there table in database 50,000 records. combobox loads first 15. when select record between these 15 displays fine. render displayfield instead valuefield , use following function rendercombobox : function(value, metadata, record, rowindex, colindex, store, view, isnewrow){ var me = this, columns = me.columns, editor, editorstore, editorindex, displayfield, display, rec; for(var i=0,j=columns.length;i<j;i++){ if(columns[i].geteditor){ editor = columns[i].geteditor(record); if(editor.xtype === 'combobox'){ editorstore = editor.getstore().load(); editorindex = editorstore.findexact(editor.valuefield, value); displayfield = editor.displayfield;

html - How to set "content" on an :after element inline with the text -

i have li-tag in menu: nav ul li ul.firstmenu li.secondtothree{ float: none; border-bottom: 1px solid #dcdcda; padding:3px; text-transform:none; } then want add ">" after menupoints, looks "home >" or "article >". this :after: nav ul li ul.firstmenu li.secondtothree:after{ content: ">"; font-size: 15px; text-align: right; display: inline-block; width:100%; right:0px; } but ">" in next row. possible set directly in line after menupoint? generated content placed inline default. don't need of these properties: text-align: right; display: inline-block; width:100%; right:0px;

python - Colorbars close to subplots -

Image
how can put colorbars beside each colormap in subplot? simplified version of real code here shows problem. can see colorbars @ bottom right , making last plot smaller. from matplotlib import pyplot plt import numpy np def plots(): fig,ax=plt.subplots(2,2) in range(2): rho_mat,c_mat=np.random.uniform(size=(50,50)),np.random.uniform(size=(50,50)) ax[0,i].set_title(r"$\rho_{x,y}$") p=ax[0,i].imshow(np.fliplr(rho_mat).t,extent=[0.,1,0.,1],vmin=0,vmax=1, interpolation='none') ax[0,i].set_xlabel(r'$\epsilon_1$') ax[0,i].set_ylabel(r'$\epsilon_2$') fig.colorbar(p, shrink=0.5) ax[1,i].set_title(r"$c_{x,y}$") p2=ax[1,i].imshow(np.fliplr(c_mat).t,extent=[0.,1,0.,1],vmin=0,vmax=1, interpolation='none') ax[1,i].set_xlabel(r'$\epsilon_1$') ax[1,i].set_ylabel(r'$\epsilon_2$') fig.colorbar(p2, shrink=0.5) plt.

Php equal more or less operators -

i getting following error: $experience = $row[experience]; use of undefined constant experience - assumed 'experience' – user3696343 ) from code: } else if($_get['event'] == 15) { $fetch = mysqli_query($db_handle, "select gold, bank, troop, head, body, gloves, foot, combatlog, item0, item1, item2, item3, coordinatex, coordinatey, coordinatez, horse, hp, new, food, experience, level playerdata unique_id = '$unique_id'"); $row = mysqli_fetch_assoc($fetch); $experience = $row[experience]; $xptolevel = '50'; if($experience >= $xptolevel) { echo'enough xp level up'; mysqli_query($db_handle, "update playerdata set experience = 0, level = level + 1 unique_id = '$unique_id'"); echo "15|$unique_id|$local_id|$row[gold]|$row[bank]|$row[troop]|$row[head]|$row[body]|$row[gloves]|$row[foot]|$row[combatlog]|$row[item0]|$row[item1]|$row[item2]|$row[item3]|$row[coor

performance - Python pypy: Efficient sum of absolute array/vector difference -

i trying reduce computation time of script,which run pypy. has calculate large number of lists/vectors/arrays pairwise sums of absolute differences. length of input vectors quite small, between 10 , 500. tested 3 different approaches far: 1) naive approach, input lists: def std_sum(v1, v2): distance = 0.0 (a,b) in izip(v1, v2): distance += math.fabs(a-b) return distance 2) lambdas , reduce, input lists: lzi = lambda v1, v2: reduce(lambda s, (a,b):s + math.fabs(a-b), izip(v1, v2), 0) def lmd_sum(v1, v2): return lzi(v1, v2) 3) using numpy, input numpy.arrays: def np_sum(v1, v2): return np.sum(np.abs(v1-v2)) on machine, using pypy , pairs itertools.combinations_with_replacement of 500 such lists, first 2 approaches similar (roughly 5 seconds), while numpy approach slower, taking around 12 seconds. is there faster way calculations? lists read , parsed text files , increased preprocessing time no problem (such creating numpy arrays). lists contain floating

summing matrices to a single matrix in R -

i have following matrices:- alive <- array(0,c(num_samples,num_time_periods,num_groups)) alive[,1,] <- 100 for(i in 2:num_time_periods){ alive[,i,] <- rbinom(num_samples, alive[,i-1,], exp(-delta[,i,]))} alive , , 1 [,1] [,2] [,3] [,4] [,5] [1,] 100 98 94 89 87 [2,] 100 98 96 94 92 [3,] 100 99 95 94 92 , , 2 [,1] [,2] [,3] [,4] [,5] [1,] 100 98 94 89 87 [2,] 100 98 96 94 92 [3,] 100 99 95 94 92 , , 3 [,1] [,2] [,3] [,4] [,5] [1,] 100 98 94 89 87 [2,] 100 98 96 94 92 [3,] 100 99 95 94 92 how sum of matrices element give me single matrix? i have tried write this:- totalalive <- array(0,c(num_samples,num_time_periods,num_groups)) for(i in 2:num_groups){ totalalive[,,i] <- sum(alive[,,i]) } but wrong. want single matrix below:- sum:- [,1] [,2] [,3] [,4] [,5] [1,] 300 294 .. .. .. [2,] 300 294 .. ..

javascript - Ajax onerror handler not working -

in pure javascript: make ajax request. the server supposed return 410 error. my code: var ajax = new xmlhttprequest(); ajax.onload = displayxml; ajax.onerror = displayerror; ajax.open('get', 'http://myurl.com/request?param=1&param=2', true); ajax.send(); function displayerror(e) { console.log(this.status); } function displayxml() { console.log(this.responsexml); } problem is, onerror function never gets called when http 410 returned. console says "get .... 410 (gone)" on line ajax.send() appears, calls displaypopularity . how should handle http errors, if can't use .onerror ? mean, roll error handling displaypopularity thought there more elegant solution. i believe onerror security issues (eg. cross-origin ) or errors in "config" ajax (front-end). "http errors" not considered "errors", "responses" server. xmlhttprequest.onload executed, if there error in "http response&

ruby on rails - How to make a concern route DRYer -

sometimes need concern route collection , member (sometimes have_many galleries, , has_one ) concern :single_galleriable resource :gallery, concerns: :photoable member post :make_feature end end end concern :galleriable resources :gallery, concerns: :photoable member post :make_feature end end end and do resources :somemodel, concerns: :single_galleriable obviously, wet.. can use concern resource or resources according needs while concern's content stay same? don't know if help, can use methods in routes.rb file: #config/routes.rb (some of our actual code) #methods have kept @ top def destroy_all collection delete :destroy_all delete 'destroy(/:id)', action: 'destroy', as: 'multi_destroy' end end #general stuff resources :controller destroy_all end -- this means this: #config/routes.rb #methods have kept @ top def gallery type = true m

Adding html via Jquery but page just keeps refreshing -

i don't have access change html directly on page i'm using jquery add text. have code far: $(document).ready(function(){ if(window.location.href='http://somepage.com') { $(".rightborder.eq(2)").append("<p>some text</p>"); } the problem text gets added page keeps refreshing, doing loop cannot end. can see why? thanks dan you assigning new href property, need check instead: if(window.location.href === 'http://somepage.com')

Akka IO Serial communication using java -

i new akka io. have requirement of client server communication happening on serial port using akka io. have read jodersky serial io library. ( https://github.com/jodersky/flow ), didin't specific scala. have idea on how setup jodersky library java based developments in akka. useful if related samples posted. i'm pretty sure can use flow java well. akka written in scala isn't it? another approach might use similar tech: https://github.com/jodersky/ace/blob/master/scala/jssc/src/main/scala/com/github/jodersky/ace/jssc/serial.scala same author has hidden away in project. still scala, it's using java-simple-serial-connector library instead of flow perhaps more adapt java solution. https://code.google.com/p/java-simple-serial-connector/ they way akka io appears working having specific actors bound io duties can send messages actor refs provide. using event listener in jssc should make pretty straight-forward.

cuda - Converting a dense matrix to sparse CSR format with cuSPARSE -

i want use scsrmv cusparse function. reading documentation here , can't figure how define csrrowptra , csrcolinda : csrrowptra : integer array of m+1 elements contains start of every row , end of last row plus one. csrcolinda : integer array of nnz ( = csrrowptra(m) - csrrowptra(0) ) column indices of nonzero elements of matrix a. so , example: float *devrow; cudamalloc((void **)&devrow, (m+1)*sizeof(float)); and if a matrix, then: for (int i=0; i<m; i+= n) //m rows , n columns devrow[i] = a[i]; this start of every row. last row , plus 1 ? confused me. and columns? like: for (int i=0;i<nnz;i++) devcol = devrow[m] - devrow[0]; you can convert dense matrix sparse code write yourself. csr (compressed-sparse-row) formulation, use cusparse function this. the general format of csr sparse matrix representation documented in many places, including cusparse manual .

jboss - JSF Managed Bean not being called -

i getting started jsf , trying out following tutorial in eclispe: http://javing.blogspot.de/2013/01/how-to-create-new-jsf-21-project-and.html i have got working compiles , deploys on jboss eap 6 without error. not getting output managed bean class, consists of 1 function returns text string. here code files: web.xml <?xml version="1.0" encoding="utf-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee /web-app_3_0.xsd" version="3.0"> <display-name>archetype created web application</display-name> <context-param> <param-name>javax.faces.project_stage</param-name> <param-value>development</param-value> </context-param> <servlet> <servlet-name>face

c# - Comparing generics: A "master-type" IEnumerable<> that is generic, but matches all specific types (IEnumerable<int>, IEnumerable<object>, ...)? -

i want to compare typeof(ienumerable<>) types of various specific classes of ienumerable, e.g. compare(typeof(ienumerable<>), typeof(ienumerable<object>)) // should return true compare(typeof(ienumerable<>), typeof(ienumerable<int>)) // should return true compare(typeof(ienumerable<>), typeof(ienumerable<myclass>)) // should return true compare(typeof(ienumerable<>), typeof(ienumerable)) // should return false because ienumerable not generic ienumerable<> type how can this? common methods such == or isassignablefrom return false above examples. probably not necessary question, background: i'm writing conversion class convers object other type. i'm using attributes (xlconverts): public class xlconvertsattribute : attribute { public type converts; public type to; } to flag type each methods converts into. 1 of conversion methods converts object ienumerable: [xlconverts(converts = t

jquery - How can i set the text of a div dyanmically? -

i have static html <div id="myordersdiv"> <ul> <li class="myorderhead"><h5>my orders <i>2</i></h5></li> </ul> </div> here orders <i>2</i> represents number of orders present in how can set text hardcoded 2 dynamically ?? var dataa = '<div id="ordersdiv" style="display:none"></div>'; $("#myordersdiv ul").append(dataa); $("#ordersdiv").prepend(buildcart); $("#myordersdiv").show(); this html <div id="myordersdiv"> <ul> <li class="myorderhead"><h5>my orders <i>2</i></h5></li> </ul> </div> and calculating length way var dataa = '<div id="ordersdiv" style="display:none"></di

jquery - Alternative to multiple identical IDs in the same HTML document -

i know repeated use of identical ids in 1 html document bad practice. how can avoid this, if have elements performing same functions, , need quick access? for example: <form id='dialog_setting_dns-form'> <label>address:</label> <input name="address" id="address"/> </form> <form id='dialog_static'> <label>address:</label> <input name="address" id="address"/> </form> use class instead of id in situation <form id='dialog_setting_dns-form'> <label>address:</label> <input name="address" class="address" /> </form> <form id='dialog_static'> <label>address:</label> <input name="address" class="address" /> </form> you select class in jquery $('.address') opposed using id $('#address') .

html - Google Map link to markers from external site -

i have question. website has link show on map points custom google map. custom google map has 30ish markers, , when click link website, opens map, , focuses corresponding marker there. use show on map marker 1, custom map opens , focuses marker 1 info bubble. link here <a href="http://maps.google.com/maps/ms?msa=0&amp;msid=202453748669122555293.0004ab5452234ae2281f9&amp;hl=hr&amp;ie=utf8&amp;t=h&amp;vpsrc=6&amp;ll=44.833596,14.728954&amp;spn=0.007304,0.013733&amp;z=16&amp;iwloc=0004ad9b633f7bf6421e7&amp;" rel="external" class="button">show on map</a> link map now, since need replicate google map because dont have acess anymore, wondering how link marker? since website doesnt have javascript or regarding goolge maps, links hardcoded on custom map in source code or something? since know iwloc , coordiantes change on links.. on source code of custom map iwloc same on 3-4 ocurrances in page. any w

database - Equijoin when used on relations with attributes of same name -

i came across question has been bugging me bit. if equijoin used 2 relations have multiple attributes of same name, multiple value matches, result? example, consider like: r(a,b,c,d) , s(c,d,e,f). if apply equijoin above follows: r (equi-join)(condition: r.c = s.c) s, how resulting relation behave? interested common 'd' attribute of both relations , presence in result. many in advance answers! this should answer question: table addresses first_name last_name address john miller 5 miller street jane smith 6 smith way jane becker 7 becker street table jobs first_name last_name job john miller milkman jane smith software engineer jane becker translator query select * addresses inner join jobs on jobs.first_name = addresses.first_name result first_name last_name address job john miller 5 miller street milkman jane smith 6 smith way

javascript - implementing bootstrap tabs in rails -

i trying use bootstrap tabs rails4.1. here haml code: .container-fluid .row-fluid .span8.well %ul.nav.nav-tabs %li.active %a{"data-target" => "#home", "data-toggle" => "tab", href: "#home", id: '#home_link'} home %li %a{"data-target" => "#profile", "data-toggle" => "tab", href: "#profile", id: '#profile_link'} profile .tab-content #home.tab-pane.active.fade.in home tab content #profile.tab-pane profile tab content in application.js have //= require bootstrap for first time loading page show home tab content afterwards clicking on tab doesn't show anything. don't know lacking. thanks solved myself through .container-fluid .row-fluid .span8.well %ul.nav.nav-tabs %li.active %a{"data-toggle" => "tab", href: "

javascript - Model changes not updating the view -

i have button listening click event , idea toggle state when button clicked. the view : <button ng-click="nextbtnclicked()" ng-disabled="{{state == 1}}" class="btn">call</button> the controller : app.controller('workstation',['$scope',function($scope) { $scope.state = 0; $scope.nextbtnclicked = function() { $scope.state = 1; }; }] the problem don't see changes when button clicked.i've tried execute $apply() got error "error:[$rootscope:inprog]" you don't need use interpolation. use: ng-disabled="state == 1" otherwise: ng-disabled="{{state == 1}}" will evaulated into: ng-disabled="false" which means ngdisabled directive watching variable named false on associated scope.