Posts

Showing posts from May, 2014

rest - Python Flask persistent object between requests -

i creating web interface omxplayer on raspberry pi. i'm trying create more rest api controlling video while playing. issue i'm having how control video while playing. currently can create player object methods available start , stop video. @main.route("/video", methods=["get", "post"]) @login_required def video(): form = videoform() if form.validate_on_submit(): url = form.url.data vid_output = form.vid_output.data player = player(url=url, output=vid_output) player.toggle_pause() return redirect('/video') return render_template("video.html", form=form) now want have url can run player.toggle_pause() method again. @main.route("/video/stop", methods=["get", "post"]) @login_required def video_stop(): player.toggle_pause() my problem cannot find way have object persist between 2 requests. video start playing after sending first re...

php - How to get rid of synchronous XHTML request? -

how rewrite code can use json data retrieved test2.php ? function drawchart4() { var jsondata = $.ajax({ url: "/master/test2.php?zoekopdracht=ceremonie", datatype: "json", async: false }).responsetext; var object = $.parsejson(jsondata); your question not clear, maybe looking for: $.ajax({ url: "/master/test2.php?zoekopdracht=ceremonie", datatype: "json" }).done(function(jsondata){ // data console.log(jsondata); }).fail(function(){ // react on error console.log("whoops, failed!"); }); this assumes using jquery js library on client side, code implies.

ios - Xcode: Issue adding localization to my project (Resource file / Reference language not found) -

Image
i'm trying add spanish version app. i'm following several tutorials , me point: screenshot http://www.raywenderlich.com/64401/internationalization-tutorial-for-ios-2014 but when try doing same thing step step in existing project, don't see files choose from: what have can create/see files? you need have marked files localizable first. select file (e. g. storyboard) , click localize button. then, have files listed when adding languages.

build - Adding the uri.js bower component breaks my Grunfile.js, which dies thinking the uri.js directory is a file. How to fix? -

the yeoman generated gruntfile.js dies during grunt build with: running "rev:dist" (rev) task dist/public/app/app.js >> b90d2f58.app.js dist/public/app/vendor.js >> 2deb5480.vendor.js warning: unable read "dist/public/bower_components/uri.js" file (error code: eisdir). used --force, continuing. clearly interpreting uri.js component directory file! 1 simple fix rename uri.js component uri_js or similar. rather that, there easy switch add utility hashing know 'uri.js' not file??? tried adding "filter: 'isfile'" every place in gruntfile has *.js pattern, no avail. anyone has seen this, appreciated. doing grunt build --force. thanks i discovered 1 can exclude bower_component rename process. key order of files in rev piece dependent on order of selection. modified section of gruntfile.js ... , well. // renames files browser caching purposes rev: { dist: { files: { src: [ '<%= ye...

c++ - Using openmp with odeint and adaptative step sizes -

i trying use openmp parallelize code. works fine when use constant step sizes, when run same code using adaptative stepper errors don't understand. here essential parts of code : using namespace std; using namespace boost::numeric::odeint; const int jmax = 10; typedef double value_type; typedef boost::array<value_type ,2*(jmax+1) > state_type; //the step function void rhs( const state_type , state_type &dadt , const value_type t ) { value_type rhstemp0; value_type rhstemp1; //we write rhs of equations big sum #pragma omp parallel schedule(runtime) for(int j = 0; j < jmax+1 ; j++ ) //real part { rhstemp0 = value_type(0.0); rhstemp1 = value_type(0.0); (int k = 0; k< jmax+1 ;k++) { (int l = max(0,j+k-jmax); l < 1 + min(jmax,j+k);l++) { rhstemp0 = rhstemp0 + s[j*size_s*size_s + k*size_s + l]*(-a[k+jmax+1]*a[l]*a[j+k-l] + a[k]*a[l+jmax+1]*a[j+k-l] + a[k]*a...

ios - How to delete cell with parse data? -

i want delete cell parse server can tell should write under func commiteditingstyle ? override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let logcell:uitableviewcell = uitableviewcell(style: uitableviewcellstyle.subtitle, reuseidentifier: "default") let log:pfobject = self.logdata.objectatindex(indexpath.row) as! pfobject logcell.textlabel?.text = log.objectforkey("weight") as? string return logcell } override func tableview(tableview: uitableview, caneditrowatindexpath indexpath: nsindexpath) -> bool { return true } override func tableview(tableview: uitableview, commiteditingstyle editingstyle: uitableviewcelleditingstyle, forrowatindexpath indexpath: nsindexpath) { // delete object parse, remove list } } when wish delete object parse cloud, method deleteinbackground() should used. let log:pfobject = self.logdata.objectatindex(indexpath.row) as! p...

html - Bootstrap Carousel not working correctly -

this time it's carousel giving me trouble. should normal don't know why isn't working. saw in site, in here: http://parkhurstdesign.com/improved-carousels-twitter-bootstrap/ here's codeply link: http://www.codeply.com/go/ypbxy1hmc8 , here html/css code: <!-- wrap page content here --> <div id="wrap"> <!-- fixed navbar --> <div class="navbar navbar-default navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">sugoi!</a> ...

regex - Match a line not ending in digit (with possible trailing white spaces) -

i want match line doesn't end in digit (with possibly trailing white spaces. using emacs regex (and open use other regex flavors). what regexs accomplish that? can use possessive quantifiers. (suppose possessive quantifiers work in emacs regex) here 2 attempt of mine. [^[:digit:]] *^j where ^j new line character, typed c-q c-j , match concepts of logic 1 but [^[:digit:]] *$ doesn't match concepts of logic 1 i wonder why there difference? thanks. so want match either line not end in char (i.e., empty) or line ends in character not digit , not newline char? interactively, type regexp c-m-s , way: \(^$\|[^c-qc-j[:digit:]]\)$ where typing c-q c-j inserts newline char ( c-j ) interactively. looks in isearch, ^j single (newline) char: \(^$\|[^^j[:digit:]]\)$ from lisp, double backslashes , use \n represent newline char: \\(^$\\|[^\n[:digit:]]\\)$ if want allow trailing whitespace, add [ \t]* before $ . example, interatively: ...

sql - Using SUBSTR() AND INSTR() find end of string -

i have problem, select substring string. string after equal. example looks one. string='test = 1234sg654' my idea select string after equal "1234sg654", in way: instr() find position of equal, after substr(), subtract string after equal until end of string. equal=instr(string,'=',1,1); aux=substr(string,-1,equal); // -1 thought represent end of line but result not 1234sg654 mistake? don't use -1 position argument -- substring starts many characters end of string. can do: aux = substr(string, instr(string, '=') + 1) no third argument means "go end of string".

javascript - How to call reload after animation in JQuery -

i building news feed style page automatically scroll bottom, wait , refresh page , repeat process. the automatic reload not working @ moment, , starting bug me. any appreciated. the scrolling part works great my code <script language="javascript" type="text/javascript"> function scrolll() { time = $('.message').length*3000; $("html, body").animate({ scrolltop: 0 }, 0); $("html, body").animate({ scrolltop: $(document).height() }, time,0, function() {location.reload; }); ; } </script> you can use location.reload(); or window.location.href = window.location.href; but think problem time,0 $("html, body").animate({ scrolltop: $(document).height() }, time, function() {location.reload(); }); and if understood can use settimeout() $("html, body").animate({ scrolltop: $(document).height() }, 100, function() { settimeout(function() { ...

Retrieve associations in AngularJS & Rails using ngResource -

i have record & category model: class record < activerecord::base belongs_to :category end class category < activerecord::base has_many :records end the category model has name field should used display. using ng-repeat display records, ' record.category.name ' causes page break: <tr ng-repeat="record in records"> <td>{{record.category.name)}}</td> <td>{{record.description}}</td> <td>{{record.created_at | date:'medium'}}</td> </tr> how can retrieve ' record.category ' 'name' field available have above? using ngresource far has not populated associations. i retrieving record model using ngresource: var record = $resource('/records/:recordid', { recordid:'@id', format: 'json' }, { 'save': { method: 'put' ...

userscripts - Replace Text and Link Target on a page -

i want make userscript changes gmail link on google.com inbox one. <a class="gb_la" href="https://mail.google.com/mail/?tab=wm&amp;authuser=0" data-pid="23" data-ved="0cbeqwi4oaa">gmail</a> to: <a class="gb_la" href="https://inbox.google.com/" data-pid="23" data-ved="0cbeqwi4oaa">inbox</a> but know nothing javascript and/or userscripts. can me ? html: <a class="gb_la" href="https://mail.google.com/mail/?tab=wm&amp;authuser=0" data-pid="23" data-ved="0cbeqwi4oaa" id="link">gmail</a> javascript: link=document.getelementbyid("link"); link.src="https://inbox.google.com/"; link.innerhtml="inbox";

json - Running vert.x with java security manager -

when run vertx verticle without java.security.manager works fine. when try run same vertx verticle java.security.manager tells me "configuration file not contain valid json object". configuration file simple , works expectet file mod.json: { "main":"server.java" } file ./bin/vertex: jvm_opts="-djava.security.manager -djava.security.policy=my.policy" file ./my.policy: grant codebase "file:${java.home}/lib/-" { permission java.security.allpermission; }; grant codebase "file:${java.home}/jre/lib/ext/-" { permission java.security.allpermission; }; grant codebase "file:${java.home}/../lib/-" { permission java.security.allpermission; }; grant codebase "file:/home/internet//downloads/vert.x-2.1.5/lib/-" { permission java.util.propertypermission "user.dir", "read"; permission java.util.propertypermission "java.io.tmpdir", ...

Why such implementation of partial in clojure.core -

i stumbled across implementation of partial function in cojure.core . looks this: (defn partial "takes function f , fewer normal arguments f, , returns fn takes variable number of additional args. when called, returned function calls f args + additional args." {:added "1.0" :static true} ([f] f) ([f arg1] (fn [& args] (apply f arg1 args))) ([f arg1 arg2] (fn [& args] (apply f arg1 arg2 args))) ([f arg1 arg2 arg3] (fn [& args] (apply f arg1 arg2 arg3 args))) ([f arg1 arg2 arg3 & more] (fn [& args] (apply f arg1 arg2 arg3 (concat more args))))) why has several parity options if have one? performance optimisation concat doesn't called in cases? i mean otherwise, right? (defn partial ([f] f) ([f & more] (fn [& args] (apply f (concat more args)))) ) i noticed several other functions follow same pattern. yes, it's performance optimization. i'ts not not calling con...

sql - Query Split string into rows -

i have table looks this: id value 1 1,10 2 7,9 i want result this: id value 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 2 7 2 8 2 9 i'm after both range between 2 numbers , delimiter (there can 1 delimiter in value) , how split rows. splitting comma separated numbers small part of problem. parsing should done in application , range stored in separate columns. more 1 reason: storing numbers strings bad idea. storing 2 attributes in single column bad idea. and, actually, storing unsanitized user input in database bad idea. in case, 1 way generate list of numbers use recursive cte: with t ( select t.*, cast(left(value, charindex(',', value) - 1) int) first, cast(substring(value, charindex(',', value) + 1, 100) int) last table t ), cte ( select t.id, t.first value, t.last t union select cte.id, cte.value + 1, cte.last cte ...

ajax - Lambda fetching multiple records with contains query returns empty -

i have code: public jsonresult ekranbilgilistele(list<int> ids) { dbreklam db = new dbreklam(); //int[] ids = { 14, 16 }; ids comes db.configuration.proxycreationenabled = false; var secilenekranlar = db.tbl_ekranlar.where(ekranlar => ids.contains(ekranlar.sektorid)); return json(secilenekranlar); } and ajax call: $.ajax({ type: 'post', url: '@url.action("ekranbilgilistele")', datatype: 'json', data: { ids: arraysecilenekranlarid }, success: function (data) { console.log('---->' + data.ekranad); }, datatype: "json", traditional: true }); however, using breakpoints , results view returns 'empty' , console returns 'undefined' really sorry wrote wrong query! writing right one. public jsonresult ekranbilgilistele(list<int> ids) { //int[] ids = { 14, 16 }; ids comes db.configuration.proxycreationenab...

android - 403 error: Ajax post call in ionic app -

i have strange problem. app working fine in browser not able make ajax post request in android device. giving 403 error. i using django-rest backend apis. oauth2 authentication . set cors header in django , sending required access token in http header. headers: {'authorization': 'bearer '+ioniccookies.get('access_token')} can please tell missing?

html - Change Initial Scale With Css -

how can change initial scale value css? don't want use javascript. <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/> you can use @viewport . but, might not supported in browsers. https://developer.mozilla.org/en-us/docs/web/css/@viewport

android - How to wait for webview.post to complete? -

in below code, outside printed before inside . want order inside first , outside . how ensure runnable finished before second log reached? webview.post(new runnable() { @override public void run() { log.d("check", "inside"); } }); // code needed here log.d("check", "outside"); some code must inserted comment achieve this. edit: doing work in background service. [p.s.: curious why doing this, because unless add webview.post , keep getting following error: "all webview methods must called on same thread.". anyway, shouldn't affect answering question.] you might try using countdownlatch : final countdownlatch latch = new countdownlatch(1); webview.post(new runnable() { @override public void run() { log.d("check", "inside"); latch.countdown(); } }); // code needed here latch.await(); log.d("check", "outside"); howev...

angularjs - Creating bootstrap columns in angular ng-repeat making issue in width and alignment -

Image
i have directive create bootstrap columns dynamically . problem directive columns width not equal statically creating bootstrap columns. e.g <my-directive></my-directive> <div class="row"> <div style="background:green" class="col-md-4 col-sm-4"> </div> <div style="background:green" class="col-md-4 col-sm-4"> </div> <div style="background:green" class="col-md-4 col-sm-4"> </div> </div> mydirectiveview.html div class="row"> <div style="background:red" ng-repeat="tile in tiles" ng-init="colsspan=12/configinfo.tiles.length" class="col-sm-{{colsspan}} col-xs-12 col-md-{{colsspan}}> </div> </div> my problem width of directives div not equal when compare div created in static div not aligned can me in ?? want both directive div , div created in html file should i...

arrays - Find Missing Number in a Range- Javascript challenge -

can me started on challenge: given array of 99,999 unique numbers ranging 1 100,00 in random order, find 1 number missing list. i'm not sure how start thinking it. except missing number, describing arithmetic progression , has nifty formula calculate sum. loop on array, sum it, , subtract formula. difference missing element: function missing(arr) { var sum = 0; (var = 0, len = arr.length; < len; ++i) { sum += arr[i]; } var expected = 100000 * (1 + 100000) / 2; var missing = expected - sum; return missing; }

sql server - Calling stored procedure with OUTPUT parameter in dynamic SQL -

i calling stored procedure output parameter using dynamic sql. set @csql='exec '+@cname+'.dbo.uspndateget ''' +convert(varchar(10),@dtason,102)+''',''' +@cbr+''',''' +@clcode+''',''' +convert(varchar(10),@dtndate,102)+''' output' exec(@csql) on executing script, following error. cannot use output option when passing constant stored procedure. without using dynamic sql, script gives me required result. exec uspndateget @dtason,@cbr,@clcode,@dtndate output you need pass parameters outside inside query. here show generic case: declare @sql nvarchar(max); declare @out1 nvarchar(10); declare @out2 nvarchar(10); declare @parmdef nvarchar(max); set @parmdef = ' @parm_out1 nvarchar(10) ' + ', @parm_out2 nvarchar(10) ' ; set @sql='exec myproc @parm_out1 output, @parm_out2 output ' exec sp_execut...

javascript - maintainable way of injecting dependencies in angularjs -

i wondering how can inject dependencies in more readable way in angular. more interested in amd(requirejs) way. following: define(function (require) { var moduleone = require("moduleone"), moduletwo = require("moduletwo"); var thismodule = (function () { // code here })(); return thismodule; }); is possible inject dependencies above way in angularjs or there better way current way in angularjs? from angular js official website angular modules solve problem of removing global state application , provide way of configuring injector. as opposed amd or require.js modules, angular modules don't try solve problem of script load ordering or lazy script fetching . these goals orthogonal , both module systems can live side side , fulfil goals. hence, purpose of both libraries(requirejs , angularjs) totally different. dependency injection system built angularjs deals objects needed in component; whil...

image doesnt shows on JLabel when click on next button, using java Swing -

i trying make small program shows pic on jlabel when user click on next button.the problem when click on next button shows nothing.but if resize frame shows pics directory. instead of 1 picture @ time. please excuse english. here code. import java.awt.*; import javax.swing.*; import java.awt.event.*; import javax.imageio.imageio; import java.io.*; import java.awt.image.bufferedimage; class test { public static void main(string args[]) { frame f = new frame(); f.gui(); f.actions(); } } class frame { bufferedimage file; file img; imageicon icon; jlabel image; jframe frame; jpanel panel; string[] path = { "juice.jpg", "gal.jpg", "truck.jpg", "drive.jpg" }; jbutton next = new jbutton("next"); jbutton pre = new jbutton("prevoius"); jtextfield field = new jtextfield(10); static int num = 0; public void gui() { frame = new jframe(...

Get CWD of bjobs in LSF environment -

bjobs -l gives long description of job cwd split across 3 lines. want command can reliable fetch me cwd. if you're using recent version of lsf (9.1.2+ believe), can use -o option of bjobs customize bjobs short form output give each job's cwd on single line: $ bjobs -o 'jobid exec_cwd' 5950 jobid exec_cwd 5950 /home/squirrel/cwd if you're running older version of lsf real option parse long form bjobs output. the -uf option bjobs display same output @ -l option, in "unformatted" way. take of job events split many lines , display each 1 on single line easier parsing.

html - Product list with jquery. Method remove() -

it simple product list. use jquery. have problem. remove() dont work , elements of list dont remove. dont understand why. me please, , sorry english). code. html <div class="container"> <h1>product list</h1> <input type="text" name="newproduct" id="newproduct" placeholder="enter product here"/> <ul id="productlist"></ul> </div> css code * { box-sizing:border-box; } body { font-family: tahoma, sans-serif; } .container { margin:0 auto; width:600px; } h1, #newproduct { text-align: center; width:598px; } #newproduct { border:1px solid #999; padding: 20px; font-size: 28px; box-shadow: 0px 0px 3px #888; } #productlist { list-style: none; padding-left:0; background-color: #f2f2f2; } .product { padding: 15px 0px 15px 40px; margin: 10px; position: relative; font-size: 24px; box-shadow: 2px 2px 3px #848484;...

javascript - Benefits of using $scope.foo versus foo.vaue -

in controller, can access inputs values value of dom id instead of setting ng-model directive , binding dom value $scope. for example, in <input type="text" ng-model="foo" id=foo> we can either use $scope.foo or foo.value in controller. advantage of using $scope in case? i think main benefits of using ng-model instead of getting value of input id two-way binding . variable ng-model date , can use directly in html or wherever want. <input type="text" ng-model="foo" id="fooinput" /> <p>ng-model value: <span ng-bind="foo"></span></p> if choose approach when value input id lose feature, little bit better performance. because whenever type into, trigger $digest cycle causing angular update watchers , bindings in app see if has changed. a little demo on plunker .

kill process - Getting an Android app to start and stop a third party app -

i have android app uses activity start app (a third party app). after events have taken place, want activity stop/hide/kill third party app. starting third party app easy, cannot find way stop it. i have read on net how should done , cannot seem outcome want. @ point seems impossible without rooted device. if can suggest better way of doing this, appreciated. i if uid of third party app different, calls kernel kill third party app ignored, given have started app, think there must way stop it. i have included of code have used/tried - comments. third party app called com.xxx. //start activity string packagename = "com.xxx"; intent startintent = this.getpackagemanager().getlaunchintentforpackage(packagename); startactivity(startintent); //attempts stop app list<activitymanager.runningappprocessinfo> activityes = ((activitymanager)am).getrunningappprocesses(); (int icnt = 0; icnt < activity...

Explain the relationship of ESB technology with EAI and SOA? -

can explain relationship of esb technology eai , soa? , give me examples. eai integration framework composed of group of technologies , services form middleware/esb enable integration of systems , applications within enterprise, and/or across enterprises. esb software architecture model used implementing communication between software applications in service-oriented architecture (soa). examples: oracle services bus (osb) http://www.oracle.com/technetwork/middleware/service-bus/overview/index.html ibm websphere enterprise service bus: http://www-03.ibm.com/software/products/en/wsesb soa architectural pattern in application components provide services other components/clients via communication protocol (soap, rest). soa architecture independent of vendor, product or technology.

postgresql (npgsql 2.2.5) with entity framework 6 and code first -

i having issues right initializing database using code first. i'm having problems on how trigger initializer if database not exist. i've tried following, https://stackoverflow.com/a/28960111/639713 but problem have call method on initial page trigger create database. that, tables not created unless manually it. issue if i'm going integrate app using sql server , have 50 tables on dbcontext. anyway, here's code: dbcontext public class testmigrationsdatabase : dbcontext { public testmigrationsdatabase() : base(nameorconnectionstring: "testmigrations.domain.entities.testmigrationsdatabase") { //database.setinitializer<testmigrationsdatabase>(null); database.setinitializer<testmigrationsdatabase>(new testmigrations.domain.testmigrationsinitializer()); } public dbset<base> bases { get; set; } public dbset<fighter> fighters { get; set; } p...

c99 - Does comma separators in type definition in C guarantee the order? -

comma operators have lowest precedence , left-to-right associativity, guarantees order like: i = ++j, j = i++; i 2, , j 1 after statement if i , j both 0 @ first. however, comma separators in type definition in c guarantee order? such as int = 1, j = ++i; your example comma operator, i = ++j, j = i++; , well-defined because comma operator sequence point. precedence/associativity not enough guarantee -- different order-of-evaluation , sequence points. example, i * 2 + i++ * 3 undefined because there no sequence points. the comma separator between declarators , e.g. int = 1, j = i++; , sequence point. covered c11 6.7.6/3, c99 6.7.5/3: a full declarator declarator not part of declarator. end of full declarator sequence point. so there sequence point after i = 1 , , code well-defined. however, comma separator between function arguments f(i, i++) not sequence point; code causes undefined behaviour. note: in c11, term sequence point rep...

linq - Enforce ordering of OData items even when $top is used -

i have dbset<items> collection. the primary key guid. don't want order primary key. want order editable decimal property named "order". the code have simple, , works great until user puts "$top" parameter request: public class itemscontroller : apicontroller { protected dbcontext ctx = // ... // api/documents [enablequery()] public iqueryable<item> get() { return ctx.items.orderby(o => o.order).asqueryable(); } when user puts "$top" query string, order gets messed (it presumably forces ordering done primary key, consistent paging results -- however, in situation, having opposite effect, it's preventing me having consistent paging results). i've tried moving .asqueryable() earlier in query (before .orderby(...) clause), i've tried without .asqueryable() , i've tried 2 asqueryables, etc. there going lot of items in table, needs done via iqueryable (enumerating of items on web ser...

swift - Why does SwiftyJSON create implicitly unwrapped optional for its constants? -

Image
in swiftlyjson's code , defines following constants using forced unwrapping: ///error code public let errorunsupportedtype: int! = 999 public let errorindexoutofbounds: int! = 900 public let errorwrongtype: int! = 901 public let errornotexist: int! = 500 what's purpose of declaring constants implicitly unwrapped optional here? note: not asking why or when use implicitly unwrapped, rather why it's used in swiftyjson see no reason that. well, maybe i'm wrong, of course better way ask author of code. here suggestions anyway: by blaming commit can see changes made @ oct 6 2014 , know swift released there compiler warnings or maybe errors: actually writing int! instead of int forcing compiler generate implicitlyunwrappedoptional<int> type (and knowing fact return item 1): public let x: int = 1 public let y: int! = 2 println(x.dynamictype) println(y.dynamictype) outputs: swift.int swift.implicitlyunwrappedoptional<swift.int>...

jquery - Remove a td cell containing specific text from being counted -

var donotcounts = 'td.player:contains(s)'; $(data).find('td.two_column_layout .report').each(function (index, element) { if ($(this).find("td.player:not("+donotcounts+")").length !== +requiredstarters && $(this).attr("id") !== "invalidlineup") i trying count td.player cells , except children span class contain specific letter. here have. set var "donotcounts" , have 2 questions. how can make var use true or false declaration can decide whether want count or not count , based on true or false setting ? how can add 2nd var called donotcountp , can remove span warning text p , not counted well, true/false can turn both on or 1 or other ? example html <table> <caption><span><a></span></caption> <tbody> <tr><th class="player">text</th><th>text</th></tr> <tr><td class="...

regex - Not moving files in perl grep in if expression -

i have current subroutine written move files in current directory /junk directory off current directory if don't have file extension. reason, none of files getting moved, , think has unless expression. i've been working in perl week appreciated! sub clean_old_runs { $current = cwd(); opendir(dir, $current); mkdir 'junk'; @files = readdir(dir); $num_of_files = scalar(@files); for(my $n = 0; $n < $num_of_files; $n++) { unless ( grep {/\.ext1$/} @_ or grep {/\.ext2$/} @_ or grep {/\.pl$/} @_) { move("$current/@_", "$current/junk/@_"); } } close dir; } there's more 1 thing wrong code. here's complete working example: #!/usr/bin/env perl use cwd; use file::copy; sub clean_old_runs { $current = cwd(); opendir(dir, $current); mkdir 'junk'; @files = readdir(dir); $num_of_files = scalar(@files); foreach $file (@files) { ...

python - Regex catastrophic backtracking -

Image
i using regex remove css comments , content input document, using following code: text = re.sub('/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/', '', input_text) however, running catastrophic backtracking , , i'm pretty sure has *+ nested within * near end of expression. however, i'm not sure how rewrite regex still same thing without nested quantifiers. need to remove comments of forms: /* remove text */ /* * remove text */ /******* * remove text *******/ can offer little in rewriting regex avoid situation? don't understand how can still accomplish same task without nested quantifiers. appreciate lot! you can use simple regex leveraging single line flag this: /\*.*?\*/ or /[*].*?[*]/ working demo you can use python code: import re p = re.compile(ur'/\*.*?\*/', re.dotall) test_str = u"/* remove text */\n\n/*\n * remove text\n */\n\n/*******\n * remove text\n *******/" subst = u"" result = re.sub(p,...

arrays - PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset" -

i running php script, , keep getting errors like: notice: undefined variable: my_variable_name in c:\wamp\www\mypath\index.php on line 10 notice: undefined index: my_index c:\wamp\www\mypath\index.php on line 11 line 10 , 11 looks this: echo "my variable value is: " . $my_variable_name; echo "my index value is: " . $my_array["my_index"]; what these errors mean? why appear of sudden? used use script years , i've never had problem. what need fix them? this general reference question people link duplicate, instead of having explain issue on , on again. feel necessary because real-world answers on issue specific. related meta discussion: what can done repetitive questions? do “reference questions” make sense? notice: undefined variable from vast wisdom of php manual : relying on default value of uninitialized variable problematic in case of including 1 file uses same variable name. majo...

In the Soundcloud API, is information about a track still available after it's removed due to DMCA infringement? -

i'm building app utilizes soundcloud api , came across small problem. archive playlists on our own servers cut down on amount of data needed display tracks. so, example, user can create playlist tracks soundcloud strip away data provided soundcloud minimum required view , play said track. data includes it's sc_id, track name, artist, stream url, etc. doesn't provide full data set sc does. my question: when songs removed due dmca copyright infringement, soundcloud keep track id , information available or remove track entirely? mean is, have track id 123456 , removed due dmca. track still exist such request [sc_api_url]/tracks/123456.json yield track not streamable nor downloadable? correct logic if wrong. i've searched documentation , best answer can if try , request resource not available throws common 404 error api not clear on happens when tracks removed due dmca violations. so reached out soundcloud , said removed public facing api. this means er...

android capture gesture and draw on canvas, incomplete draw -

i'm creating app user draws letter on canvas , gets validated if draw actual letter. i'm using gestureoverlayview canvas inside capture both gesture , path, problem canvas not drawing whole path/gesture hands. need find solution. need path/gesture drawn. xml: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <android.gesture.gestureoverlayview android:id="@+id/gestures" android:layout_width="wrap_content" android:layout_height="wrap_content" android:eventsinterceptionenabled="true" android:gesturestroketype="multiple" android:layout_alignparentright="true" android:fadeoffset="500" android:background="#000000"> ...

c++ - reverse a number's bits -

here c++ class revering bits leetcode discuss. https://leetcode.com/discuss/29324/c-solution-9ms-without-loop-without-calculation example, given input 43261596 (represented in binary 00000010100101000001111010011100), return 964176192 (represented in binary 00111001011110000010100101000000). is there can explain it? thank much!! class solution { public: uint32_t reversebits(uint32_t n) { struct bs { unsigned int _00:1; unsigned int _01:1; unsigned int _02:1; unsigned int _03:1; unsigned int _04:1; unsigned int _05:1; unsigned int _06:1; unsigned int _07:1; unsigned int _08:1; unsigned int _09:1; unsigned int _10:1; unsigned int _11:1; unsigned int _12:1; unsigned int _13:1; unsigned int _14:1; unsigned int _15:1; unsigned int _16:1; unsigned int _17:1; unsigned int _18:1; unsigned int _19:1; unsigned int _20:1; unsigned int _21:1; unsigned int _22:1; unsigned int _23:1; unsi...

ios - Why are UI events not thread-safe in Swift/Objective-C? -

so i'm beginning learn basics of grand central dispatch , whole concept of multithreading ios applications. every tutorial tell you must run ui events on main thread, don't understand why. here's problem came across yesterday, , fixed running segue on main thread, still don't understand why running off main thread problem: i had custom initial vc (barcode scanner) , segue new view controller uiwebview attached. vc found barcode, called handler, , in closure, had performseguewithidentifier . however, got exc_bad_access because of (it didn't happen when second vc had label or uiimageview , uiwebview ). realized reason, closure called off main thread, , segue being performed off main thread. why performing segue on thread throw memory error? because self in self.performseguewithidentifier somehow nil? , why wouldn't swift automatically dispatch segue event on main thread? interesting question! crash isn't related uikit. it's crash speci...

reader - Clojure: How do I get the file/line number on which a map was defined? -

i know can :line , :file metadata on var; however, i'm building system user can pass me raw maps , end "linking" data @ later time. when linkage fails, i'd report file/line in specified map. e.g.: (defn generate-stuff [] (make-thing { :k (make-thing { :k v }) } ) ) (link (generate-stuff) (other-generator)) ;; outputs file/line of map containing errant :k/v pair i assume writing macro associate file/line collection's metadata way go, since there isn't "var" at, i'm not sure line number. see definition of get-line-number, requires reader, , while can find of special readers , *default-data-reader-fn* data reader (which nil), cannot seem figure out how access "code" reader. ok, looks using &form in macro answer. wrote following bit of generic test code, , seems work: (defmacro make-thing [obj] (let [f *file*] (with-meta obj (assoc (meta &form) :file f)) ) ) the &form refers form i...

USB Printing using chrome browser on Mac -

i testing chrome.usb , chrome.printerprovider api. able connect usb printer using chrome.usb deviceinfo (sample app ) , device info. not able print using chrome.usb usb-label-printer app. app seems print using label printer did not work when use usb printer. have vendorid, productid, endpoint correctly configured. how print?

java ee - Servlet is not updated after modifing code (Netbeans/Tomcat) -

i'm working on java ee application , have faced following problem: when modify code of servlet , re-run it's old version displayed. have cleared logs of tomcat , restarted still have same issue. yes times happens this. 1 thing. delete tomcat , re configure .it work, problem ide only.

java - For-Each Loop Alternative - Clarification -

i working through lessons in java, , have not been able understand going on in following lesson. purpose: purpose of lesson explain how for-each loop works creating alternative simulates how for-each loop work. in previous lesson, explanation of for-each loop simple: import java.util.arraylist //imports arraylist class public class foreachloops { public static void main(string[] args) { arraylist<integer> numbers = new arraylist<integer>(); // ^ creates arraylist object & calls constructor for(int = 1; < 11; ++i) numbers.add(i); //just adding numbers 1-10 arraylist. for(int n : numbers) //for-each loop system.out.println(n); //returns value each arraylist element } } in next lesson, instructor showing how create alternative/simulator of for-each loop. works follows: import java.util.arraylist; //importing arraylist class package import java.util.iterator; // question 1 (see be...