Posts

Showing posts from August, 2014

switching from Sqlite3 to PostgreSQL on an existing rails application -

when tried switching sqlite3 postgresql in existing application faced problem rake db:migrate , did following 1 - rake db:create 2- rake db:migrate got error: == addcolumn1: migrating ===================================================== -- add_column(:users, :first_name, :string) rake aborted! error has occurred, , later migrations canceled: pg::error: error: relation "users" not exist 3- rake db:reset 4- rake db:migrate , migration done no errors i have lost data specially admin user because of rake db:reset , questions : 1- why forced use rake db:reset ? 2- there ways transfer data database engine without losing in next time ? 3- , postgresql couldn’t use blank password , said fe_sendauth: no password supplied , after adding password error gone , using password in database engine instead of sqlite3 must ? 4- heroku require reset or github accept data if use db engine in development ? this railscast great resource on migrating, , shoul

c - fopen / fgets using char* instead of FILE*, why does this work? -

i noticed had used char* variable instead of file* variable in code when using fopen , fgets, code works. wondering why is? section of code follows. ... char* filepath = ac->filepath; char* line = malloc(sizeof(char) * max_char_per_line) ; filepath = fopen(filepath, "r"); // assigning result char*, not file* if (filepath == null) { printf ("\n[%s:%d] - error opening file '%s'", __file__, __line__, filepath); printf ("\n\n"); exit (1); } while ((fgets(line, max_char_per_line, filepath) != null)) { ... both char* , file* store memory address. c has weak typing (edit: misunderstanding on part, see comments below) lets assign pointers without worrying type point to. fopen returns address of file object , store address somewhere (in case in char* ). when use address in fgets still has address of file object work expected.

java - Getting ClassNotFound Exception when executing jar -

am using intellij 12.0.4 community edition. i created java console app called db main class name of db. i packaged executable jar file called db.jar. in app connect oracle db using jdbc. i packaged necessary jdbc jar files db.jar via intellij's project structure (modules, library) when execute app within intellij runs successfully if copy db.jar directory , execute via "java -jar db.jar" classnotfound exception on oracle.jdbc.driver.oracledriver i looked in db.jar , jdbc jar files (ojdbc6.jar, ojdbc14.jar) in db.jar any thoughts? jars in executable jar not on classpath, typically. you can put them in same folder db.jar , do: java -cp db.jar;ojdbc6.jar;ojdbc14.jar <mainclass goes here> and should run it. you put class-path entry in manifest.mf file inside jar reference other jars relative location of db.jar in computer's file system. reference 2 other jar files , can java -jar db.jar <mainclass goes here> (assuming 2 jars i

c# - Why can't i pass Dictionary<string, string> to IEnumerable<KeyValuePair<string, string>> as generic type -

i explanation. have generic class list of type t , execute delegate method on want pass ienumerable class able treat list, dictionary, etc. assuming code : public static class genericclass<t> { public delegate void processdelegate(ref ienumerable<t> p_entitieslist); public static void executeprocess(ref ienumerable<t> p_entitieslist, processdelegate p_delegate) { p_delegate(ref p_entitieslist); } } public static void main() { genericclass<keyvaluepair<string, string>.processdelegate delegateprocess = new genericclass<keyvaluepair<string, string>.processdelegate( delegate (ref ienumerable<keyvaluepair<string, string>> p_entitieslist) { //treatment... }); dictionary<string, string> dic = new dictionary<

ios - How to change the UILabel content by tapping? -

this question has answer here: handling touch event in uilabel , hooking ibaction 4 answers i add tap gesture on label couldn't retrieve tapped label in selector function. mean, example, function this: -(void)changelabel:(uigesturerecognizer *)sender{} if gesture added on imageview, can imageview using sender.view. since it's uilabel don't know , change text content. hope question clear... set interaction enabled, add would. my example: - (void)viewdidload { [super viewdidload]; self.mainlabel.text = @"this label"; uitapgesturerecognizer *taprecongizer = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(changetext)]; self.mainlabel.userinteractionenabled = yes; [self.mainlabel addgesturerecognizer:taprecongizer]; } -(void)changetext { nsarray *randomnames = @[@"jim", @&

r - barplot two-sided data sets left and right of y axis -

i trying figure out how make barplot can show 2 data sets. each @ 1 side of y-axis. need space showing many data sets in few graphs. stacked or besides other options find out how solve task specially have started play around little #creating data names<-letters[1:9] data1<-c(8, 6, 3, 2, 0, 1, 1, 3, 1) data2<-c(0, -1, 0, 0, 0, 0, 0, -2, -1)#negative show them on #left side of yaxis data1<-matrix(data1,ncol=9,nrow=1,byrow=f) dimnames(data1)<-list(1,names) data2<-matrix(data2,ncol=9,nrow=1,byrow=f) dimnames(data2)<-list(1,names) par(fig=c(0.5,1,0,1)) # making space "left" barplot barplot(data1,horiz=t,axes=t,las=1) par(fig=c(0.35,0.62,0,1), new=true)#adjusting "left" barplot #because labels negative # use of axes=f barplot(data2,axes=f,horiz=t,axisnames=false) #creating new axis desired labels axis(side=1,at=seq(-8,0,2),labels=c(8,6,4,2,0)) but have difficulties understand concept

regex - Perl: suppress output of backtick when file not found -

in code : $status = `ls -l error*`; it shows output : ls *error no such file or directory. how can suppress message. interested in determining error files generated or not. if yes, need list of files else ignore (without printing message) by running like $status = `ls -l error* 2> /dev/null`; and suppressing external command's output standard error. if need file names (and not other info ls 's -l switch gives you), can accomplished in pure perl statement like @files = glob("error*"); if (@files == 0) { ... there no files ... } else { ... files ... } and if need other info ls -l ... , applying builtin stat function each file name can give same information.

java - How do I validate incoming JSON data inside a REST service? -

a rest service needs validate incoming json data against json schema. json schemas public accessible , can retrieved via http requests. i'm using jackson-framwork marshaling , unmarshaling between java , json. far couldn't find possibility validate data against schema using jackson. i tried jsontools framework comes such validation functionality. unfortunately wasn't possible me validation work. why jsontool schema validation isn't working? how can such validation? i searched best practice enforce validation incoming json data restful service. suggestion use messagebodyreader performs validation inside readfrom method. below there message-body-reader example non-generic sake of simplicity. i interesed in finding best framework doing json data validation. because use jackson framework (version 1.8.5) marshaling , unmarshaling between json , java, have been nice if framework provide json data validation functionality. unfortunately couldn't fin

crontab - Cron job to SFTP files in a directory -

scenario: need create cron job scans through directory , sftps each file machine bash script : /home/user/sendfiles.sh cron interval : 1 minute directory: /home/user/myfiles sftp destination: 10.10.10.123 create cron job crontab -u user 1 * * * /home/user/sendfiles.sh create script #!/bin/bash /usr/bin/scp -r user@10.10.10.123:/home/user/myfiles . #remove files after have been sent rm -rf * problem: not sure if cron tab correct or how sftp entire directory cron tab if going executed on cronjob, i'm assuming in order sync dir. in case, use rdiff-backup make incremental backup. way, things change transferred. this system use ssh transferring data, using rdiff-backup instead of plain scp . major benefit of doing way speed ; faster transfer parts have changed. this command copy on ssh using rdiff-backup: rdiff-backup /some/local-dir hostname.net::/whatever/remote-dir add cronjob, making sure user executes rdiff backup has ssh keys, not require

css - Why did my #wrapDesktopNavBar disappear on desktop view? -

the following css. i'm not sure why when open website on dekstop view, #wrapdesktopnavbar not show. please me @ :) @media screen , (min-width: 800px) { /* navigation bar (blank) settings */ #wrapdesktopnavbar { visibility: visible; width: 100%; /*sets width*/ height: 70px; /*sets height*/ top: 0%; /*sets distance top*/ position: relative; /*fixes bar @ designated position*/ background-color: #ffffff; /*sets background color white*/ font-family: helvetica, arial, sans-serif; /*sets font of headers*/ z-index: 1; /*sets 1 top layer, bottom layers should use small index number, vice versa*/ }} #wrapdesktopnavbar { height: 100%; background-color: #315aa9; position: fixed; width:80%; top:0%; overflow-y:a

SQL Server join on whichever column has value populated -

i have 2 tables each following id columns: ticker sedol, isin each row has 1 or more of these columns populated value. join on whichever column has value. know how join way? thanks. ticker , sedol , isin different formats assume need select * t1 join t2 on t1.ticker = t2.ticker or t1.sedol = t2.sedol or t1.isin = t2.isin performance poor if tables large however, see is having 'or' in inner join condition bad idea? . if both tables consistent on columns supplied particular security potentially faster can use hash or merge join not nested loops. select * t1 inner join t2 on exists (select t1.ticker, t1.sedol, t1.isin intersect select t2.ticker, t2.sedol, t2.isin) or if tables not consistent option might be select * t1 inner join t2

javascript - Make slideToggle effect only one element at a time -

here's i've got far: http://jsfiddle.net/jackieschreiber/4xqjm/3/ $('.expand').on('hover', function(e) { e.preventdefault(); $price = $('.price-box'); $pricefull = $price.find('.full'); $pricemini = $price.find('.small'); $pricefull.slidetoggle('slow'); $(this).unbind('mouseenter'); }); my question is, if i've got multiple elements of class, how apply effect 1 being hovered over? changed selectors little bit , added stoppropagation() animations wouldn't que. http://jsfiddle.net/4xqjm/4/ $('.price-box').on('hover', function(e) { $(this).find('.full').slidetoggle('slow'); e.stoppropagation(); });

java - JFrame setComponentZOrder() changes size of the objects -

i'm trying write undecorated jframe. i'm trying put button on background label. setting button's z order causes button streches size of jframe , neither setbounds() nor setsize() changes situation. here code: import javax.swing.*; public class myapp { public static void main(string[] args) { jframe mainframe = new jframe(); mainframe.setbounds(0, 112, 100, 50); mainframe.setlayout(null); mainframe.setundecorated(true); jlabel lblbackground = new jlabel(new imageicon(jframe.class.getresource("/res/green.png"))); lblbackground.setbounds(0, 0, 100, 50); jbutton btnstart = new jbutton(""); btnstart.setbounds(5, 15, 10, 15); mainframe.add(lblbackground); mainframe.add(btnstart); mainframe.setcomponentzorder(btnstart, 0); mainframe.setcomponentzorder(btnstart, 1); mainframe.setvisible(true); } } thanks replies. use jl

Incremental build in TFS - How do I update AssemblyInfo.cs version only for projects that have changed? -

we have solution in tfs 2012 contains several projects. have set continuous integration build on our build server , have set clean workspace = none. i'm using tfs versioning template 2.0 update assemblyfileversion , assemblyversions. when build run, each project has assemblyinfo.cs file updated new version number though there have been no changes made code in of projects. ideally want version change if there have been changes project. i considering building each project separately, prefer able build solution. have read clean workspace = none should prevent projects being updated doesn't appear happening me since timestamp on dll's showing changed after build. i new setting build process, i'm hoping there simple i'm doing wrong. suggestions appreciated. update: after checking suggested link, appears i'm doing 2 things during build may causing issue: 1) web.config file transforms take place in "afterbuild" step in 1 of projects , 2) using ver

not working cookie on remote login by curl -

this sajji i want write php app show users data ibsng system site. in system user can login : and see information on bellow url : i need immiatly , created demo user : username: demo , password: demo u can login , see information, what want using curl , information show users on account on site. had been sended data server , save cookie picking information up, after getting cookie it's seems i'm not logged in. tokken cookie: ibs_sessid=7p9ncv5adb0im1f5fqf51oj4c1 it's seems ok , when request home page login form comming , header of is: http/1.1 100 continue http/1.1 200 ok date: fri, 09 aug 2013 22:05:01 gmt server: apache/2.2.3 (centos) x-powered-by: php/5.1.6 set-cookie: ibs_sessid=7p9ncv5adb0im1f5fqf51oj4c1; path=/ expires: thu, 19 nov 1981 08:52:00 gmt cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 pragma: no-cache vary: accept-encoding connection: close transfer-encoding: chunked content-type: text/html; charse

vb.net - VB publish error -

in trying publish program wrote, select desktop, in case: c:\users\rosss1\desktop\cpxtester\ then on last window before publishing, window says published to: file:///c:/users/rosss1/desktop/cpxtester/ looks web-type path, not windows, anyway when click publish, blank web page opened says "this webpage not found". so, although specified file installed users cd/dvd looks it's trying publish web page. can't seem change , therefore can't create executable. d'oh! i

javascript - XRegExp no look-behind? -

i need use lookbehind of regex in javascript, found simulating lookbehind in javascript (take 2) . also, found author steven levithan 1 developed xregexp . i git cloned xregexp 3.0.0-pre , , tested some lookbehind logic http://regex101.com/r/xd0xz5 using xregexp var xregexp = require('xregexp'); console.log(xregexp.replace('foobar', '(?<=foo)bar', 'test')); it seems not working; $ node test foobar what miss? thanks. edit: goal like (?<=foo)[\s\s]+(?=bar) http://regex101.com/r/sv5gd5 (edit2 link wrong , modifed) answer: var str = "fooanythingbar"; console.log(str); console.log(str.replace(/(foo)(?:[\s\s]+(?=bar))/g, '$1test')); //footestbar credit goes @trevor senior thanks! it possible use non-capturing groups this, e.g. $ node > 'foobar'.replace(/(foo)(?:bar)/g, '$1test') 'footest' in second parameter of string.replace , special notation of $1 references fi

c# - Parsing HTML to get script variable value -

i'm trying find method of accessing data between tags returned server making http requests to. document has multiple tags, 1 of tags has javascript code between it, rest included files. want accesses code between script tag. an example of code is: <html> // html <script> var spect = [['temper', 'init', []], ['fw\/lib', 'init', [{staticroot: '//site.com/js/'}]], ["cap","dm",[{"tackmod":"profile","xmod":"timed"}]]]; </script> // more html </html> i'm looking ideal way grab data between 'spect' , parse it. there space between 'spect' , '=' , there isn't. no idea why, have no control on server. i know question may have been asked, responses suggest using htmlagilitypack, , i'd rather avoid using library task need javascript dom once. very s

html - Cross-browser double border / inner outline -

Image
what proper way re-create subtle inner outline following works cross-browser? currently, i've outer div , inner div both have border of different color. there solution uses 1 div , not two? jsfiddle demo what type of approach make div container border , padding. , have div inner border. way container can hold outer border , contained border colors. , inner div can hold inner border color. html <div class="outer"> <div class="inner"> <div class="content"> text.<br> other stuff,<hr> in here too. </div> </div> </div> css body{ background-color:#545454; } .outer{ border: 2px solid black; padding: 3px; border-radius:4px; width:200px; height:200px; background-color:#858585; } .inner{ background-color:#545454; width:196px; height:196px; border-radius:4px; border:2px solid black; } .content{ color:white; padding:5px; }

python - Handle spaces in argparse input -

using python , argparse, user input file name -d flag. parser.add_argument("-d", "--dmp", default=none) however, failed when path included spaces. e.g. -d c:\smthng\name spaces\more\file.csv note: spaces cause error (flag takes in 'c:smthng\name' input). error: unrecognized arguments: spaces\more\file.csv took me longer should have find solution problem... (did not find q&a i'm making own post) for can't parse arguments , still "error: unrecognized arguments:" found workaround: parser.add_argument('-d', '--dmp', nargs='+', ...) opts = parser.parse_args() and when want use ' '.join(opts.dmp)

utf 8 - Rails: How to send a http get request with UTF-8 encoding -

i'm trying use external api information address=self.address response = httparty.get("http://api.map.baidu.com/geocoder/v2/?address=#{address}&output=json&ak=5dfe24c4762c0370324d273bc231f45a") decode_response = activesupport::json.decode(response) however, address in chinese, need convert utf-8 code, if not i'll uri::invalidurierror (bad uri(is not uri?): how it? i tried address=self.address.force_encoding('utf-8') , not work, maybe should use other method instead? update: uri = "http://api.map.baidu.com/geocoder/v2/?address=#{address}&output=json&ak=5dfe24c4762c0370324d273bc231f45a" encoded_uri = uri::encode(uri) response = httparty.get(encoded_uri) decode_response = activesupport::json.decode(response) self.latitude = decode_response['result']['location']['lat'] and can't convert httparty::response string . what's wrong it? i found here , think i'll need tell

java - How can I fix output from ArrayList? -

i'm writing program reads file. each line in file contains information student.each student represented object class "student". class student has method getname returns student's name.the method goes through file returns , arraylist containing student objects. problem every time use loop access arraylist , name of each student, name of last student in list. method go through file called "fileanalyzer" below code. import java.io.*; import java.util.arraylist; import java.util.list; public class studentstats { public static void main(string[] args) { list<student> example = null; example = fileanalyzer("c:\\users\\achraf\\desktop\\ach.csv"); ( int = 0; < example.size(); i++) { system.out.println(example.get(i).getname()); } } public static list<student> fileanalyzer(string path) //path path file { bufferedreader br = null; list<student> info = new arraylist<student>();

html - Access remote jQuery file -

i building website (to accessed 3 members). need install jquery in website. since, website limited members, decided have jquery file in c drive of every pc , decided link instead page load time decreased. but, link not working. following code:- <!doctype html> <html> <script src="file:///c:/jquery.min.js"></script> <script> $(document).ready(function(){ $("body").html("replaced text"); }); </script> <body> replace text </body> is not possible fetch remote jquery file? first of all, there no such way can access user's local file. huge security exception. there 1 way can access user's file, i.e. when user uploads files voluntarily. now, offering solution, if have 3-4 members and not variable , must try using local server. why access web pages online when can access them offline? using local server may save bandwith pages load immensely fast. , yes can store jquery file in proje

Assembly - (NASM 32-bit) Printing a triangle of stars not working properly -

Image
edit: problem solved. many mbratch. my code outputs: but should display this: i think problem in innerloops can't fix it, works on first loop not on succeeding ones. here's code: innerloop1: ;;for(j=n-i;j>0;j--) mov bl, [i] sub byte [num], bl mov dl, [num] mov byte [j], dl cmp byte [j], 0 jle printstar mov eax, 4 mov ebx, 1 mov ecx, space mov edx, spacelen int 80h dec dl jmp innerloop1 printstar: mov eax, 4 mov ebx, 1 mov ecx, star mov edx, starlen int 80h innerloop2: ;;for(k=0;k<(2*i)-1;k++) mov al, [i] mul byte [two] dec al cmp byte [k], al jge printme mov eax, 4 mov ebx, 1 mov ecx, space mov edx, spacelen int 80h inc byte [k] jmp innerloop2 printme: mov eax, 4 mov ebx, 1 mov ecx, star mov edx, starlen int 80h mov eax, 4 mov ebx, 1 mov ecx, newline mov edx, newlinelen int 80h inc byte [i] jmp outerloop printspace: mov eax, 4 mov ebx,

Split string in Javascript with _ -

i beginner javascript.i want create array 1,2,3,4,5 but o/p ,1,2,3,4,5 i tried .split() in javascript not getting required output. var string="testrating_1testrating_2testrating_3testrating_4testrating_5"; var temp = new array(); temp = string.split("testrating_"); (a in temp ) { temp[a] = temp[a]; } fiddle you way: var string = "testrating_1testrating_2testrating_3testrating_4testrating_5", temp = string.split('testrating_'); temp.shift(); //remove fist item empty console.log(temp); //["1", "2", "3", "4", "5"]

joomla3.0 - passing variable as hidden from default.php is not working - joomla 3 -

hi im new on module development. need know how pass variable tmpl/default.php mod_.php since couldnt achive tutorials have reffered. how used: tmpl/default.php (not full code) <form action="index.php" method="post" id="sc_form"> <input type="hidden" name="form_send" value="send" /> <label>your name:</label><br/> <input type="text" name="your_name" value="" size="40" /><br/><br/> <label>your question:</label><br/> <textarea name="your_question" rows="5" cols="30"></textarea><br/><br/> <input type="submit" name="send" value="send" /> </form> ----------------------------------------------------------------------------------- mod_modulename.php $form_send = jrequest::getvar('f

winforms - Quick Book Integration with C# Windows Application -

i have quick book application installed in system. , have created few vendors , customers list. quick book: quickbooks simple start 2010 free edition database : quickbooks database server manager db version : 11.0.1.2584 computer name : sys13 from windows c# application, i'm trying add list of vendors , customer reading excel . i'm generating xml , based on excel inputs. every thing ok. connectivity not happening between my c# app , quick book database . i'm getting below error: can't connect database. connection string : computer name=sys13;company data=demo vss;version=11.0.1.2584 code have tried connect: try { rp.openconnection("vendoradd", "vendoradd"); messagebox.show(connstring); ticket = rp.beginsession(connstring); response = rp.processrequest(ticket, input); requestxml = input.tostring(); responsexml = response.tostring(); }

Do the action when the DIV comes in the display area of the browser with jQuery -

this question has answer here: jquery event trigger action when div made visible 20 answers i need actions when div comes in display area of browser jquery. i gave animation div, in bottom of webpage. animation need start when user scroll , reach position. try this: $(document).scroll(function(){ if($(document).scrolltop() + $(window).height() > $("your div").offset().top){ // start animation } });

gtk - Write custom widget with GTK3 -

i trying find simplest example of custom widget being written gtk-3. so far best thing i've found this (using pygtk), seems targeted gtk-2. btw: don't care language written in, if can avoid c++, better! python3 gtk3 is, then: from gi.repository import gtk class supersimplewidget(gtk.label): __gtype_name__ = 'supersimplewidget' here non-trivial example something, namely paints background , draws diagonal line through it. i'm inheriting gtk.misc instead of gtk.widget save boilerplate (see below): class simplewidget(gtk.misc): __gtype_name__ = 'simplewidget' def __init__(self, *args, **kwds): super().__init__(*args, **kwds) self.set_size_request(40, 40) def do_draw(self, cr): # paint background bg_color = self.get_style_context().get_background_color(gtk.stateflags.normal) cr.set_source_rgba(*list(bg_color)) cr.paint() # draw diagonal line allocation =

javascript - Adding options to a select box dynamically -

i trying add options select element using javascript dynamically. university assignment , first time have studied javascript/html/php please bare me if terminology wrong. please note can't use mysql because don't cover in course. we creating class booking system gym users can book class. wanted use drop down boxes, select class, time using next drop down box, has change depending on class selected. finally, user select personal trainer in last box, once again created depending on timeslot selected. this have far (javascript side): <script type="text/javascript"> function gettimes() { var index=document.getelementbyid("classes").selectedindex; var x=document.getelementbyid("schedule"); if(index==0) { document.getelementbyid("schedule").value=" "; } else if(index==1) { var option=docu

python - Macro for both excel and openoffice calc -

i in need of creating macro launch on both excel , openoffice calc. first problem format of file should create (xls vs ods) able open in both applications. another problem creating macro, language should use allow launching using both excel , oo calc? i'm pretty sure vba macro won't launch on openoffice since it's quite complicated case, i'm afraid starbasic not run on excel. i aware of python should launch on both applications, knowledge of python insufficient (i use vba/sb -> python converted if there any). any ideas? the openoffice default macro language (ooobasic / starbasic) similar vb not same , if try reuse macros written in vb in openoffice or starbasic in office won't work. worked professionally developing macros , don't know method convert code between vba , sb. recommend use python, believe possible if don't use advanced programing options. if plan use openoffice objects (services) ( ooo services here ) not work in microso

locking - What is the result of a mysql SELECT query on a table already LOCKED (write) by another session? -

everything in title... if use: lock table tablea write commands unlock tables what happen if session/user tries make select query on table? can't find in mysql documentation... will mysql respond error kind of "error xxx table locked! retry later" or mysql automatically wait until table unlocked? how long? mysql respond timeout error if table stay locked long time? btw wonder if case happen: lock table tablea write and php/mysql crashes and tablea stay locked 'forever' until mysql receive unlock tables command. just tested php : first point : let's use script that: locks table invoke script try select on same table (done in same file switch on $argc) foo.php: function showtablelocked( $link, $table ) { $query = mysqli_query( $link, "show open tables `table` '$table'" ); $data = mysqli_fetch_assoc( $query ); echo "is table locked ? :". (($data['in_use'] == '1' )

c - doubts using array and switch in? -

what role of statement ndigit[c-'0'] ? using ansi c. #include<stdio.h> #include<string.h> #include<stdlib.h> int main() { int c, i, ndigit[10]; for(i = 0; < 10; i++) ndigit[i]=0; while((c = getchar())!= eof) { switch(c) { case '0' :case '1' :case '2' :case '3' :case '4' :case '5' :case '6' :case '7' :case '8' :case '9' : ndigit[c-'0']++; break; } } printf("digits="); for(i=0;i<10;i++) printf("%d",ndigit[i]); return 0; } c ascii character value (although stored in integer type). e.g. character '0' 48 in ascii , if getchar returns character '0' c have integer value 48. c - '0' subtraction of 2 character values (ok, converts '0' integer 48 before subtracting), giving integer ready index array. so char '1'

.net - How can i do office interop on Click to Run installations? -

i have .net application heavily interops (today excel, tommorrow whole office suite) office , i'm getting pretty worried 2013 being ctr (except volume licenses). i followed google sync fiasco 2013 & keep reading requires whole re architecturing support ctr install, i'm "very willing" it, can't seem find information on know how interop ctr office 2010 / 2013? i'm not looking ways non ctr version, want program in way can natively support both , not push burden on customers switch version (which won't anyway). i'm not programming add ins (hosted inside apps) external .net apps need able interop office suite did far using excel interop (ability retrieve running instance & recycle them or start new instances , access interop api exposes). so since i'm willing restart project scratch cannot impose specific office installation (both media & non default options) on customers, appropriate way interop office 2013 ctr? appropriate way wo

Error while executing linux command using Java -

i'm trying execute following command using java process acquirinterfaces = runtime.getruntime().exec("dumpcap -d"); and getting error as java.io.ioexception: cannot run program "dumpcap": java.io.ioexception: error=2, no such file or directory linux box im executing command has got installed dumpcap located under (/usr/local/bin) what mistake im doing, please help use following line, exact path: process acquirinterfaces = runtime.getruntime().exec("/usr/local/bin/dumpcap -d");

matlab - How to count number of 1's in the matrix -

i have 1 matrix like- a=[1 1 3 0 0; 1 2 2 0 0; 1 1 1 2 0; 1 1 1 1 1]; from these "a" need count number of 1"s of each row , after want give condition after scanning each row of 'a' if number of 1's >=3 take that. means final result a= [1 1 1 2 0; 1 1 1 1 1]. how can this. matlab experts need valuable suggestion. >> a(sum(a == 1, 2) >= 3, :) ans = 1 1 1 2 0 1 1 1 1 1 here, sum(a == 1, 2) counts number of ones in each row, , a(... >= 3, :) selects rows count @ least 3.

php - Unwanted redirect with form submit -

i transfered codeigniter proejct wamp server free speech server , have been experiencing weird issues. i'm using mod_rewrite found online remove infamous 'index.php' url, , think causing redirect when submit form, losing post data. here htaccess file: <ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewritecond %{request_uri} ^system.* rewriterule ^(.*)$ /index.php?/$1 [l] rewritecond %{request_uri} ^application.* rewriterule ^(.*)$ /index.php?/$1 [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php?/$1 [l] </ifmodule> in script form calling, checking see if there post data. if there no post data, redirect 404 error (this prevent people calling script via url). after uploading site, getting 404 errors every form submit, suggesting there no data being sent. however, debug purposes, removed code script , discovered submitting form loads blank page. since form isn't supposed load new page,

remote control - android teamviewer intent with parameters -

is there way start in android "teamviewer" app (or similar app let remote control phone) specifing "user id" , password required control device? for example: intent = getpackagemanager().getlaunchintentforpackage("com.teamviewer"); i.putextra("id_key", "123456789"); i.putextra("password", "1234"); startactivity(i); thank you intent = getactivity().getpackagemanager().getlaunchintentforpackage("com.teamviewer.teamviewer.market.mobile"); i.putextra("id_key", "123456789"); i.putextra("password", "1234"); startactivity(i);

python - wrong output in arff -

i using python script , writing results (calculated using ntlk) arff file. information needs go arff file letters , words (nothing numerical). however, whenever run script arff file containing zeros.. this: 0,0.0,0.0,0 this piece of code writes arff: fileid in corpus.fileids(): cat = str(fileid.split('/')[0]) text = corpus.words(fileid) text2 = corpus.raw(fileid) text3 = ngrams(text2, 3) text4 = ngrams(text2, 4) lijst = [frequencycount(text, freq)] + [frequencycount(text3, chartrigramfreq)] + [frequencycount(text4, chartetragramfreq)] merged = list(itertools.chain.from_iterable(lijst)) merged2 = ','.join(merged) filet.write("%s\n" % merged2) counter += 1 print counter, fileid, time()-tijd filet.close()

No projects listed with Maps Engine Lite API -

i've set api service account access , seems authenticating , connecting ok using provided sample code ( https://developers.google.com/maps-engine/documentation/oauth/serviceaccount ). i've shared map provided service account email address in google maps engine ui. accessing api method https://www.googleapis.com/mapsengine/v1/projects expected see map in returned list of projects visible service account. instead, empty projects array returned. ultimately goal access place name , geodata stored within layer on map have created in maps engine lite. there step have missed or have misunderstood granting api access maps engine lite map? did progress question?. got 1 project in list because singed in free google maps engine account. allows créate 1 project. looking accessing "my places" maps.

javascript - Show Window from Grid Cell? EXTjs -

i have grid , window/form definded on page.. 1 of grid columns 'action' column.. need write href or js each cell in column show extjs 'action' window , pass cell data.. i'm having trouble finding correct renderer or handler approach.. simple example exist? i'd render data link within cell , have click show defined extjs window cell data.. extjs 3.4 any direction or examples highly appreciated you can register listener cellclick event on grid. http://docs.sencha.com/extjs/3.4.0/#!/api/ext.grid.gridpanel-event-cellclick

ruby - Using Rails find_or_initialize_by_email, how to determine if record if found or initialized? -

in 1 of controllers, i'm doing: user = user.find_or_initialize_by_email(@omniauth['info']['email']) i need know if records found or initialized. had tried this: if user else end but not work there user. right way know if find or initialize found or initialized? thanks you should able use persisted? : if user.persisted? edgeguides.rubyonrails.org says following find_or_initialize_by : the find_or_initialize_by method work find_or_create_by call new instead of create. means new model instance created in memory won't saved database.

iphone - Multiple pan gestures in a mixing console app -

Image
i ipad mixing console app able move multiple sliders simultaneously when user touches them multiple fingers, in real life. i have implemented logic single pan gesture (uipangesturerecognizer). how add multiple-touch functionality in case? there requirement of ios 5.1 compatibility. edit: reference, here gesture looks on real-life mixing consoles: you can create separate gesture recognizers each slider, e.g. assuming had collection outlet: - (void)viewdidload { [super viewdidload]; [self.sliders enumerateobjectsusingblock:^(uiview *slider, nsuinteger idx, bool *stop) { uipangesturerecognizer *pan = [[uipangesturerecognizer alloc] initwithtarget:self action:@selector(handlepan:)]; [slider addgesturerecognizer:pan]; }]; } then, gesture recognizer handle each 1 individually (surprisingly, without needing recognize them simultaneously shouldrecognizesimultaneouslywithgesturerecognizer ): - (void)handlepan:(uipangesturerecognizer *)ges

Compare HTML and HTML5 -

i've been making research tools front end developer shall know. now, i'm focused on html , have questions listed below: since html5 better html , offers new tags such header, nav, article, etc. why not not using them? why there still old tags? or should prefer use html5 tags or keep using html tags? which opportunities html5 offers me @ all? does html5 supported of browsers? do have comments, answers questions? thanks in advance.. not using them because not every legacy browser supports them. modern browsers do support html5 there still lots of folks on internet using old, outdated browsers. fortunately, html5 tags have fallback options in non-supported browsers load different tags depending on viewing them old tags still around because still crucial part of html structure. lots of websites rely on these "old" tags still function , taking them out break lot of websites. there nothing wrong "old" tags , depends on implementatio

Does setting techOrder for video.js really work? -

due ie problems, i'm trying force video.js use techorder puts flash first (at least when ie being used, anyway). i've tried methods mentioned in https://github.com/videojs/video.js/blob/master/docs/tech.md , , none of them working me. i'm finding lot of people asking same general question in various tech sites, no responses of them, other version of "didn't work me, either". i've been able flash player work hacking video.js source, wrong route, since want use html5 in non-ie cases. so: has been able make work? examples out there? both data-setup , options block methods working me. data-setup='{ "techorder":["flash", "html5"] }' in data-setup method make sure you're using single quotes around html attribute value , double quotes in json. json requires double. the techorder preference, , isn't guaranteed. still depends on tech , video formats supported specific browser. if doesn't hel

c# - When is device unique id the same on windows phone? -

i'm building application using push notifications, want possibility send "test" message's phones. don't know phones @ launch. way solve using "deviceuniqueid" , using second app retrieve name. read questions can change, example when app published different publisher. so question is: when deviceuniqueid same , when different? for wp 7.1 apps running on wp 8 devices value of deviceextendedproperties("deviceuniqueid") unique across applications , not change if phone updated new version of operating system. for wp 8.0 apps running on wp 8 devices value of deviceextendedproperties("deviceuniqueid") unique per device , per app publisher. source

mysql - How to query a table with over 200 million rows? -

i have table users 1 column user_id . these ids more 200m, not consecutive , not ordered. has index user_id_index on column. have db in mysql , in google big query, haven't been able need in of them. i need know how query these 2 things: 1) row number particular user_id (once table ordered user_id ) for this, i've tried in mysql: set @row := 0; select @row := @row + 1 row users user_id = 100001366260516; it goes fast returns row=1 because row counting data-set. select user_id, @row:=@row+1 row (select user_id users order user_id asc) user_id = 100002034141760 it takes forever (i didn't wait see result). in big query: select row_number() over() row, user_id (select user_id users.user_id order user_id asc) user_id = 1063650153 it takes forever (i didn't wait see result). 2) user_id in particular row (once table ordered user_id ) for this, i've tried in mysql: select user_id users order user_id asc limit 150000000000, 1 it takes 5 mi

python - Code not running after os.system call -

in code while 1: try: #print "try reading socket" os.system("echo 1 >/sys/class/leds/led0/brightness") data, wherefrom = s.recvfrom(1500, 0) # data socket except (keyboardinterrupt, systemexit): #print "reraise error" raise except timeout: print "no data received: socket timeout" #print sys.exc_info()[0] break except: print "unknown error occured receiving data" break print (data + " " + repr(wherefrom[0])) if (data.find("start sid" + myserial[-4:]) != -1): os.system('sudo python /home/pi/simplesi_scratch_handler/scratch_gpio_handler2.py '+ str(repr(wherefrom[0]))) in range (0,20): os.system("echo 0 >/sys/class/leds/led0/brightness") time.sleep(0.5) os.system("echo 1 >/sys/class/leds/led0/brightness") time.sleep(0.5) break os.system("echo mmc0 >/sys/class/leds/led0/trigger&

What is the Compiler Status in magento? -

what compiler status magento? should enable or disabled? compilation mode different compiler status? couldn't find in documentation. thanks compilation helps make website faster. if decide use it, need remember turn off before making changes modules , recompile before enabling again. here's best resource found on subject: http://alanstorm.com/magento_compiler_path

ruby on rails - Using a method within model, calling it from view -

i have update model belongs users. show of 1 user's friends' updates, doing like: update.where("user_id" => [array_of_friend_ids]) i know "right" way of doing things create method create above array. started writing method it's half-working. have in user model: def self.findfriends(id) @friendarray = [] @registered_friends = friend.where("user_id" => id) @registered_friends.each |x| @friendarray << x.friend_id end return @friendarray end i doing entire action in view with: <% @friendinsert = user.findfriends(current_user.id) %> <% @friendarray = [] %> <% @friendarray << @friendinsert %> <%= @friendarray.flatten! %> then i'm calling update.where("user_id" => @friendarray) works. i'm doing things in hacky way here. i'm bit confused when rails can "see" variables models , methods in view. what's best way go inserting a

c++ - Integrating Latex into my desktop application -

i'm searching consultation, or maybe opinion, suggestion, or this. i'm starting project (desktop application) ide writing books/reports. i'm planing introduce latex features, if can name them in such way. so question is: possible integrate latex script or plug-in in software in order have needed features? waiting questions or suggestions on topic. in advance! p.s. sorry if topic posted. not sure understand question correctly. never heard of kind of latex library or plugin of kind, readily available integrated in other programs. you tagged question 'qt' assume, use qt framework. way see integrate latex qt using qprocess. write latex code, start pdflatex qprocess. question if can created pdf file.

mysql - MYSQLDUMP failing. Couldn't execute 'SHOW TRIGGERS LIKE errors like (Errcode: 13) (6) and (1036) -

this question has answer here: mysqldump doing partial backup - incomplete table dump 3 answers does know why mysqldump perform partial backup of database when run following instruction: "c:\program files\mysql\mysql server 5.5\bin\mysqldump" databaseschema -u root --password=rootpassword > c:\backups\daily\myschema.dump sometimes full backup performed, @ other times backup stop after including fraction of database. fraction variable. the database have several thousand tables totalling 11gb. of these tables quite small 1500 records, many have 150 - 200 records. column counts of these tables can in hundreds though because of frequency data stored. but informed number of tables in schema in mysql not issue. there no performance issues during normal operation. and alternative of using single table not viable because of these tables have different

javascript - Applying delay between each iteration of jQuery's .each() method -

having problems following block of code: $('.merge').each(function(index) { var mergeel = $(this); settimeout(function() { self.mergeone(mergeel, self, index - (length - 1)); }, 500); }); i'm trying apply .500 second delay between each call of mergeone , code applies .500 second delay before calling mergeone on elements in array simultaneously. if explain why code doesn't work , possibly working solution awesome, thanks! here's general function can use iterate through jquery object's collection, delay between each iteration: function delayedeach($els, timeout, callback, continuous) { var iterator; iterator = function (index) { var cur; if (index >= $els.length) { if (!continuous) { return; } index = 0; } cur = $els[index]; callback.call(cur, index, cur); setti

javascript - Querying for non existent property doesn't always throw error -

why when executing piece of code, checking thisthrowserror throws error, querying non existent property on prototype object or on this context doesn't? function test() { if(this.somevar){} if(test.prototype.somevar){} if(thisthrowserror){} } var test = new test(); see: why undefined variable in javascript evaluate false , throw uncaught referenceerror?

python - How can i import gtk.gdk from gi.repository -

i have python code takes screenshot of x screen. #!/usr/bin/python import gtk.gdk w = gtk.gdk.get_default_root_window() sz = w.get_size() print "the size of window %d x %d" % sz pb = gtk.gdk.pixbuf(gtk.gdk.colorspace_rgb,false,8,sz[0],sz[1]) pb = pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1]) if (pb != none): pb.save("screenshot.png","png") print "screenshot saved screenshot.png." else: print "unable screenshot." it works need import from gi.repository import gdk instead gtk.gdk. have tried following: #!/usr/bin/python gi.repository import gtk, gdk, gdkpixbuf gi.repository.gdkpixbuf import pixbuf w = gdk.get_default_root_window() sz = w.get_size() print "the size of window %d x %d" % sz pb = pixbuf(gdk.colorspace_rgb,false,8,sz[0],sz[1]) pb = pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1]) if (pb != none): pb.save("screenshot.png","png") print &qu