Posts

Showing posts from May, 2012

gate - How to get the name of the document, the pipeline is currently working on? -

let's say, corpus have 1k docs, , processed pipeline. @ point, pipeline stucks, throws exception or have funny behavior. these document-relevant. it'd nice know document being processed in pipeline. example, print out doc name in jape transducer. to document processing can write simple jape rule like: phase: docname input: token options: control = once rule:docname ( {token} ) --> { system.out.println(doc.getname()); } put rule first rule in pipeline. hope have least 1 token in document.

php - Form with login and password not working -

i'm trying create form login , password can not authenticate. have checked mysql query , ok. think problem comes $stmt->num_rows(); returns 0 . php form <?require('cabecera.php');?> <!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>pujas</title> <script type="text/javascript" src="jquery-1.9.1.min.js"></script> </head> <body> <div id='login'> <input type="text" name="txtuser" id="txtuser"> <input type="text" name="txtpass" id="txtpass"> <input type="button" name="butconectar" id="butconectar" value="conectar"> </div> </body> <? if ($_session['

Devise with Rails 4 -

the team behind devise announced via blogpost http://blog.plataformatec.com.br/2013/05/devise-and-rails-4/ releasing version compatible rails 4, calling '3.0 rc'. in same blog post, said it's releasing devise 2.2.4. i'm trying build rails 4 app. when did gem install devise , installed 2.2.4, not version compatible rails 4. fetching: devise-2.2.4.gem (100%) which assume comments in blogpost strong parameters not going compatible rails 4. i looked @ devise's github page it's not obvious me how install version compatible rails 4. can assist? https://github.com/plataformatec/devise note, tried gem install devise --version 3.0.0.rc1 but said error: not find valid gem 'devise' (= 3.0.0.rc1) in repository error: possible alternatives: devise devise compatible rails 4 out of box of time of answer. our end goal have users able register, log in , log out of website. we'll create small partial view letting know if we'

javascript - Cannot focus on button when focused in textarea in mobile -

i have textarea when user types text , clicks button underneath, button not work first time, have push twice on button make work. it's if first time click focusing out of textarea (the keyboard closes) , second time click button. happens in mobile (galaxy s3 , iphone4). anyone know can stop doing that? this js code jquery('.nextbutton').click(function () { alert('clicked'); }); html <div class="questionoptions selectiontextarea"> <textarea rows="4" cols="40" name="s3q1" id="textareas3q1"></textarea> <input type="button" value="next" class="nextbutton"> </div> try add return false; jquery('.nextbutton').click(function () { alert('clicked'); return false; });

javascript - Do variables get overwritten -

i have question declaration of variables in javascript , java. let's in java declare in code variable int x = 6; global variable , along way change x = 10 . x variable replace 6 10 permanently? in javascript, lets says have var area = 6 change area = 12 along way global variable, not local, inside function. overwritten permanently? int 'primitives' in java , javascript, , stored value in variable names them. when change variable's int, value inside of variable directly changed. old value not exist anymore. (we call kind of behaviour value-type) however, objects different, variables reference objects - , depending on whether object mutable (e.g. java arrays) or immutable (e.g. java strings), operations on object either alter object such every variable referencing sees changes, or create new object changes, such variables referring new object see changes, old object immutable forever.

Can't run Perl script on other computer -

when try run script on second computer message: malformed json string, neither array, object, number, string or atom, @ character offset 0 (before "lwp support htt...") @ iptest.pl line 21, line 2. on first computer, script works fine. line 21: my $data = decode_json($resp->content); does know problem can be? thanks in advance i'm bit surprised json error error get. contain tiny little hint: "lwp support htt...". bet lwp missing module needs able make https connections. have 2 options: print $response->content see full error message. on command line, lwp-request https://google.com/ . should see full error message. then install missing module. and of course: please, please, please: use strict , use warnings clean script , throw away every use -line don't need: io::socket, lwp::simple, yaml::tiny. read documentation of modules using. trying achieve lwp::useragent->new(keep_alive) ? hint: won't quote keep_

ios - Crash report when user accesses the address book -

in app, crashlytics used gather crash reports users. here 1 crash report user. possibly depending on contacts informations of user. can not recreate crash, not know what's in his/her contacts. 1 has idea situation? com.apple.root.default-priority crashed 0 corefoundation cfstringcreatecopy + 13 1 appsupport cpsqlitedatabasecreatewithpath + 36 2 appsupport cpsqlitedatabasecreatewithpath + 36 3 appsupport cprecordstoregetdatabase + 16 4 appsupport _getreaderconnection + 10 5 appsupport cprecordstoreprocessquerywithbindblock + 22 6 appsupport cprecordstorecopyallinstancesofclasswherewithbindblock + 98 7 addressbook abccopyarrayofallpeopleinsourcewithsortordering + 244 8 seeyoukee phonenumberinputviewcontroller.m line 538-[phonenumberinputviewcontroller dofetchcontacts:] 9 addressbook __37-[abtcc accessrequestwithcompletion:]_block_invoke_0 + 26 10 tcc __tccaccessrequest_block_invoke_038 + 316 11 ... libxpc.dylib _xpc_conne

How to delete all divs with at least one child using jquery? -

i want delete divs has @ least 1 child using jquery. example need delete divs containing paragraph 'hello' , 'world'. can 1 please ? <div style="background:#ff0000;height:200px;width:200px;"> <p> hello </p> </div> <div style="background:#00ff00;height:200px;width:200px; "> </div> <div style="background:#0000ff;height:200px;width:200px;"> </div> <div style="background:#aaaa3a;height:200px;width:200px;"> <p>world </p> </div> try :has selector $('div:has(*)').remove(); http://jsfiddle.net/9gdmn/

regex - MySql REGEXP - how to extract 7 digit value from URL -

i have link (shown below ) field in table values like: http://test.abc.com/carrier/ca-9265/2360283/?id=41352626&src=j2w&eid=72-201301190212-88381790 http://test.abc.com/sub/carrier/ca-12656/4322830/?id=41352626&src=j2w&eid=72-201301190212-88381790 i need extract 7 digit code links. code: 1 - 7 digit not containing character. 2 - contains '/carrier/' , comes 1 section away '/carrier/' . in above links code 2360283 , 4322830. please suggest select query regexp . thanks, try $str = 'http://test.abc.com/carrier/ca-9265/2360283/?id=41352626&src=j2w&...'; select substring_index( substring_index($str,'/',-2),'/',1) // return 2360283 read substring_index more

How to combine equality operators in an if statement in java? -

in python, can if(a!=b!=c) how can same thing in java without having separate them , write "&&" operators? i'm trying check 10 elements not equal, , don't want have write equality statement 45 times. you cannot operation in java. note furthermore if a , b , etc., not primitives, should using equals instead of == (or != ). latter check object identity, not equality of values. if want check whether 10 elements distinct, can throw them set implementation (such hashset ) , check set contains 10 elements. or better (thanks @allonhadaya comment), check each element added. here's generic method works arbitrary number of objects of arbitrary type: public static <t> boolean aredistinct(t... elements) { set<t> set = new hashset<t>(); (t element : elements) { if (!set.add(element)) { return false; } } return true; } if elements primitives (e.g., int ), can write non-generic versio

Add Close Accordion Function to Jquery Script -

i have script found here: (function() { var $container = $('.acc-container'), $trigger = $('.acc-trigger'); $container.hide(); $trigger.first().addclass('active').next().show(); var fullwidth = $container.outerwidth(true); $trigger.css('width', fullwidth); $container.css('width', fullwidth); $trigger.on('click', function(e) { if( $(this).next().is(':hidden') ) { $trigger.removeclass('active').next().slideup(300); $(this).toggleclass('active').next().slidedown(300); } e.preventdefault(); }); // resize $(window).on('resize', function() { fullwidth = $container.outerwidth(true) $trigger.css('width', $trigger.parent().width() ); $container.css('width', $container.parent().width() ); }); })(); and can't figure out add ability not automatically reveal firs

php - set variables to global scope within a loop -

i want define number of temporary global variables in php called $myglobalvar1 , $myglobalvar2 ... , problem keyword 'global' takes variable name literally: for ($i = 1; $i<= 10; $i++) { $var = '$myglobalvar'.$i; global $var; } i.e. $var global. setting quotes not work because 'global' expects '$' , stop execution @ single quote: for ($i = 1; $i<= 10; $i++) { $var = '$myglobalvar'.$i; global '$var'; } how set variables global scope? thanks. since using ' taken string try $globals purpose for ($i = 1; $i<= 10; $i++) { // acess $globals['myglobalvar'.$i] , whatever want $globals['myglobalvar'.$i] = null }

.htaccess - Setting database dynamically according to sub-domain URL in codeigniter? -

i working on codeigniter site.i have 1 single application application used various user each user having own db(its own clients also).i need way how approach cloud system. have single copy of application folder , difference in db each user. have tried creating subdomain directory in codeigniter , writing index file , htaccess file can access original application.but need subdomain path in url , way how connect database according subdomian url path. htaccess file. rewriteengine on rewriterule /test/(.*) /$1 [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /index.php which way should follow complete work.please in advance. here's do: in config/database.php, define set of different db settings, picked based on domain. can adjust/extend easily. if($_server['server_name'] == 'www.stagingserver.com'){ $active_group = "staging"; $db['staging']['hostname'] = "95.xxx.xxx.xxx&

performance - How to implement tire map in java? -

i want tire map blow: map<string,object> map = new tiremap(); map.put("com","1"); map.put("com.aa","2"); map.put("com.aa.bb","3"); map.get("com");// return ["1","2","3"] map.get("com.a"); //return ["2","3"] map.get("com.aa"); //return ["2","3"] // key maybe full key or key prefix how implement map this? or there exits map in java api or open source? it's innodb in mysql. ps: performance important. storage items more 1000w. i try out treemap java.util. map u need. manages keys based on natural order (defined comparator in key class). methods tailmap , headmap gives map keys need. example public static void main(string[] args) { treemap<string, object> map = new treemap<string, object>(); map.put("com","1"); map.put("com.aa","2&q

MFC create modeless popup window in modal dialog -

i managed create , show modeless window in property page's message handler: m_plistctrl = new clistctrl(); m_pparent->screentoclient(rtlist); m_plistctrl->createex(ws_ex_topmost, ws_child|ws_visible|lvs_list, rtlist, m_pparent, idc_list_info); m_plistctrl->showwindow(sw_shownormal); but list ctrl cannot work me, doesn't keep focused or active(it cannot capture , handle client area itself, e.g. editbox behind can paint upon it) hope able behave dropdown list combobox. didn't use combobox because cannot use cue banner of combobox project didn't define unicode. title, wondering if it's possible make custom popup window(it can mfc control or common dialog) work in modal dialog. pretty sure possible in modeless window. i put control in dialog , domodal dialog, works me.

java - 404 when running project through eclipse on Tomcat -

Image
i have struts 2 project following directory structure. when try run project using eclipse on tomcat 7, gives me 404 error. struts.xml : <?xml version="1.0" encoding="utf-8"?> <struts> <action name="login" class="com.actions.loginaction" method="execute"> <result name="success">/jsp/login.jsp</result> </action> </struts> login.jsp : <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>login page</title> </head> <body> <s:form action="login" method="post"> login name : <input type="text" value="name"/> </s:form> </body> </html> on running @ path http://localhost:8080/strutspro/jsp/login.jsp , gives http 404, why? examine web.xml instead. else put .jsp files in webcontent fo

How to check whether Id already exist in the database or not in Android? -

my problem is, have created app need download documents, want compare value/id whether exist in database or not, if exist copy , replace existing one. have document id unique or primary key. i read tutorials no benefit. this code: intent = new intent(); i.putextra("item_name", item_name.folder_name); i.putextra("item_url", item_url.url); i.putextra("id", documentid.id); string doc_id = i.getstringextra("id"); string name = i.getstringextra("item_name"); string url = i.getstringextra("item_url"); i.getstringextra("item_type"); database = new dms_database(files_folders_activity.this); database.save_doc(doc_id, name, url); database.close(); // check here if doc_id exist show toast, // how perform function exist???? downloadmanager.request request = new downloadmanager.re

c++ - Problems with Delegate Template Metaprogramming -

the below code adapted programmer yingle jia's code , i'm having port linux. compiles fine in vs2010, when try building in ubuntu gcc 4.6.3, shows errors @ template <class r acf_delegate_comma acf_delegate_template_params> class delegate<r (acf_delegate_template_args)> the error message being: ../../../mysdk-master/include/abc/delegatetemplate.h:45:1: error: pasting "," , "class" not give valid preprocessing token ../../../mysdk-master/include/abc/delegatetemplate.h:46:1: error: pasting "," , "t" not give valid preprocessing token ../../../mysdk-master/include/abc/delegatetemplate.h:74:1: error: pasting "," , "a" not give valid preprocessing token lines 45 , 46 2 lines of code of delegatetemplate.h i've pasted above. delegate.h // copyright (c) 2004-2005 yingle jia // // permission copy, use, modify, sell , distribute software // granted provided copyright notice appears in copies.

backbone.js - Backbone - before route / view change event -

i want execute method on view before changing other view. example. var homeview = backbone.view.extend({ ......, close: function() { } }); var loginview = backbone.view.extend({ ...... } }); if current view "homeview" , if going switch "loginview", need execute close function in homeview before changing loginview. there way? in other words, view should execute close function automatically before going changed. i have seen of stackoverflow's previous posts. seems outdated or not useful context. if use router switch between views: var homeview = backbone.view.extend({ initialize : function(){ /* router here references global router object "route" event triggered when route has been matched; if want call close function when navigating login view may use "route:login" */ this.listento( router , "route", this.close ); }, close: fu

javascript - Phonegap back button not working when cursor focus on a field -

i overide backbutton event on apps javascript this: document.addeventlistener("backbutton", function (e) { e.preventdefault(); navigator.app.backhistory(); }, false); if cursor not focussed on element exists on webview (cordovawebview), pressing button fine, in case previous activity. but, if cursor focussed on field form, e.g. input field or button, button not working or hide keyboard. logcat show this, when pressed button. 05-13 12:47:41.463: d/cordovawebview(14396): current url is: file:///android_asset/www/login.html#register 05-13 12:47:41.463: d/cordovawebview(14396): url @ item 0 is:file:///android_asset/www/login.html#register 05-13 12:47:41.663: d/cordovawebview(14396): current url is: file:///android_asset/www/login.html#register 05-13 12:47:41.663: d/cordovawebview(14396): url @ item 0 is:file:///android_asset/www/login.html#register 05-13 12:47:42.203: d/cordovawebview(14396): current url is: file:///android_asset/www/login.html#register 05-13

playframework - Support for HTTP "MERGE" verb in Play! Framework 2.1? -

i'm attempting implement odata service on play! framework. when updating records, odata client "jaydata" uses 'merge' http verb/method submit changes, doesn't appear supported @ play framework. is there anyway add support this? merge won't supported because not valid http method . in order use arbitrary http method in request, use execute method wsrequestholder .

namespaces - Reserved atribute names in Ember.js models -

i have post model following fields: blogapp.post = ds.model.extend({ author: ds.attr('string'), title: ds.attr('string'), preamble: ds.attr('string'), content: ds.attr('string'), created: ds.attr('date'), comments: ds.hasmany('blogapp.comment'), lastupdate: ds.attr('date') }); after rendering, instead of post.content, result like: <blogapp.post:ember272:1> other fields rendering ok. guess content conflicting internal property. have few questions: is there workarround when rest api has names conflict ember internals? is there other forbiden attribute names should aware? [update] the name clash controller, not model. not definitive list watch out other common database column names like: model transaction is_new is_deleted store errors i guess ember developers not afraid of namespace-related bugs poor pythonist. btw, angular.js guys got right: prefix api attribute

What is the difference between clojure's APersistentMap implementations -

i'm trying figure out difference between persistenthashmap, persistentarraymap, persistenttreemap, , persistentstructmap. also if use {:a 1} gives me persistentarraymap can change of other ones if give objects or things other keys? the 4 implementations list fall 3 groups: "literal" : persistentarraymap , persistenthashmap : basic map types used when dealing map literals (though constructor functions available different behaviour around handling duplicate keys -- in clojure 1.5.x literals throw exceptions when discover duplicate keys, constructor functions work left-to-right repeated conj ing; behaviour has been evolving version version). array maps promoted hash maps when growing beyond number of entries (9 iirc). array maps exist because faster small maps; differ hash maps in keep entries in insertion order prior promotion hash map (you can use clojure.core/array-map arbitrarily large array maps, may useful if know you'd benefit insertion-order

eclipse - Grails test war creation error -

need dear friend.... using grails 2.1.4 , maven integration. i created pom file grails project. running goal eclipse mvn -dgrails.env=test package i getting error this: fatal error forking grails jvm: java.lang.reflect.invocationtargetexception java.lang.runtimeexception: java.lang.reflect.invocationtargetexception @ org.grails.launcher.grailslauncher.launch(grailslauncher.java:150) @ org.grails.maven.plugin.tools.forkedgrailsruntime.main(forkedgrailsruntime.java:168) caused by: java.lang.reflect.invocationtargetexception @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:601) @ org.grails.launcher.grailslauncher.launch(grailslauncher.java:144) ... 1 more caused by: java.lang.illegalstateexception: user input not enabled,

asp.net mvc - mvc 4 reusable controls in one page -

i new mvc framework. when using web form, user control can assigned parameter in page , can generated unique id in page. though implemented control more 1 time in same page. in mvc framework, partial view way implement reusable control. got problems below. how implement same reusable control more once in same page different parameters. i know renderpartialextensions.renderpartial can pass different viewdata, if partial view implementing javascripts/jquery, generate issue id in same page you can differentiate id within passed models . can put example unique member model , use inside partial view : <p id="element@(model.unique.tostring()) ></p> or avoid id selection inside jscript @ all. example use class selectors

android - How to know what view is in the same context than other -

i have class have list 3 webview different activities public class class { private list<webview> webviews; . . . public void bindonclickevent(actionmethod amethod, view control){ control.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { //here need know webview in webviews in same context view control //webview.loadurl("javascript:myjsfunction(\'"+s+"\');"); } }); } } i need use inside of method onclick(view v) webview (that can found in list "webviews") in same context parameter view v. any idea? thanks! view has method getcontext() . should able compare contexts determine view s belong activity s.

c++ - case break causing error while compiling with gcc -

error while compiling error: break statement not within loop or switch case label 'not within switch statement i couldn't attach whole code because it's bug if insist see whole thing let me know , i'll upload how. void s9xsetupdefaultkeymap() { s9xunmapallcontrols(); // build key map s9xcommand_t cmd; // player 1 s9xmapbutton( 65, cmd = s9xgetcommandt("joypad1 left"), false ); // s9xmapbutton( 68, cmd = s9xgetcommandt("joypad1 right"), false ); // d s9xmapbutton( 87, cmd = s9xgetcommandt("joypad1 up"), false ); // w s9xmapbutton( 83, cmd = s9xgetcommandt("joypad1 down"), false ); // s s9xmapbutton( 79, cmd = s9xgetcommandt("joypad1 x"), false ); // o s9xmapbutton( 80, cmd = s9xgetcommandt("joypad1 y"), false ); // p s9xmapbutton( 75, cmd = s9xgetcommandt("joypad1 a"), false ); // k s9xmapbutton( 76, cmd = s

google chart script for time table/bar -

Image
how write code draw google chart of time bar. bar has start point , length, , function timebar(start time, duration). have looked sample codes on google, no lucky. thanks. if you're using charts services in google apps script, limited chart types provided service. won't able create specific visualization there. in html / javascript, might able close want using technique described in this answer . using google chart tools outside of apps script, can create own chart app or gadget, using google visualization api. how create new chart gadget? best way started first familiar developers guide , , read gadget extensions section , start coding.

php - Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object hasn't 'source' property in -

i trying connect osticket support system opencart. tried integrate soap <?php error_reporting(e_all); ini_set('display_errors', '1'); $osticket = new soapclient('http://www.website.com/osticket/api/soap/index.php?wsdl'); // set parameters $args = array( 'username' => 'webservice', 'password' => 'mysecr3tp@ssword', 'origin' => 'web', 'alertuser' => true, 'alertstaff' => true, 'ticketdata' => array( 'name' => utf8_encode('sir test'), 'email' => utf8_encode('some@email.com'), 'subject' => utf8_encode('testing'), 'message' => utf8_encode('this message'), 'topicid' => 3, //topic website support 'deptid' => 2, //department sales 'staffid' =

c++ - Reverse an array in pointer -

here question: write function void reverse(char s[]) reverses character string. example, “harry” becomes “yrrah”. and here code : void reverse(char s[]); int main() { char s [] = "harry"; reverse(s); cout << s << endl; system("pause"); return 0; } void reverse(char s[]) { int length = strlen(s); int c, ,j; for(int i=0, j=length-1 ; i<j ; i++, j--) { c = s[i]; s[i] = s[j]; s[j] = c; } } it works reverse string. however, asked in pointer. thought, first assign p pointer first char in string. assign q pointer last char of string. loop thru reverse array. when tried last char: char *q = strlen(s-1); i got error. can me fix using pointer? updated portion if (strlen(s) > 0( { char* first = &s[0]; char*last = &s[strlen(s)-1]; while(first < last) { char temp = *first; *first = *last; *last = temp; ++first; --last; } } try that. char* left = &

php - How to search in an output generated by a http request -

i using this api searching postcodes in range around it. generates automatic output when type in postcode (1234) example. it's using jquery autocomplete that. now question. how can save output in session , search within session match of postcodes have in companydatabase? my code looks this: my form: <form action="#" method="post" class="pro6pp_range"> <input type="text" class="postcode" placeholder="postcode (1234)" maxlength="4"> <select class="range"> <option value="5" selected="selected">5 km</option> <option value="10">10 km</option> <option value="15">15 km</option> <option value="20">20 km</option> <option value="25">25 km</option> </select> <br/><br/> <span class

java - not all junit tests are running in eclipse -

Image
i have java project in eclipse, when press project right click -> run junit tests not run. attached picture, see yamimailsendertest example. when try run tests directly running. using eclipse 3.7.2. and expanded view: any idea? ran same problem, error wrote: public void mymethodname(){ //assertions } instead of: public void testmymethodname() { //assertions } the test before mymethodname important.

Pass data between activities in a single android app -

i have situation stated below: __> b(setup page)------------> d(account settings) *all users have / | same layout / (has 10 rows/users) / (click 1 of account/row, highlight) / (once row selected, , click done, data saved in d / jumped , passed c. a(welcome page) \ \__> c(remote page) above illustration of overall program~ i not know how pass data d through b c~ can guide me? code in c incomplete because has other function , class not related it. code: // code b: public class accountsetup extends activity { tablerow tablerow1, tablerow2, tablerow3, tablerow4, tablerow5, tablerow6, tablerow7, tablerow8, tablerow9, tablerow10; view border1, border2, border3, border4, border5, border6, border7, border8, border9, border10; @override public void oncreate(bundle savedinstancestate) {