Posts

Showing posts from July, 2011

Using JavaScript functions as "classes": What am I doing wrong here? -

here's javascript "class" far: function snake(c, c_h, c_w) { this.linksize = 10; // size of snake unit, in pixels /* on instantiation, snake direction down , has 1 link */ this.dy = this.linksize; this.dx = 0; this.link = c.rect(c_h/2, c_w/2, this.linksize, this.linksize); this.link.attr("fill", "#d7a900"); this.body = [link]; /* event listener changing direction of snake arrow keys on keyboard */ this.redirect = function(dirnum) { switch (dirnum) { /* dirnum corresponds 1 ---> right 2 ---> down 3 ---> left 4 ---> */ case 1: this.dx = this.linksiz...

java - How can I generalize these repetitive blocks of code? -

Image
code near-identical blocks makes me cringe. plus adds have thousand lines of code half suffice. surely there way make loop make happen , not have code looks unsophisticated , brainless. offhand seems adding code seek reduce: loop make 5 buttons, array of labels buttons, array of backgrounds... maybe more. if turned out acceptable, how make loop handle listeners? i can't have array of methods, can i? guess such loop have include switch . yes? i'd if didn't want seek better solution. i'm asking... what code listen entire group of buttons , take action based on 1 pressed? component assign single listener? , how? (there's chance answer question make me cringe more repetitive nature of code, if realize know how , needn't have asked in first place, i'm asking anyway. i'm @ 1 of i've-had-it-for-today points brain wants out.) private void makescoremasterbonuses(){ pnlbonuses = new jpanel(new gridlayout(1, 6)); pnlbonuses.setsize(6,1); ...

How to match a regex with backreference in Go? -

i need match regex uses backreferences (e.g. \1) in go code. that's not easy because in go, official regexp package uses re2 engine , 1 have chosen not support backreferences (and other lesser-known features) there can guarantee of linear-time execution, therefore avoiding regex denial-of-service attacks . enabling backreferences support not option re2. in code, there no risk of malicious exploitation attackers, , need backreferences. what should do? regular expressions great working regular grammars, if grammar isn't regular (i.e. requires back-references , stuff that) should switch better tool. there lot of tools available parsing context-free grammars, including yacc shipped go distribution default. alternatively, can write own parser. recursive descent parsers can written hand example. i think regular expressions overused in scripting languages (like perl, python, ruby, ...) because c/asm powered implementation more optimized languages itself, go is...

windows - Weird java.net.SocketException behaviour -

i distributing app binds 1200 port listen udp packets. app installed on ~50 machines set auto restart in 7:30am , auto login specific user , when user logging in auto start app. problem on morning machine restart 5 machines wont start app because app fails java.net.socketexception: bound exception 1200 port. when login machine , try starting app manually starts without problems. there nothing unusual installed on machines, vnc server, , few other apps should not use port. can while windows booting randomly takes port or that? because experienced behaviour when machine restarted, not when user logging off , in (which kills , starts app). i using standard datagramchannel bind port, nothing exotic. datagramchannel channel = datagramchannel.open(); channel.socket().bind(new inetsocketaddress(1200)); problematic machines different every day, not same ones.

c# - All uploaded files are not displayed in the links -

Image
i have written as protected void btnupload_click(object sender, eventargs e) { httpfilecollection filecollection = request.files; (int = 0; < filecollection.count; i++) { httppostedfile uploadfile = filecollection[i]; string filename = path.getfilename(uploadfile.filename); if (uploadfile.contentlength > 0) { uploadfile.saveas(server.mappath("~/uploadfiles/") + filename); lblmessage.text += filename + "saved successfully<br>"; hyperlnk.text = filename.tostring() + "saved successfully<br>"; // hyperlnk.attributes.add("href", server.mappath("/uploadfiles/") + filename); hyperlnk.navigateurl="~/uploadfiles/" + filename; //lblmessage.text= "<a href=" + "/uploadfiles/" + filename +">"+filename+"...

sql - Getting data from multiple cursors in Android ListView -

in project have 2 cursors. 1 handling books records form 1 table , join on 2 tables holding rents records , users data. using 2 cursors because join on showing books rented, , not all. i've figured out - if join , 1 of column empty omited in resulting cursor. the proble want have in 1 listview . i've created custom cursorloader because data loading done via loader . custom loader returning list of cursors based on list of elements - difference. in cursoradapter implementation want set text of textview rent or free based on values second cursor. unfortunately can't like: secondcursor.moveto(bookid) because book id can way bigger size of secondcursor throw indexoutofboundsexception . also i've been testing cursorjoiner : cursorjoiner joiner = new cursorjoiner(data.get(0)/*first cursor*/, new string[]{tables.book_id}, data.get(1)/*second cursor*/, new string[]{tables.rent_column_book_id}); int = 0; while(joiner.hasnext()){ ...

php - No such file or directory error using mkdir -

i encounter problem when give full path mkdir says no such file or directory when providing same first going 1 directory work i want ask why not working $name = "4ftwx"; // dir name $domain = $_server['http_host']; mkdir($domain.'/project/'.$name); //localhost/project/4ftwx but work when call this mkdir('../project/'.$name); both pointing same path why not working maybe should use $_server['document_root'] document root directory under current script executing.

scala - why the "===" operation do not work on "filter" or "where" do not apply on my TableQuery [slick2] -

i use slick 2.0.2 , scala, datamodel is: case class aditem(id:option[long], res:string,status:string,userid:string, head:string,summary:string, url:string, position:string) class advertisement(tag:tag) extends table[aditem](tag, "advertisement"){ def id=column[long]("id", o.primarykey, o.autoinc) def res=column[string]("resource") def status=column[string]("status") def userid=column[string]("user") def head=column[string]("head") def summary=column[string]("summary") def url=column[string]("ad_link") def position=column[string]("position") def * = (id.?, res, status, userid, head, summary, url, position)<>(aditem.tupled, aditem.unapply) def userfk=foreignkey("ad_use_fk", userid, userdata)(_.id) } this tablequery: val addata=tablequery[advertisement] when execute the: val idd="1232232" addata.filter(_.id === idd.tolong) i error is: ...

c# - How to generate all subsets of a given size? -

given number n, , subset size, want possible subsets of specified size of set {1, ..., n}. expected result for n = 5 , subsetsize = 4 : {{1,2,3,4}, {1,2,3,5}, {1,3,4,5}, {1,2,4,5}, {2,3,4,5}} (that list<list<int>> ) that means need (subsetsize choose n) subsets (newton's symbol). any idea algorithm find me such list of lists of integers? i'm implementing in c#, if matters. internal class program { private static ienumerable<ienumerable<int>> subsets(int n, int subsetsize) { ienumerable<int> sequence = enumerable.range(1, n); // generate list of sequences containing 1 element e.g. {1}, {2}, ... var oneelemsequences = sequence.select(x => new[] { x }).tolist(); // generate list of int sequences var result = new list<list<int>>(); // add initial empty set result.add(new list<int>()); // generate powerset, skip sequences long ...

angularjs - angular 1.2, how would a router load views without making get calls? -

i've been going on current (angular 1.2.16) routing , multiple views method angular. detailed here . in see every route there request load partial html. how change requests views happen when app instantiates , routes switch views without making further calls server? suppose want change content of div depending on stored in data.mode . need have first mechanism change value of data.mode , that's entirely you. <div ng-switch on="data.mode"> <div ng-switch-when="first_value"> <!--your first partial page content--> </div> <div ng-switch-when="second_value"> <!--your second partial page--> </div> <div ng-switch-when="second_value"> <!--your third partial page--> </div> <div ng-switch-default> <!--default content when no match found.--> </div> </div>

node.js mongodb query was working fine until replica set setup and result is null -

i have followed mongo documentation @ http://docs.mongodb.org/manual/tutorial/deploy-replica-set-for-testing/ setup replica set (3 instances only) in local windows machine. tested followings , works fine: inserted data , connect primary using robomongo , can see data stop primary , 1 of secondary take on primary , data there. brought the 1 stopped , secondary now. my problems: when use robomongo connect of secondary can't see data although there. my query code below return null although there data in mongodb the connection string (no authentication needed) mongodb://mark2:27017,mark2:27018,mark2:27019/mydb?w=0&readpreference=secondary&replset=rs0 i rs.status() , shows 3 nodes active. { "_id" : "rs0", "version" : 3, "members" : [ { "_id" : 0, "host" : "mark2:27017" }, ...

Java, JavaScript: Avoid escaping particular HTML tags -

i using org.apache.commons.lang.stringescapeutils escape html tags: stringescapeutils.escapehtml(str); what want avoid escaping few particular tags. e.g. <h1>this h1</h1> <ul> <li></li> <li></li> </ul> after escaping should connvert < &lt; , > &gt; except <ul> , <li> tag. here don't want escape <ul> <li> tags because in html page have show content list need ul , li. how can in java , javascript. you don't want simple string escape util, you're using. what want html sanitizer, owasp java html sanitizer . allows whitelists of html tags not escape, e.g., custom html policies can specify allowed tags, in case default sanitizers don't meet needs. other libraries this, jsoup cleaning functionality .

algorithm - Snake Game in JavaScript: 2 Bugs Occuring -

i have 2 bugs infecting game. here's link have far: http://jaminweb.com/snake.html . use arrow keys control direction of snake. bugs: (1) program doesn't register when snake's head hits food. i'll have move on food several times, different directions, until works; or never works. (2) when snake hits food, it's supposed add link end, reason isn't working. relevant code: $(document).keydown(function(e) { switch(e.which) { case 37: // left arrow key s.redirect(3); break; case 38: // arrow key s.redirect(4); break; case 39: // right arrow key s.redirect(1) break; case 40: // down arrow key s.redirect(2); break; default: return; // exit handler other keys } e.preventdefault(); // prevent default action (scroll / move caret) }); ...

unit testing - Why isn't my delete_via_redirect test working in Rails? -

i can't logout test work, yet works in browser. cannot see wrong. test "logout user" chloe = login(:starrychloe, 'passpasspass') chloe.delete_via_redirect "/users/logout" chloe.assert_equal '/', chloe.path chloe.assert_equal "logged out!", chloe.flash.notice, chloe.flash.to_a chloe.assert_select '.button' |elem| puts elem end chloe.assert_select '.button', 'login' here error. still thinks logged in, though session destroyed , user_id no longer in session: started delete "/users/logout" 127.0.0.1 @ 2014-05-31 23:28:17 -0400 processing userscontroller#logout html ******************** {"session_id"=>"174289eb62bf8679db7f7b04e28c0822", "invalidlogin"=>0, "user_id"=>1, "flash"=>{"discard"=>["notice"], "flashes"=>{"notice"=>"logged in! last seen 172...

c++ - If my code uses RTTI then it will not work on android? -

i read in android native development kit cookbook that: by default, android provides minimal c++ support. there's no run-time type information (rtti) , c++ exceptions support, , c++ standard library support, partial. following list of c++ headers supported android ndk default: cassert, cctype,cerrno, cfloat, climits, cmath, csetjmp, csignal, cstddef, cstdint, cstdio, cstdlib, cstring, ctime, cwchar, new, stl_pair.h, typeinfo, utility it possible add more c++ support using different c++ libraries. ndk comes gabi++, stlport, , gnustl c++ libraries, besides system default one. in our sample code, used external "c" wrap c++ method. avoid c++ mangling of jni function names. c++ name mangling change function names include type information parameters, whether function virtual or not, , on. while enables c++ link overloaded functions, breaks jni function discovery mechanism. we can use explicit function registration method cover...

html - last div I added not positioning to bottom of page -

i don't know what's causing this.. added div onto page going wrapper footer (class = main_foot) , it's stuck in top left corner. goal: move div underneath div class="main_content" i checked make sure element's class correct in style sheet, position tags, idk. doesn't seem move. hopefully can notice problem. it's last div added. js fiddle: http://jsfiddle.net/73mk8/1/ header.php <html> <head> <html> <head> <title> crazy fat wrap* </title> <link href="../css/nav.css" rel="stylesheet" type="text/css"> <link href="../css/normalize.css" rel="stylesheet" type="text/css"> <link href="../css/body.css" rel="stylesheet" type="text/css"> <link href="../css/stylesheet.css" rel="stylesheet" type="text/css"> <meta http-equiv=...

vb.net - How do i load a text file from a listbox if the name is unkown in visual basic -

Image
so sitting here trying work open have 2 listboxs 1st selection list , if click on 1 of options pulls list of files , places them in listbox2. now trying workout how open files pulled in listbox if 1 selected in richtextbox. this have far, listbox 2is not working: private sub listbox1_selectedindexchanged(sender object, e eventargs) handles listbox1.selectedindexchanged if listbox1.text = "custom" dim folderinfo new io.directoryinfo("c:\users\a\desktop\project1\project1\my project\responses\custom") dim arrfilesinfolder() io.fileinfo dim fileinfolder io.fileinfo arrfilesinfolder = folderinfo.getfiles("*.*") each fileinfolder in arrfilesinfolder listbox2.items.add(fileinfolder.name) next end if end sub private sub listbox2_selectedindexchanged(sender object, e eventargs) handles listbox2.selectedindexchanged dim myfile string = dir$("c:\users\a\desktop\project1\project1\...

java - Switching JVM in Netbeans IDE -

i trying load video in jpanel using java swing framework. getting error . cannot load 32-bit swt libraries on 64-bit jvm tried finding 64-bit swt jars of links expired , not working. some people said should install 32-bit jvm purpose. want know " possible can switch jvm 32-bit ? , later can revert ?" . it save lot of time if possible. using windows 7, 64-bit , using 64-bit jvm. you have 2 options 1) use 64 bit swt libraries. 2) use 32 bit jvm. of course can switch 64 bit jvm 32 bit jvm out modifying java code . java bytecode platform independent, assuming use platform independent libraries. 32 vs64 bit shouldn't matter. but swt library have interact native system function ,so library platform dependent.

javascript - Store object dynamically in object -

this question might sound stupid or little simple got stuck. i have node.js app , need store clients able send information specific client specific other client. var clients = { }; var chat = io.of('/chat') .on('connection', function(socket) { socket .on('ehlo', function(data) { // mysql queries here etc client's data, // example session_id, customer name, ... // got stuck here, need save socket in customers object like: clients.(customer + data.get_customer_id) = { socket: socket }; i later need able access property different scope etc. basically lack idea of how these abstract methods can implemented: clients.addclient({ id: 123, socket: socket}); and later find them by: x = clients.findbyid(123); // x should { id: 123, socket: socket} well, can define clients module first. //clients.js "use strict"; var clients = { _db: [] }; clients.findbyid = function(id){ for...

android - Error parsing data org.json.JSONException: End of input at character 0 of -

i creating android application, in there search module user enters data send server , server sends output user , displayed in form of table. my problem getting error 06-02 00:08:43.971 19902-20586/com.diamond.traders w/singleclientconnmanager﹕ invalid use of singleclientconnmanager: connection still allocated. make sure release connection before allocating one. 06-02 00:08:43.991 19902-20586/com.diamond.traders w/system.err﹕ org.apache.http.client.httpresponseexception: not found 06-02 00:08:43.991 19902-20586/com.diamond.traders w/system.err﹕ @ org.apache.http.impl.client.basicresponsehandler.handleresponse(basicresponsehandler.java:71) 06-02 00:08:43.991 19902-20586/com.diamond.traders w/system.err﹕ @ org.apache.http.impl.client.basicresponsehandler.handleresponse(basicresponsehandler.java:59) 06-02 00:08:43.991 19902-20586/com.diamond.traders w/system.err﹕ @ org.apache.http.impl.client.abstracthttpclient.execute(abstracthttpclient.java:657) 06-02 00:08:43.991 199...

How to activate Ipython Notebook and QT Console with Python 3.4 in Anaconda 2.0 -

i have installed in window 7 environment anaconda 2.0. default python 2.7 python 3.4 installed. able activate python 3.4 command "activate py3k". after spyder ide work right python 3.4 1) i'm not able start ipython notebook , qt console python 3.4 2) i'm not able start anaconda python 3.4 default (so launcher starts 3 apps -spyder, ipython notebook , ipython qt console python 3.4) the launcher points root environment (python 2). if have activated python 3 environment, can launch notebook typing ipython notebook (and same qtconsole ipython qtconsole ).

AngularJS testing w/ jasmine and $httpBackend -

i'm experimenting angular , want able run automated tests jasmine. i'm having trouble setting test environment. have controllers & services separated separate files app.js (function (ng) { 'use strict'; ng.module('demo', ['marvel', 'ngroute']); }(window.angular)); controllers.js (function (app) { 'use strict'; function paging(pageindex, pagesize, total) { var url = '/characters/' , last = math.floor(total / pagesize); this.first = pageindex === 0 ? null : url + '0'; this.previous = pageindex === 0 ? null : url + (pageindex - 1).tostring(); this.next = last <= pageindex ? null : url + (pageindex + 1); this.last = last <= pageindex ? null : url + last; }; app.controller('characterscontroller', function ($scope, $routeparams, marvelrepository) { var pageindex = parseint($routeparams.pageindex); marvelrepository.fetch(pageindex).then(function (data) { ...

Designing a database with relational tables in MySQL using Phpmyadmin -

i need tips when comes designing tables in database. designing employee meal system monitors , processes meal logs of employees (like attendance) problem here, have 2 tables: employee_table , log_table. employee table contains basic employee information , has unique key (not primary one) employee_number. , then, there's table, log_time, contains swipe data of employees. now, 2 tables contain , employee_number column. how make relation out of them? can bind them when call employee_number column on log_time basic information of employee on other table well? sorry because i'm having hard time when comes designing database. sql syntax relation might this: create table employee_table( foreign key (employee_number) references employees(number), ...other stuff... ) with table looks like create table employees( number int(10) not null ) here's great site on sql foreign keys: http://www.sitepoint.com/mysql-foreign-keys-quicker-database-development/ ...

php - codeigniter localhost email not sending -

i have problem , don't understand. code $this->load->library('email'); $config['protocol'] = 'sendmail'; $config['mailpath'] = '/usr/sbin/sendmail'; $config['charset'] = 'iso-8859-1'; $config['wordwrap'] = true; $this->email->initialize($config); $this->email->from('rudzstyle@yahoo.co.id', 'your name'); $this->email->to('rudzstyle@gmail.com'); $message = $data->nama_depan.'<br>'.$this->input->post('snk'); $this->email->subject($message); $this->email->message('testing email class.'); $this->email->send(); echo $this->email->print_debugger(); that 2 email active email. and result of debugger this exit status code: 1 unable open socket sendmail. please check settings. unable send email using php sendmail. server might not configured send mail using method. user-agent: codeigniter d...

javascript - backbone-forms: style options of a select field? -

i using backbone-forms , i'm wondering, whether possible add styles options ( <option> ) in select field. app quite complex snippet here: this.schema = { xname : { title : i18n.t('x.name') + " " + i18n.t('x.name-msg'), type : 'text', validators : [ { type : 'required', message : i18n.t('x.name-required-msg') }, { type : 'regexp', regexp : /.{3,}/, message : i18n.t('x.name-tooshort-msg') } ], }, */ ... */ selecty : { title : i18n.t('y.project'), type : 'select', options : this.getsomeoptions() //is defined , works well!! } /* , on ... */ now quite obvious, cannot add style attribute selecty in or...

regex - Python regular expression for finding string in between the text file -

i'm working on python code extract specific strings on text file between ' ' . here's code i'm working on: import re pattern = "(\w+'*',)" open('c:\documents , settings\ash\desktop\strcount.txt', "r") text: line in text: print re.findall(pattern, line) and list of strings in text file ('flbc8u', 24) ('chvquw', 24) ('7fdm@', 24) ('15ii?', 24) ('h!ode', 24) ('rb6#u', 24) ('uamer', 24) ('6nmdj', 24) ('d-ms1', 24) ('ejf&b', 24) i wanted take string in middle of ' ' single quotation mark before comma , number , bracket ignored s = "'flbc8u', 24" print re.findall("'([^']*)'", s)[0] flbc8u

c# - How to properly release memory when doing custom marshaling (ICustomMarshaler) from native to managed? -

my main app in c# , i'm trying write dll (for input-output) should portable (in c or c++ both windows , linux) , accessible both others c++ apps , main c# app. although inside dll use c++ make life easier, use c-style methods interface, i.e. have extern "c" { /* methods */} in headers. thought better having c++/cli wrapper (hope right choice since i'm far enough, glad hear suggestions on matter). now in native dll have structs, contain several other structs , arrays. simplify (a lot) following example: typedef struct astructnative{ size_t length, void* bstructs; }astructnative; typedef struct bstructnative{ int16_t a; int16_t b; }bstructnative; and c# counterparts: public class astruct { bstruct[] array; } public struct bstruct { short a; short b; } i make use of icustommarshaler , astruct (1) can passed native dll (when writing) or (2) can got dll (when reading back). think i've been successful case (1) (at least...

Effective way to find checksum in perl without memory leakage -

in program need checksum many files. checksum calculation within find command. find(sub { $file = $file::find::name; return if ! length($file); open (file, "$file"); $chksum = md5_base64(<file>); close file; }, "/home/nijin"); the above code works perfectly. if there file large size example 6gb in path /home/nijin, load 6 gb ram memory , process takes 6 gb ram continuously until process completed. please note backup process , take more 12 hours process complete. lose 6gb until process completed. worst case process gets hangs due large memory usage. option have tried use file::map . code pasted below. find(sub { $file = $file::find::name; return if ! length($file); map_file $map, "$filename", '<'; $chksum = md5_base64($map); }, "/home/nijin"); the above code works getting segmentation fault error while using above code. have tried sys::mmap having same issue first o...

c# - Send parts of a byte[] by webclient to create a large file in server side -

so trying transfer large byte[] chose separate in chunks of 20mb, , in first chunk received create file , add that,the rest open existing file , add remaining.the problem having instead of send first part , reconnect receive second part establishing 2 connections , sending 2 chunks @ same time.. how can send second after first finished? client.openwriteasync(ub.uri); void client_openwritecompleted(object sender, openwritecompletedeventargs e) { if (e.cancelled) { messagebox.show("cancelled"); } else if (e.error != null) { messagebox.show("deu erro"); } else { try { using (stream output = e.result) { int countbytes; //for (int = 0; < max; i++) //{ if ( (max+1) != maxaux) { countbytes = zippedmemorystream.read(partofdataset, 0 , 20000000);//maxaux * 20000000 ...

Mocking Excel's Comment.Text() in c# with moq -

currently trying mock text() method excel's comment interface in c# moq. msdn link text() my problem is, have call no parameters because want read content. when calling text() this: mockcomment.setup(m => m.text()).returns("test comment") following error shown: an expression tree may not contain call or invocation uses optional arguments how can call text() moq can mock method? i aware of question link problem not have parameters pass. clr not support calling methods optional arguments either when arguments not provided explicitly , since il-compiled code c# compiler inserts default values @ compile time. refer this , states underlying expression tree api not support optional arguments .

ruby on rails - Pass XML value from one page other page -

i want pass xml value 1 page in better way. i getting xml value api: <hotelist> <hotel> <hotelid>109</hotelid> <hotelname>hotel sara</hotelname> <location>uk,london</location> </hotel> <hotel> <hotelid>110</hotelid> <hotelname>radha park</hotelname> <location>uk,london</location> </hotel> <hotel> <hotelid>111</hotelid> <hotelname>hotel green park</hotelname> <location>chennai,india</location> </hotel> <hotel> <hotelid>112</hotelid> <hotelname>hotel mauria</hotelname> <location>paris,france</location> </hotel> </hotelist> i want pass 1 hotel: <hotel> <hotelid>112</hotelid> <hotelname>hotel mauria</hotelname> <location>paris,france</location> </hotel> ...

jsf 2 - JSF ui:insert with f:attribute to change attribute of a p:commandButton -

i've got project jsf 2.1.28 , primefaces 4.0 . i've got problem editor controller template. my page this: <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets"> <p:panel header="#{loccommon.report} #{loccommon.editor}"> <h:form id="editform"> <h:panelgrid columns="2"> <p:outputlabel value="#{loccommon.name}" /> <p:inputtext value="#{reportbean.businessitem.name}" /> <p:outputlabel value="hql" /> <p:selectbooleancheckbox value="#{reportbean.businessitem.hql}" /> <p:outputlabel value="sql" /> <p:inputtextarea value="#{reportbean.businessitem.s...

c - Pointer as parameter is null but after function pointer is not null -

this question has answer here: changing address contained pointer using function 5 answers hello have funcion like: void enterstring(char *string) { string = (char*)malloc(15); printf("enter string: "); scanf("%s",string); //don't care length of string } int main() { char *my_string = null; enterstring(my_string); printf("my string: %s\n",my_string); /* it's null want show string typed enterstring */ return 0; } i want string function show on string in main ... don't know if you'll understand me. thank :) you passing string value. neet pass address : void enterstring(char **string) { *string = (char*)malloc(15); printf("enter string: "); scanf("%s",*string); /...

lucene - Integrating solr and openNLP -

i followed link integrate https://wiki.apache.org/solr/opennlp installation for english language testing: until lucene-2899 committed: pull latest trunk or 4.0 branch apply latest lucene-2899 patch do 'ant compile' cd solr/contrib/opennlp/src/test-files/training i followed first 2 steps got following error while executing 3rd point common.compile-core: [javac] compiling 10 source files /home/biginfolabs/solrtest/solr-lucene-trunk3/lucene/build/analysis/opennlp/classes/java [javac] warning: [path] bad path element "/home/biginfolabs/solrtest/solr-lucene-trunk3/lucene/analysis/opennlp/lib/jwnl-1.3.3.jar": no such file or directory [javac] /home/biginfolabs/solrtest/solr-lucene-trunk3/lucene/analysis/opennlp/src/java/org/apache/lucene/analysis/opennlp/filterpayloadsfilter.java:43: error: cannot find symbol [javac] super(version.lucene_44, input); [javac] ^ [javac] symbol: variable lucene_44 [javac] ...

Git error : The remote end hung up unexpectedly -

when typing following command: git clone git://git.code.sf.net/p/biodoop-seal/code biodoop-seal-code i getting error below: fatal: remote end hung unexpectedly i cannot understand why happening. please help.

c# - Is there a neat way to compare nullable and dbnullable objects? -

i have code this: foreach (datarow row in datatable.rows) { if ((string)row["forename"] != record.forename) { // } } works great if row["forename"] null in database, dbnull here , can't cast dbnull string, or perform comparison between dbnull , string . values nullable<int> , , can't compare dbnull int? is there helper method let me nice comparisons or have write extension method myself? you can use datarow.field extension method supports nullable types: foreach (datarow row in datatable.rows) { int? id = row.field<int?>("id"); if(id.hasvalue) { console.write("id: " + id.value); } } since string reference type null default. can use datarow.isnull instead check whether dbnull.value or not: foreach (datarow row in datatable.rows) { if(row.isnull("forename")) { // ... } else { string for...

c# - dynamic/ExpandoObject method throws 'No default member found for type 'Action' -

i can't dynamic method on expandoobject directly callable in vb.net. in c# following works: dynamic obj = new system.dynamic.expandoobject(); var called = false; obj.forcerefresh = new action(() => called = true); obj.forcerefresh(); i'd have thought same thing in vb.net be: dim called = false dim obj object = new dynamic.expandoobject obj.forcerefresh = new action(sub() called = true) obj.forcerefresh() 'no default member found type 'action'. obj.forcerefresh.invoke() 'this works the obj.forcerefresh throws 'no default member found type 'action' it works if put invoke, that's not option (this simplified example of moq unit test, objects being tested call functions can't change them) is there way of setting dynamic method in vb.net can call without invoke? there doesn't seem way around - need use "invoke" call dynamically-added methods in vb. the following microsoft link showing c# vs vb ...

ruby - uninitialized constant Minitest::Assertion (NameError) -

first i'm new ruby , gems , great stuff i'm sorry if content or context sucks here. here issue, using cucumber. whenever make assert call step definition file like... assert(false, 'my message') i receive following error uninitialized constant minitest::assertion (nameerror) how resolve error? here gem list of gems have installed , ruby version i'm using. ruby 1.9.3p448 (2013-06-27) [i386-mingw32] bigdecimal (1.2.5, 1.1.0) builder (3.2.2) childprocess (0.5.3, 0.3.9) cucumber (1.3.15, 1.3.8) diff-lcs (1.2.5, 1.2.4) ffi (1.9.3 x86-mingw32, 1.9.0 x86-mingw32) gherkin (2.12.2 x86-mingw32) io-console (0.4.2, 0.3) json (1.8.1, 1.5.5) minitest (5.3.4, 2.5.1) multi_json (1.10.1, 1.8.2) multi_test (0.1.1, 0.0.2) rake (10.3.2, 0.9.2.2) rdoc (4.1.1, 4.0.1, 3.9.5) rubyzip (1.1.3, 1.0.0) selenium-webdriver (2.41.0, 2.37.0) watir-webdriver (0.6.9, 0.6.4) websocket (1.1.4, 1.0.7)

java - Hibernate one to one mapping. Schema generation issue -

i generating schema hibernate mapping. reason 1 one mapping not getting generated properly. here classes: @entity @table(name = "resturant") public class restaurant { private integer restid; private string restaurantname; private foursquare foursquare; @id @column(name = "restid") @generatedvalue(strategy = generationtype.auto) public integer getid() { return restid; } public void setid(integer id) { this.restid = id; } @onetoone(fetch = fetchtype.lazy, mappedby = "restaurant", cascade = cascadetype.all) public foursquare getfoursquare() { return foursquare; } public void setfoursquare(foursquare foursquare) { this.foursquare = foursquare; } @column(name = "restname") public string getrestaurantname() { return restaurantname; } public void setrestaurantname(string restaurantname) { this.restaurantname = restaura...

r - Reading a user input (character or string of letters) into ggplot command inside a switch statement or a nested ifelse (with functions in it) -

i have code like aa <- as.integer(readline("select number")) switch(aa, 1={ num <-as.integer(readline("select 1 of options \n")) print('you have selected option 1') #reading user data var <- readline("enter variable name \n") #aggregating data based on required condition gg1 <- aggregate(cbind(get(var))~mi+hours,a, fun=mean) #ploting ggplot(gg1, aes(x = hours, y = get(var), group = mi, fill = mi, color = mi)) + geom_point() + geom_smooth(stat="smooth", alpha = i(0.01)) }, 2={ print('bar') }, { print('default') } ) the dataset [dataset][1] i have loaded dataset object list a <- read.table(file.choose(), header=false,col.names= c("ei","mi","hours","nphy","cphy","chlphy","nhet","chet","ndet","cdet","don","doc","din...