Posts

Showing posts from June, 2010

javascript - Removing Size and font-size from child elements -

i want remove element attributes divs. divs generated automatically. want iterate through each div , child divs , want remove font-size (font-size: xpx) , size inside font tag <font size="x"> . these examples of div. <div id="headline" class="headline" style="position: word-break: break-all; background-color: rgb(90, 88, 84); width:300px;height:250px"> <div style="text-align: center; font-size: 12px; color: rgb(1, 69, 18);"> <div> <div> <font color="#ffffff" size="6" > <b>this is&nbsp;</b> </font> <b style="color: rgb(255, 255, 255); font-size: xx-large;">a test&nbsp;</b> </div> </div> <div> <div> <b style="color: rgb(255, 255, 255); font-size: xx-large;">demo&nbsp;</b> </div> </div...

How to scan a string line, then scan inside that line without creating a nested loop? Java -

i want write code scan each line of file, takes each line , scan each next token on (by specified delimiter), compare token input, if there no match moves next line..etc. but, couldn't think of other way doesn't involves making nested loop! there other way, or better approach? try { scanner scan = new scanner(clock_time); while (scan.hasnext()) { //scan next line //scan specified tokens each line //if no match repeat, otherwise break } } use inner loop, that's tool (for life of me, don't know why you're worried using it). sure conserve resources closing inner scanner when you're done after end of inner loop, , same outer scanner. scanner filescanner = new scanner(somefile); while (filescanner.hasnextline()) { string line = filescanner.nextline(); scanner innerscanner = new scanner(line); while (innerscanner.hasnext()) { // whatever } innerscanner.close(); } filescanner.close();

regex - PHP - How do I convert string number to number -

i have string this $str = "one 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 nine"; with php language pattern can convert string: $str = "1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9"; for php can this: $string = "one 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 nine"; $replace = array(0,1,2,3,4,5,6,7,8,9); $search = array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'); echo str_ireplace($search, $replace, $string); as fred -ii- pointed in comment str_ireplace trick insensitive replacement.

javascript - How to split a string by a character not directly preceded by a character of the same type? -

let's have string: "we.need..to...split.asap" . split string delimiter . , wish split first . , include recurring . s in succeeding token. expected output: ["we", "need", ".to", "..split", "asap"] in other languages, know possible look-behind /(?<!\.)\./ javascript unfortunately not support such feature. i curious see answers question. perhaps there clever use of look-aheads presently evades me? i considering reversing string, re-reversing tokens, seems work after... plus controversy: how reverse string in place in javascript? thanks help! here's variation of the answer guest271314 handles more 2 consecutive delimiters: var text = "we.need.to...split.asap"; var re = /(\.*[^.]+)\./; var items = text.split(re).filter(function(val) { return val.length > 0; }); it uses detail if split expression includes capture group, captured items included in returned array. these captu...

webjars - How to use RequireJS optimizer in Play framework? -

Image
as advertised, rjs in play can ensure javascript resources referenced within webjar automatically referenced jsdelivr cdn. in addition if .min.js file found used in place of .js. added bonus here there no change required html! however, cannot seem of work. i tried running play app in production mode, , webjar javascripts still being referenced local. i not see .min version of javascript files being used in production. i cannot dependency injection work in production mode. example, when want inject jquery in code this define(['jquery'], function ($) { 'use strict'; console.log($.grep); return { sum: function (a, b) { return + b; } }; }); i can work fine in dev mode, in production mode, rjs failed saying [info] error: enoent, no such file or directory '/users/khanguyen/desktop/rjsdemo/target/web/rjs/build/js/jquery.js' [info] in module tree: [info] main [info] app [info] [info...

Does django (python) reuse object? -

suppose have model field field1 class myclass(models.model): field1 = models.charfield(max_length=100) somewhere have code like my_object = myclass() my_object.field1 = 'a' my_object.another_field = 'b' # (it's not defined in model class) is there chance another_object = myclass() have another_field set ? no, another_field unique instance assigned to. particular python, irrespective of django. try in python console: >>> class myclass(): >>> field1 = "field 1" >>> x = myclass() >>> x.another_field = "another field!" >>> x.field1 'field 1' >>> x.another_field 'another field!' >>> y = myclass() >>> y.field1 'field 1' >>> y.another_field traceback (most recent call last): file "<stdin>", line 1, in <module> attributeerror: myclass instance has no attribute 'another_field' if want add ...

python - Using Django with an existing database id field trouble -

i'm using django existing database. used inspectdb create models of existing database. works except 1 important detail. seems though django assumes there id field. example, when delete field called date run migration, date deleted table. however, when try delete id field, says -alter field id on table_name if there no id field in actual database table. so, if want make , use id field in existing database have manually specify in model , database or there better way? by default django creates id field models if don't specify it, so, in case, if delete autogenerated: id = models.integerfield(primary_key=true) django models assume 1 exists, message see. because need have 1 primary key field. so, yes, have specify primary key adding primary_key=true attribute appropriate field on model generated inspectdb , or django assume primary key column id . keep in mind that, if decide add id column table, shouldn't set explicitly in model : each gene...

python - Does PyCharm Have Spyder's Variable Explorer Functions (mainly "Save As" and "Import")? -

i started playing around pycharm today, , seems python ide want start working in near future. currently, using spyder anaconda. spyder able export , import variables variable explorer window. this means can debug part of script, save results, , import variables spyder @ time. can use such variables without having declare in script spyder assume exists variable explorer window. this feature extremely useful me, , cannot tell if pycharm has feature. i searched many places, , not find anything. does know how feature work in pycharm if exists? thanks. pycharm added functionality similar spyder's variable explorer months ago, can seen in this blog post . however, far know, doesn't have ability import/export variables present in python console.

HTML image height (in %) does not change? -

example: http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_img_height can change width in terms of % or px but, can change height in terms of px , not % (you can experiment changing height % , seeing not change). example wondering how change height in terms of %? thank you. if want use percentage height in div , parent objects of have have explicit height property. unlike width , website fixed heights bring problems. my advice: don't use percentage height in html. instead, try padding #mydiv{ padding-bottom: 20%; } see here more info.

javascript - Change label's name using image button is not working -

this code supposed change name of label when click image button. this not happening. 1 thing observed when closely is: when button clicked, label changes changes original value immediately. when use normal button change working. <html> <body> <script type="text/javascript"> function change(n) { var e=document.getelementbyid("name"); e.innerhtml='jnbjkvnkx'; } </script> <form> <label for="name" style="width: 300px; padding-left: 5cm" id="name">hemanth</label> <input type="image" src="page31.png" onclick="change('name')"> </form> </body> </html> the label value doesn't changed because once click on button, page refreshes new page x , y coordinates image type. there several w...

Can't open an existing file in Sdcard in Android Studio -

i have code in project read audio file : mainactivity2: private string getfilename() { string filepath = environment.getexternalstoragedirectory().getpath(); file file = new file(filepath, audio_recorder_folder); if (!file.exists()) { file.mkdirs(); } return (file.getabsolutepath() + "/" + system.currenttimemillis() + file_exts[currentformat]); } private void startrecording() { recorder = new mediarecorder(); recorder.setaudiosource(mediarecorder.audiosource.mic); recorder.setoutputformat(output_formats[currentformat]); recorder.setaudioencoder(mediarecorder.audioencoder.amr_nb); recorder.setoutputfile(getfilename()); log.i("tag", getfilename()); listeaudio.put(indice,getfilename()); // here listeaudio path=getfilename(); recorder.setonerrorlistener(errorlistener); recorder.setoninfolistener(infolistener); try { recorder.prepare(); recorder.start(); } catch (illegal...

c# - case statement for logical operators -

i getting "cannot implicitly convert string char" error. trying following code, how should specify cast in case statement <= operator. help/direction appreciated. thanks! char test1; switch(test1) { case '+': //do break; case '-' : case '*' : case '<=' : //method1 break method 1: private void method1(char test2) { if(test2 == '+' || test2 == '*' || test2.tostring() == "<=") { token.add(test2.tostring()); } } ok, have method1 this: private void method1(char test2) { if(test2 == '+' || test2 == '-' || test2 == '/' || test2 == '*') { //code tokens.add(test2); } char test1; switch(test1) { case '+': case '-' : case '*': case '/': method1(test1); break; i trying tok...

apache - .htaccess URL Rewrite not working -

i've never been @ .htaccess, i'm trying copy , paste code worked on 1 of domains , modify work here. have several rewritten urls, static, dynamic, can't simplest of them work. 1 testable here: http://lindseymotors.com/home clearly, index.php available because if access http://lindseymotors.com works. rewriteengine on rewritecond %{http_host} ^.* [nc] rewriterule ^home$ index.php rewriterule ^home/$ index.php # when answering, if write statement combine # both of statements above 1 appreciated. as said, these same conditions worked on 1 domains because copied code right over. asked server admin double check on end , fine. ideas? only thing can think of make sure use of .htaccess on. easiest way can check since server admin says it's fine put random text @ top of .htaccess file. if .htaccess file being read , .htaccess files enabled, should throw 500 internal server error . if not, don't have .htaccess files enabled , need add allowoverride all a...

c# - Entity Framework: SaveOptions.AcceptAllChangesAfterSave vs SaveOptions.DetectChangesBeforeSave -

what difference between saveoptions.acceptallchangesaftersave , saveoptions.detectchangesbeforesave in entity framework? when use saveoptions.none ? these options provided in objectcontext.savechanges(saveoptions options) . can of these option, in way, used reverse changes made objectcontext.savechanges() ? they're 2 entirely different things. note how saveoptions has flags attribute: indicates can combine multiple flags, in case make saveoptions.acceptallchangesaftersave | saveoptions.detectchangesbeforesave . and if you're wondering saveoptions.none | saveoptions.acceptallchangesaftersave , keep in mind saveoptions.none 0 value, long-winded way of writing saveoptions.acceptallchangesaftersave . so use saveoptions.none when want neither saveoptions.acceptallchangesaftersave nor saveoptions.detectchangesbeforesave . can of these option, in way, used reverse changes made objectcontext.savechanges() ? in context? if don't include saveoptio...

html - How can i make an element from a bottom stacking context stays in front of another higher stacking context? -

Image
this question has answer here: override css z-index stacking context 1 answer how can make element contained in stacking context @ bottom of stacking order appears in front of element in different stacking context higher in stacking order ? e.g: html: <div class="parent-1"></div> <div class="parent-2"> <div class="pepe"></div> <div class="pepin"></div> </div> css: .parent-1{ position: absolute; z-index: 10; background-color: green; } .parent-2 { position: absolute; z-index: 5; background-color: red; } .pepe, .pepin{ background-color: blue; } .pepin{ position: fixed; z-index: 100; } this have (this it's suppose happen): this want: bare in mind can't change elemnts order in html neither remove z-index ...

Disallow NULL parameters to stored procedures in MySQL/MariaDB -

i can specify table columns not null, how make stored procedure or function compatible non-null arguments? adding not null after argument name doesn't work. you need validate passed parameter values yourself. if you're using mysql 5.5 , can make use of signal . delimiter // create procedure my_procedure (in param1 int) begin if param1 null signal sqlstate '45000' set message_text = 'null not allowed.'; end if; -- whatever end// delimiter ; here sqlfiddle demo

mobile - Android studio doesn't let me use design mode -

i downloaded android studio , can't access design view. error: org.jetbrains.android.uipreview.renderingexception: version of rendering library more recent version of android studio. please update android studio @ org.jetbrains.android.uipreview.layoutlibraryloader.load(layoutlibraryloader.java:90) @ org.jetbrains.android.sdk.androidtargetdata.getlayoutlibrary(androidtargetdata.java:159) @ com.android.tools.idea.rendering.renderservice.createtask(renderservice.java:164) @ com.intellij.android.designer.designsurface.androiddesignereditorpanel$6.run(androiddesignereditorpanel.java:475) @ com.intellij.util.ui.update.mergingupdatequeue.execute(mergingupdatequeue.java:320) @ com.intellij.util.ui.update.mergingupdatequeue.execute(mergingupdatequeue.java:310) @ com.intellij.util.ui.update.mergingupdatequeue$2.run(mergingupdatequeue.java:254) @ com.intellij.util.ui.update.mergingupdatequeue.flush(mergingupdatequeue.java:269) @ com.intellij.util.ui.update.mergingupdatequeue.flush(merg...

Matlab @fminunc objective function optimization -

i practicing simple function optimization in matlab , hope provide little assistance / explanation on following error: %quadramin.m function z=quadramin(param,data); z=data.*(param(1).^2 - param(2).^3)+3; %quadramin_lik.m function quadlik = quadramin_lik(param,data); %pseudo/ad-hoc log-likelihood function quadlik = quadramin(param,data)- 10; %script.m data=trnd(5,6,1); param0=[2,3]; [param_eq,exitflag,output,grad,hessian] = ... fminunc(@(param) quadramin_lik(param,data),param0) output after executing %script.m: error using fminunc (line 333) user supplied objective function must return scalar value. ps: looks paradoxical user-defined functions quadramin && quadramin_lik return values. thanks both functions return vector of values whereas fminunc requires function returns scalar / single value. error pretty clear. function fminunc trying find best solution minimizes cost function, need supply cost function. therefore, perhaps try summing results in ...

plone - Registering additional validators on PloneFormGen -

i'm trying register new validator available list of validators can select in ploneformgen field. the task seems simple @ beginning: registered new archetypes validator , found way add dropdown list (through monkey-patch add new item stringvalidators tuple) , call initstringvalidators method of pfg tool. still, selecting new validator not lead anything: __call__ method never called. what i'm missing?

python - A simple Script to extracting a zip file -

good evening all, i think i'm not understanding zipfile structure heres code import xbmc import zipfile targetzip = xbmc.translatepath('special://home/userdata/addon_data/plugin.program.tester/test.zip') extractto = xbmc.translatepath('special://home/userdata/addon_data/plugin.program.tester/') zip = zipfile(targetzip) zip.extractall(extractto) any ideas why not working? try way import zipfile fh = open(targetzip, 'rb') z = zipfile.zipfile(fh) name in z.namelist(): z.extract(name, extractto) fh.close()

Mysql Query works only with Alias -

i wondering why query works: delete `temp` `tagged` `temp` inner join `tags` on (`tags`.`id` = `temp`.`tag_id` , `temp`.`user_id` = '1' , `tags`.`name` = 'tag1') or (`tags`.`id` = `temp`.`tag_id` , `temp`.`user_id` = '1' , `tags`.`name` = 'tag2'); and query, difference being not having temp alias tagged table. delete `tagged` inner join `tags` on (`tags`.`id` = `tagged`.`tag_id` , `tagged`.`user_id` = '1' , `tags`.`name` = 'tag1') or (`tags`.`id` = `tagged`.`tag_id` , `tagged`.`user_id` = '1' , `tags`.`name` = 'tag2'); the second query produces syntax error. additionally, please re-write query work , doesn't need alias. syntax error: syntax error or access violation: 1064 have error in sql syntax; check manual corresponds mysql server version right syntax use near 'inner join tags on ( tags . id = tagged . tag_id , tagged . user_id = '' @ line 1 (sql: delete tagged inner join tags ...

php - extracting an element of an array -

this question has answer here: get index of element in array value 5 answers assume array: array ( [0] => array ( [id] => 1171 [product_id] => 140 [fileid] => 479717 [purchid] => 847 [cartid] => 833 [uniqueid] => f100c3b3a853202fb6559fbacf025a6aa07f52c7 [downloads] => 99998 [ip_number] => [active] => 1 [datetime] => 2015-06-02 20:10:05 ) [1] => array ( [id] => 1172 [product_id] => 140 [fileid] => 313624 [purchid] => 847 [cartid] => 833 [uniqueid] => f00a3c91378ad469f333abeec64753b275f10670 [downloads] => 99999 [ip_number] => [active] => 1 [datetime] => 2015-06-02 20:10:05 ) [2] => array ( [id] => 1173 [product_id] => 140 [fileid] => 313618 [purchid] => 847 [cartid] => 833 [uniqueid] => ac125595e2dbca6a086261434582f6e7dfc5638e [downloads] => 99999 [ip_number] => [act...

javascript - ExtJS Tree panel not show elements correctly -

Image
i'm creating tree panel data json file, when expand categorie shows elements correctly if expand categorie elements opened desappier, happens elements in expand , contract event. here pictures of behaviour fist expand event: second expand event: third expand event: here code i'm using: the model: ext.define('app.model.modelocapa', { extend: 'ext.data.model', fields: ['nombre','url'], proxy: { type: 'ajax', url: "data/jsonprovisional.json", reader: { type : 'json', root : 'result', } }}); the store: ext.define('app.store.capa', { extend: 'ext.data.treestore', requires: 'app.model.modelocapa', model: 'app.model.modelocapa'}); the view: initcomponent: function() { var anchopanatallares = window.screen.width; var altopantallares = window.screen.height; var anchotoc = 330; var altotoc = 473; ...

Haskell home-made monad transformer unable to Show itself in GHCi -

i dabbing simple monad transformers presented in http://www.cs.nott.ac.uk/~nhn/mgs2006/lecturenotes/lecture03-9up.pdf my error-handling transformer has type newtype et m = et (m (maybe a)) i have implemented necessary plumbing , able couple identity monad (which in little sandbox called i ) , write/compile non trivial functions. but unable print resulting value onscreen. message is: no instance (show (et value)) arising use of ‘print’ maybe imported. both i , value derive show , display on own without problems. mix et won't show. see 2 ways: try insert deriving show in declaration of et m a (which tried in many ways obtaining lot of different error messages) create showable instance dabbing "stand-alone deriving declarations", suggested web resources - tried no success far. how can show et value in repl? one of purposes of standalone deriving compiler cannot infer required constraint make instance, though actual code still derived ...

javascript - How do i get Option Selected Data tag -

i can text , value want tag this.options[this.selectedindex].value <---will value this.options[this.selectedindex].text <---will text i want data_id option <option value="l w12 6.3 quattro" data-id="200480476">l w12 6.3 quattro</option> i have tried: this.options[this.selectedindex].data-id and didn't work i sorry add more info... using on nested forms in ruby on rails , have on change event set it: <select id="shipment_vehicles_attributes_0_style" name="shipment[vehicles_attributes][0][style]" onchange="getstylesid(this.id,this.options[this.selectedindex].data-id)"><option value="">select style</option><option value="base" data-id="9058">base</option></select> can use jquery in there your tags suggest using jquery. can this: var attr = $('option:selected').attr( "data-id" );

email - Problems with send mail using php -

somebody can me? need send email using php. i using code send mail <?php error_reporting(e_all); ini_set('display_errors', '1'); require '/phpmailer-master/phpmailerautoload.php'; error_reporting(e_all); ini_set('display_errors', '1'); echo (extension_loaded('openssl')?'ssl loaded':'ssl not loaded')."\n"; $mail = new phpmailer; $mail->smtpdebug = 2; // enable verbose debug output $mail->issmtp(); // set mailer use smtp $mail->host = 'smtp.gmail.com'; // specify main , backup smtp servers $mail->smtpauth = true; $mail->smtpdebug = true; // enable smtp authentication $mail->username = 'email@gmail.com'; // smtp username $mail->password = '******'; // smtp password $mail->smtpsecure = 'tls'; ...

computer architecture - Tomasulo's algorithm + MIPS 5 stages pipeline + branch prediction -

i'm learning tomasulo's algorithm , think understand it. can't figure out how integrated mips 5 stage pipeline discussed in hennessy , patterson? how 1 integrate branch prediction tomasulo? appreciated. tomasulo's keeps track of dynamic scheduling of instructions comes in play when after decode have multiple ports execute different instructions hardware resources instructions wait, schedule, forward result. mips 5 stage in-order pipeline can not issue/dispatch multiple instructions in same cycle nor can go out of order in pipeline. when see branch in front end of pipeline have make decision fetch next instruction, branch target or pc++. branch resolution takes time, , if wait, 3 or 20 cycles depending on processor, end inserting many bubbles. branch prediction (bp) start fetching somewhere confidence. the link between bp , tomasulo's can bridged reorder buffer, register files capable of handling misprediction recovery. there many other things need s...

mysql - SQL Self-Join Query in a complicated case -

i working on data sum up. different prices different periods. on database looks itemid | time start | price | time end 01 | 2012-01-01 | $10 | null 01 | 2013-01-01 | $20 | 2013-06-01 01 | 2014-01-01 | $30 | null and tricky part task askw me output form like itemid | time start | time end | price 01 | 2012-01-01 | 2013-01-01 | $10 01 | 2013-01-01 | 2013-06-01 | $20 01 | 2013-06-01 | 2014-01-01 | $10 01 | 2014-01-01 | null | $30 i think should done statement using sql self join far don't have idea this. especially have no idea how generate 'row 3' , 'row 4' 01 | 2013-06-01 | 2014-01-01 | $10 problem descriptions: each price related specific time slot. , there cases like: case 1: if time slot has start time , end time, show it.(simple) case 2 : if end time null, fill end time next start time. case 3: (difficult one), row's start time comes the end time others row,it has match last time slot'...

sql - Rolling up multiple rows into single row using 2 tables -

is there way change sql query return multiple rows same values single row comma separated? table1 ------ col1 ------ sci-fi action crime table2 ------------ col1 | col2 ------------ 1 | action 1 | sci-fi 2 | crime 2 | action 2 | sci-fi and need query results this: (table1 , table2 combined) ---------------------------- col1 | col2 ---------------------------- 1 | action, sci-fi 2 | crime, action, sci-fi select mg.movie_id , stuff(( select ',' + g.genre_name movie_genre g g.movie_id = mg.movie_id order g.genre_name xml path('') ), 1, 1, '') genres movie_genre mg group mg.movie_id credit this post crazy awesome stuff expression.

JavaScript - Separating the multi-value result of a field with commas -

i have field returns multiple values following way (in multiple rows): field role1 role2 role3 i want separate resultset commas. end result should role1, role2, role3 how achieve this? have tried split, string.replace(" ", ",") whitespace comma, nothing works. thanks, you can split on newline , join on comma: str.split('\n').join(',');

c++ - Passing the Number of Elements in an Array to Function? -

i writing dll passes char array function. define char array 22 elements here: unsigned char data[22] = { 0x00, 0x0a, 0x00, 0x09, 0x70, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x74, 0x00, 0x68, 0x00, 0x65, 0x00, 0x67, 0x00, 0x75, 0x00, 0x79, 0x00 }; now, try pass array function declared as: bool senddata(unsigned char* sdata, unsigned long ssize); with these arguments: senddata(data, 22); this code compiles, crashes program when function called. taking closer while debugging, can see there's access violation in function senddata . looking further, see values of data , sdata @ run-time: data points 22 byte char array correct values (obviously) sdata points char array null-terminated first byte, containing 1 value (0) it clear me compiler not know allocate 22 bytes sdata , because not specify length it. question is: how specify length of sdata argument passed won't terminate early? if i'm wrong issue, please correct me , explain further. in adv...

Android - Allow text highlighting without triggering CAB -

i'm trying figure out how allow text highlighting inside edittext, without triggering contextual action bar. i've seen it's possible set custom actionmode.callback that's stops cab showing, can tell stops text highlighting well. it's possible it's done in current google docs app, show custom popup when text highlighted instead of cab.

xslt - any restriction with the length of Metadata name? -

i new forum. need parse/read xml cotains lots of metadata(as below). have 2 read specific meta value based on bu value, example if bu value '987654321abcdefghijklmnopaslasjdoiwneois123abc' have value "d581452fa9ba3110vgnvcm10000038ccc5abrcrd|def". question, there restriction metadata name length? reason xslt logic not reading value(select="mt[@n=$partialval]/@v"). xslt snippet: <xsl:for-each select='./mt[@n="bu"]'> <xsl:variable name="temp_bu" select="./@v"/> <xsl:variable name="partialval" select="'987654321abcdefghijklmnopaslasjdoiwneois123abc'"/> <xsl:if test="contains($partialval, $temp_bu)"> <xsl:variable name="partialbuval" select="mt[@n=$partialval]/@v"/> <xsl:value-of disable-output-escaping='yes' select="concat('file://',$partialbuval,'test',$partialval)"/> ...

javascript - Rails AJAX live search using helper method -

i trying replicate spotify search in updates search results on every key press. works on submit on key press , i'm getting bad request error in console. how can page update on key press? little background info: i'm using rspotify gem in helper method called on search entry. static_controller.rb: class staticcontroller < applicationcontroller include applicationhelper def home end def search @search = user_search(params[:query]) render :home end end application_helper.rb: module applicationhelper def artist_search(query) artists = rspotify::artist.search(query) return artists end def track_search(query) tracks = rspotify::track.search(query) return tracks end def album_search(query) albums = rspotify::album.search(query) return albums end def user_search(query) results = {"artist" => artist_search(query), "tracks" => track_search(query), "album" => album_search(query)} return result...

Cordova Android Build Failure -

i trying basic cordova v5.0 android v4.0 project build on mac os x yosemite, keep getting error. note: same process builds fine on cordova v4. have uninstalled , reinstalled android sdk, cordova, , gradle (but don't think need it). i've checked path variable contains correct paths /tools , /platform_tools. when 'cordova build' or 'cordova build android' same error: could not create instance of type org.gradle.invocation.defaultgradle_decorated. further down says: you may not have required environment or os build project what missing? here's full text of i'm doing: my_acct$cordova create build_test com.example.build_test "buildtest" creating new cordova project. my_acct$cd build_test my_acct$cordova platform add android adding android project... creating cordova project android platform: path: platforms/android package: com.example.build_test name: buildtest activity: mainactivity android target:...

grails - Amazon Redshift: query execution hangs -

i use amazon redshift , query execution hangs without error messages e.g. query execute: select extract(year date), extract(week date),count(*) some_table date>'2015-01-01 00:00:00' , date<'2015-12-31 23:59:59' group extract(year date), extract(week date) and not: select extract(year date), extract(week date),count(*) some_table date>'2014-01-01 00:00:00' , date<'2014-12-27 23:59:59' group extract(year date), extract(week date) but happens when deploy project server , on local machine queries executed without problems. i set in code autocommit=true connection. things listed above grails using library compile 'com.amazonaws:aws-java-sdk-redshift:1.9.39' any ideas? this might not exact answer, it's long comment. you may want check mtu setting on server performing execution. redshift want's operate on 1500 bytes frame , ec2 instances set jumbo frame default ( 9000 ) in order run queri...

unity3d - Load 3D Model in Unity using Assimp -

is possible load 3d model in unity using assimp? when search code samples assimp, find c++ samples using virtual studio. can load 3d models assimpnet version 3.0 ( c# wrapper) c# code, goal use assimp64.dll , not assimpnet.dll. thanks :)

javascript - Selector returns undefined -

html <form method="post"> {% csrf_token %} <tr id = "{{ x.id }}"> <td>{{ x.name }}</td> <td>{{ x.sth }}</td> <td>{{ x.sth_else }}</td> <td><button type="submit" name="edit_btn">edit</button></td> </tr> </form> jquery $('form').on('submit', function(event){ event.preventdefault(); console.log("executing script edit button pressing") x = $(this).children().first().attr('id'); console.log(x) }); i'm trying extract id tr in html, whenever on page , see console output get: undefined. ideas?

ruby on rails - `allow_any_instance_of` mock not working in scope -

my mock working when it's in before block shown below. quick , dirty representation of problem. literally when move line before block does not quack assertion, stops mocking :( describe 'ducks', type: :feature before ... allow_any_instance_of(duck).to receive(:quack).and_return('bark!') visit animal_farm_path end context 'is odd duck' 'does not quack' expect(duck.new.quack).to eq('bark!') end end end i want here, doesn't work: describe 'ducks', type: :feature before ... visit animal_farm_path end context 'is odd duck' 'does not quack' allow_any_instance_of(duck).to receive(:quack).and_return('bark!') expect(duck.new.quack).to eq('bark!') end end end my bad. original question poorly written. visiting page makes #quack call. mocks must done before whatever engages method call. solution describe 'duc...

c++ - When to delete the windows security attributes after creating a event/mutex -

i creating mutex using security attributes, question when should delete security_attributes structure. should delete after creating mutex, or should wait untill mutex handle closed. approach 1. create security attributes createmutex using above security attributes task.... close mutex release security attributes approach 2. create security attributes createmutex using above security attributes release security attributes task.... close mutex which 1 best way do??

Watir Rspec Ruby : Comparing new/edited value with old/previous value -

auto generated name twice, first $name = generate_name self.name = $name produces: $name "abc" and edited $name "xyz". causes previous/old name no longer available/saved in app, overwritten new/edited name. i have compare 2 values of same variable $name ensure name edited. using expect($name).to_not eq($old_name) i don't understand how save previous/old name variable $old_name before overwriting it? before change $name "xyz", or test equality, need set $old_name equal $name . something this: $name = generate_name self.name = $name $old_name = self.name $name = xyz self.name = $name using expect($name).to_not eq($old_name)

Bash check if grep matches string -

i writing bash script checks every 5 minutes if there ip address 100 or more invalid passwords (brute force attack) attempts. the following script works: blockips="$(cat /var/log/secure | grep "failed password for" | grep -v "invalid" | awk {'print $11'} | sort | uniq -c | awk -v limit=100 '$1 > limit{print $2}')" while read -r line; iptables -a input -s $line -p tcp --dport 22 -j drop echo "blocking ip address: $line" done <<< "$blockips" the problem script above after hour have duplicate entries in iptables . tried extend script check if ip address blocked, if so, should skip it. this script: blockips="$(cat /var/log/secure | grep "failed password for" | grep -v "invalid" | awk {'print $11'} | sort | uniq -c | awk -v limit=100 '$1 > limit{print $2}')" currentips="$(iptables-save)" while read -r line; if grep -q $line $currentips ...

javascript - Expand multiple div on click and revert via close button -

i looked several questions of similar nature haven't found i'm looking for. have 6 divs on page ( js fiddle here ) , got them expand on click, after trying several snippets no closer getting close button work when started. pointers on how close expanded divs using close button! markup: $('#div6, #div5, #div4, #div3, #div2, #div1').click( function() { $(this).animate({ 'width': '100%', 'height': '100%' }, 600).siblings().animate({ 'width': '0', 'height': '0' }, 600); $('<button class="show">xclose</button>') .appendto('.wrapper'); }); $('.show').click(function() { $(this).animate({ 'width': '0', 'height': '0' }, 600).siblings().animate({ 'width': '50%...

c# - How do I add project references to a wix project programmatically? -

i attempting add references wix project after has been created programmatically. in implementation of microsoft.visualstudio.templatewizard.iwizard . know how envdte.project 's: // add project reference projecta projectb. // allows projecta use classes projectb. var temp = (vsproject2)projecta.object; temp.references.addproject(projectb); but can't figure out how oawixproject . appreciated. thank you! edit: should mention problems arise when attempt cast (vsproject2)projecta.object when projecta oawixproject . not sure how you'd use wix sdk dlls edit wixproj file, resort editing wixproj xml programatically. looks you'd add itemgroup element root project element. xml you'd need inject like: <itemgroup> <projectreference include="..\mysolution\customassembly.csproj"> <name>customassembly</name> <project>{233e4372-895b-4c8d-99b0-f8314d907d66}</project> <private>true...

java - Using Strings from resources in List. -

i'm new android , i'm having problem using string variables resources in code. tried couple of solutions found on internet , android api guides, didn't work in specific case, me not using them correctly. to more specific, have master/detail flow activity , use resource strings item names multilanguage purposes, have problem recovering actual strings. error is: cannot resolve method 'getstring()' here code based on android studio dummy file public class categories { public static list<catname> items = new arraylist<catname>(); static { string temp = getstring(r.string.cat_n1); additem(new catname("1", temp); } private static void additem(catname item) { items.add(item); } public static class catname { public string id; public string name; public fieldcat(string id, string name) { this.id = id; this.name = name; } @override public string tostring() { return name; ...

jquery - Uploading multiple images with AJAX empty php response -

i'm trying upload multiple images via post ajax method, if upload more 2 pictures, empty array response php, 1 or 2, , 3 images, successful response! data passed php times, response mystery ! my ajax var id=data; var file_data=$('#images').prop('files'); var formdata = new formdata(); for(var x in file_data){ formdata.append("image["+x+"]", file_data[x]); } formdata.append("id", id); $.ajax({ url: "ajax/ajax_add_car.php?veids=2", enctype: "multipart/form-data", method: "post", data: formdata, cache:false, processdata: false, ...

r - Save View() output of RStudio as html -

is possible save page see when use view() command in rstudio on data html file? maybe data looks mtcars data data(mtcars) view(mtcars) library(xtable) sink command sends output file sink('somehtmlfile.html') print(xtable(mtcars),type='html') then return things normal with sink() now open somehtmlfile.html in browser

u2 - Is it possible to audit dictionary changes on UniVerse? -

a while ago, international spectrum posted a great article outlined process of auditing changes in file through use of indexing subroutine. works record changes , have been thinking useful if track changes dictionaries in file. has found way this? the record changes work special dictionary in file indexed: create.index myfile audit.records no.nulls for dictionary auditing work, necessary index dictionary itself, don't think can do. there way add voc or other strategy entirely? >create.index file name: dict myfile index name(s): audit.dict cannot find field name audit.dict in file dictionary or voc, no index created. > my goal write dictionary changes flat files windows-friendly backups , possible integration version control. i'm curious hear if has ideas. thanks! (we're running universe version 11.2.4 on windows server 2008 r2 , still default pick flavor on our main accounts.) you can make voc pointer dictionary this: f d_myfile dict.di...

java - Multiple runs of same jar file has an affect to each other? -

i have 1 jar on linux machine. jar runs alone have start same jar different args. means 2 instances of application running @ same time. application hits db , has actions on file system creating files , folders. problem is, if both jars running, creating of files , folders on file system have effect on each other. means, folders saved on wrong place , on. if both instances of application have complete different folder structure. so more problem regarding jvm or more programmatic problem? the call start of jars java -jar app.jar as 2 instances of same jar run in isolated jvms, execution of 1 jar doesn't impact another. far filesystem concerned, cannot write same location 2 processes @ same time.

alignment - ANDROID: Align dynamically created number pickers -

i creating alert dialog 2 number pickers , 2 textviews on top of each 1 select month , year, , textviews labels. creating them dynamically because seems easier fill min , max options (couldn't xml , layout inflator). can't make 2 pickers (and labels) centralized on alert dialog box. show on extreme left , extreme right, making ugly. on coding here is: final numberpicker np1= new numberpicker(this); final numberpicker np2= new numberpicker(this); final textview t1=new textview(this); final textview t2=new textview(this); t1.settext("month"); t1.settextsize(20); t2.settext("year"); t2.settextsize(20); np1.setmaxvalue(12); np1.setminvalue(1); np2.setmaxvalue(2030); np2.setminvalue(2000); np1.setvalue(month); np2.setvalue(year); relativelayout linearlayout = new relativelayout(this); relativelayout.layoutparams params = new relativelayout.layoutparams(20,20); relativ...

python - Send data from Arduino to a Web Server through Ethenet shield -

i have arduino ethernet shield, connected same hub computer. tried let arduino send http request web server written in python. i fixed ip computer @ 192.168.1.2 , arduino ip automatically through a dhcp server or if fails new ip, static ip. web server part: tested web server , worked whenever called request, save me record database(i using mongodb database) arduino part: tested , saw connect dhcp server, not web server sent request , response dhcp server. how config dhcp server can transfer arduino's request directly web server? or other solution let arduino send data directly web server? small code of web server: #!/usr/bin/env python2.7 # -*- coding: utf-8 -*- bottle import * pymongo import * import datetime @route('/hello') def hello(): return "hello world!" @get('/receiver', method = 'get') def receiver(): # data http request , save db print 'inserting data' receiver_id = request.query.getall(...