Posts

Showing posts from July, 2010

r - How to display (advanced) customed popups for leaflet in Shiny? -

i using r shiny build web applications, , of them leveraging great leaflet features. i create customed , advanced popup , not know how proceed. you can see can in project created post on github , or directly in shinyapp.io here the more complex popup is, weirdest code is, sort of combining r , html in strange way (see way define custompopup'i' in server.r ).. is there better way proceed? practices build such popups? if plan display chart depending on marker being clicked, should build them in advance, or possible build them 'on fly'? how can that? many in advance views on this, please not hesitate share answer here or directly change github examples! regards i guess post still has relevance. here solution on how add possible interface output leaflet popups . we can achieve doing following steps: insert popup ui element as character inside leaflet standard popup field. character means, no shiny.tag , merely normal div . e.g. classic uiou...

java - Start tomcat7:run maven plugin within eclipse and debug -

i want debug webapp in eclipse. point tomcat , webapp ran inside of eclipse in debug mode, breakpoints in webapp code have no effect. details webapp maven artifact , use m2e plugin in eclipse bridge between maven , eclipse. i've managed start tomcat server within eclipse. webapp started in tomcat nicely, in debug mode if choose so: in eclipse, right-click project run > maven build... (not "maven build") a window opens. in text field "goals", enter "tomcat7:run" click apply click run the tomcat server starts running , stdlog printed window within eclipse. can stop conveniently , start again in debug mode. far, that's want , expect. problem set breakpoint in code of webapp , restart tomcat in debug mode within eclipse. now, breakpoint isn't active: doesn't have little tickmark active breakpoints have , know code executed, doesn't stop @ breakpoint. there can 2 ways fix , need 1 or both of them. open run c...

java - how to create instance from an inmutable objects? -

i trying create new instance inmutable object. in case, list, , getting error: java.lang.instantiationexception: java.util.collections$unmodifiablerandomaccesslist @ java.lang.class.newinstance(class.java:364) @ com.example.movies.domain.transformer.domainentitytransformer.transformentityarray(domainentitytransformer.java:32) @ com.example.movies.domain.service.client.impl.clientserviceimpl.getclients(clientserviceimpl.java:58) @ com.example.movies.service.controller.clientcontroller.getclients(clientcontroller.java:50) @ 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:606) @ org.springframework.web.method.support.invocablehandlermethod.doinvoke(invocablehandlermethod.java:221) @ org.springframework.web.method.support....

How to Bundle and render scripts in mvc 4 -- asp.net? -

i recenly learnt can bundle scripts js/css better , optimized performance. tried implement mvc project scripts aren't rendering. added bundleconfig class under app_start below. public class bundleconfig { public static void registerbundles(bundlecollection bundles) { bundles.add(new scriptbundle("~/content/bundles/js").include( "~/content/js/jquery.min.js", "~/content/js/bootstrap.min.js", "~/content/js/jobwebsite.js", "~/content/js/bootstrap-datetimepicker.min.js", "~/content/js/bootstrap-filestyle.min.js" )); bundles.add(new stylebundle("~/content/bundles/css").include( "~/content/css/style.css", "~/content/css/bootstrap.min.css", ...

axapta - AX 2012 initFrom methods -

i understand these initfrom(tablename) methods initialize fields in table related tables. called from? want follow pattern call method? every documentation on pattern tells me said above , no examples of using them. see examples of them being created. maxim lazarev made point using cross-reference tool. ignorantly did not realize had update on table , can see calls on method. lead me examples of being used in overridden table methods modifiedfield. i'm starting play around looks can use these initfrom methods fill in specific data need in forms whether it's directly in table or in actual form itself.

javascript - jQuery Div Scrolling Function: Issue in IE -

i'm developing website that has fixed banner div centered, , i'm using jquery below ensure scrolls correctly though fixed positioned div. jquery: $(window).scroll(function() { $('#top-content').css('left', -$(this).scrollleft() + "px"); }); however, have come across issue within ie(version 9). issue when user scrolls website (creating minus left margin on "top-content" div, give effect of scrolling) , if maximize webpage, left margin still present causing div not centered. i have attempted remedy jquery below, of yet no luck $(window).resize(function() { if ($("#top-content").width() < $(window).width()) { $('#top-content').css('left:0px'); } }); any ideas? you better do $('#top-content').css('left', '0px'); in resize event.

onsen ui - How does one navigate between pages while maintaining state whilst using <ons-navigator>? -

i have 3 main pages: list (of businesses), search, , favourites. list page users can drill down details business. i using <ons-navigator>. navigating list details , list working expected since using <ons-back-button>. list page state maintained since onsen-ui doing poppage(). my question how navigate list favourites or search while maintaining list state? right using pushpage() keeps adding pages stack. don't think that's how it's supposed work , practically speaking if push page page stack , exists... shouldn't added rather should moved top. idea. my code: <ons-navigator var="app.navi" page="list.html"></ons-navigator> <ons-template id="list.html"> <ons-page id="list-page"> <ons-toolbar> <div class="center">near me</div> </ons-toolbar> <ons-list></ons-list> </ons-page> </ons-template...

python - Tkinter window not closing after closed file dialog -

i close file open dialog after selecting file. code, can select file file open dialog remains open until click 'x'. how can close window after have selected file. here code: import sys tkinter import * tkinter.filedialog import askopenfilename fname = "unassigned" def openfile(): global fname fname = askopenfilename() if __name__ == '__main__': b = button(text='file open', command = openfile).pack(fill=x) mainloop() print (fname) the file dialog closing fine. think trying tkinter window created hold button not closing after select file dialog. have this, need restructure program bit. first, need explicitly create tk window hold button: root = tk() you should list window button's parent: button(root, text='file open', command = openfile).pack(fill=x) # ^^^^ finally, should call destroy method of root window @ end of openfile : root.destroy() this cause window close , tk...

javascript - Direct a HTML page to login page -

i have created 2 html pages, 1 called login.html , other -- resume.html . what want is, no matter page open, i'll redirected login page. if open login.html , opened , fill in username , password fields, resume.html opens. my problem is, don't know code, should add, redirected login.html , when open resume.html . the code of login page : <html> <head> <title> login page </title> </head> <body> <h1 style="font-family:comic sans ms;text-align:center;font-size:50pt;color:#ff00ba;"> need login :) </h1> <form style="font-family:comic sans ms; text-align:center"> username<br> <input type="text" name="userid"/><br> password<br> <input type="password" name="pswrd"/> <br><br> <input style="font-family:comic sans ms;" type="button" onclick="che...

Python script to load multiple files -

i have basic python script opens .xml files , replaces values. copy single .xml file folder , run script. what able copy multiple files folder , have python script load them , proceed ask files proceed "run all" feature. is possible? have similar script share?

unity3d - How can I draw 2D triangles in Unity 5? -

i'm trying draw 2d triangles using this or this (scripts) unsuccessfully (i don't see triangles). have camera, canvas , panel in it, i've tried apply on empty canvas's child object, how must apply these scripts? i've tried different variations. , way draw triangles or there better? i've read somewhere gl class doesn't work on ios and/or mac, true? private gameobject m_gotriangle; m_gotriangle.addcomponent<meshfilter>(); m_gotriangle.addcomponent<meshrenderer>(); m_meshtriangle = m_gotriangle.getcomponent<meshfilter>().mesh; m_meshtriangle.clear(); m_meshtriangle.uv = new vector2[] { new vector2(0, 0), new vector2(0, 0.25f), new vector2(0.25f, 0.25f) }; m_meshtriangle.vertices = new vector3[] { new vector3(0, 0, 0), new vector3(0, 0.25f, 0), new vector3(0.25f, 0.25f, 0) }; m_meshtriangle.triangles = new int[] { 0, 1, 2 }; hope helps! =)

python - Should every url from urls.py in django have it's own method to respond the request? -

my test site has several search pages , each page contains it's own search form. of these pages identical , displaying functions in views.py similar. for example: @csrf_exempt def rooms(request): submited = false search_option = 'none' search_param = 'none' data = [] query = '' try: cnx = mysql.connector.connect(user='root', password='****', host='127.0.0.1', database='lessons') cursor = cnx.cursor() if not submited: query = "select * rooms;" cursor.execute(query) data = cursor.fetchall() if request.method == 'post': submited = true if request.post['search_option'] != "" , request.post['search_param'] != "": search_option = request.post['search_option'] search_param = request.post['search_param'] ...

Biztalk Distinguished field issue -

i'm passing message in biztalk resulting in following suspended message: inner exception: failure occurred while evaluating distinguished field messagestatus against message part data. message part data not contain @ least 1 of nodes specified xpath expression (listed below) corresponds distinguished field. cause error may message part data has not been initialized or message part data not conform message in orchestration i'm using map maps id called textid textid field in constructed message "messageattempt". have field called messagestatus value set "nothing" not confused . after map use message assignment shape set messageattempt.messagestatus element "attempted" following code: message_messageattempt.messagestatus = var_attempt; i been trying figure out day. have similar constructedmessage/transform/assignment shape on different branch in orchestration set same , works fine. i'm not sure missing. the x...

ruby - ActiveRecord ignores table_name_prefix -

i've got situation need define table_name , table_name_prefix within model , reason table_name overrides table_name_prefix. class scheduleitem < activerecord::base self.table_name = "schedule_item" self.table_name_prefix = 'acq_ibm_t.' end the prefix ignored in queries. but, when comment out table_name part prefix added. has seen strange behavior before? in activerecord::modelschema::classmethods , table_name setter puts value in @table_name : def table_name=(value) ... @table_name = value and table_name getter uses @table_name value if defined: def table_name reset_table_name unless defined?(@table_name) @table_name end the table_name_prefix used rails when trying guess table name based on class name (in reset_table_name ). if have table name rails can't guess, can this: class scheduleitem < activerecord::base self.table_name = "acq_ibm_t.schedule_item" or if need use prefix somewhere els...

javascript - Codelab's webrtc complete only allows for one connection? How do I allow more? -

i using code codelab's webrtc guide, complete step 7 code. modified main little bit, in sense room not "foo" value between 0 , 1 (math.random between 0 , 1). has possibility of creating 2 different rooms. now, host on localhost, open 2 tabs, refresh until both same "room number" , connect. works fine. then, open 2 more tabs , wait until each 1 has same room number. like, if other ones had room number 0, wait until second 2 tabs have room 1. still don't connect! seems code doesn't allow more 1 connection , can't figure out why. have ideas? i'm sure must simple fix, somewhere in there can replace "1" ">0" or something.

r - Replacing the first date instance if a condition is satisfied -

i have snapshot data in dataframe this: zz <- "id created snap stage alpha 2012-09-07 2014-01-02 alpha 2012-09-07 2014-10-01 end beta 2012-08-26 2014-01-04 b beta 2012-08-26 2014-06-19 c beta 2012-08-26 2014-11-21 end gamma 2014-01-04 2014-01-04 gamma 2014-01-04 2014-03-07 b gamma 2014-01-04 2014-03-28 c gamma 2014-01-04 2014-03-29 end delta 2014-07-14 2014-07-15 delta 2014-07-14 2014-09-26 c delta 2014-07-14 2015-02-06 end" df <- read.table(text=zz, header = t) i need replace snap date created date whenever created date before 2014-01-01 . want replace snap date first instance of observation. although id s move through a-b-c-end in order, id doesn't have start @ a. for example, i'm looking @ output: id created snap stage alpha 2012-09-07 2012-09-07 alpha 2012-09-07 2014-10-01 end beta 2012-08-26 2012-08-26 b beta 2012-08-26 2014-06-19 c beta 2012-08-26 2014-11-21 ...

c# - Can't create elevator using waypoints in Unity3d -

i have script waypoints, find here . works fine objects, move on horizontal axes. don't move objects , down. can't understand, why. elevator decoration , randomly move 1 floor another. public transform[] waypoint; // amount of waypoint want float patrolspeed = 3.0f; // walking speed between waypoints float dampinglook = 6.0f; // how turn public float pauseduration; // how long pause @ waypoint float curtime; int currentwaypoint; charactercontroller character; void start() { character = getcomponent<charactercontroller>(); } void update() { if (currentwaypoint < waypoint.length) patrol(); else currentwaypoint = 0; } void patrol() { vector3 target = waypoint[currentwaypoint].position; target.y = transform.position.y; // keep waypoint @ character's height vector3 movedirection = target - transform.position; if(movedirection.magnitude < 0.5) { if (cu...

r - reshaping daily time series data -

i have daily time series data starting 1980 , ends @ 2013 , following format https://www.dropbox.com/s/i6qu6epxzdksvg7/a.xlsx?dl=0 . codes far are # trying reshape data require(reshape) data <- melt(data1, id.vars=c("year","month")) however, did not me desired output. have data in 4 columns ( year, month, day , data ) or 2 columns ( date , data) in time series ( starting 1st jan 1980 , ends 31st dec 2013) i grateful guidance on how done. with kind regards extending jason's / dominic's solution gives example of how plot data xts time series asked for: library(xts) dat<-read.csv('~/downloads/stack_a.csv') dat.m <-reshape(dat,direction='long',idvar=c('year','month'),varying=list(3:33),v.names='value') dat.m <- dat.m[order(dat.m[,1],dat.m[,2],dat.m[,3]),] # order year, month, day(time) dat.m$date <-paste0(dat.m$year,'-',dat.m$month,'-',dat....

osx - C++11 headers missing on Mac OS X 10.8.2 (MountainLion) -

i'm new mac. have linux , windows c++11 source uses boost i'd build on mac. installed macport (should instead using homebrew?) ran commands such as: sudo port install cmake sudo port install boost sudo port install openssl sudo port install gcc49 sudo port install gcc_select sudo port install --set gcc mp-gcc49 cmake correctly finds boost 1.57.0 , sets makefile. when run make , seems cannot find normal c++11 headers such "chrono": in file included ../src/test.cpp:10: ../src/test_private.hpp:33:10: fatal error: 'chrono' file not found #include <chrono> ^ 1 error generated. indeed, when go looking c++ header files, see of them in /usr/include/c++/4.2.1/ newer files such chrono , thread missing. is there package need install before can compile c++11 source code on mac? xcode, apple supplied compiler/tools, comes 2 implementations of std::lib: gcc's libstdc++, version 4.2. libc++ the first very, old, , not supp...

Create a file in a directory shell -

i have directory named "dir" in there html file , folders named 01 02 03 ... 10. want create folder "dir", in each folder file page01.html folder 01 , page02.html dir 02 etc .. i have tried: for in `ls -a * /`; touch page$i.html done but not create me files in directories. thank you to create file pagex.html each directory x , can use: for dir in */ touch "$dir/page$dir.html" done this safer , less redundant version of for dir in `ls -d */` , should never used has problems various types of special characters. if have other directories, can limit ones 2 digits name: for dir in [0-9][0-9]/ touch "$dir/page$dir.html" done

How to draw in javascript canvas and compare it to a shape? -

Image
so keep short i'm wondering how able track user drawing moment click when let go , compare check accuracy say, perfect circle? would possible, , if best ways check accuracy compared perfect circle , how? also thinking of if user has drawn circle start , end points don't meet, maybe draw line connect them, etc? i did "stay inside text" game while back. try trace number. more stay inside lines while tracing, higher score is. you're welcome start , modify needed. :-) var canvas=document.getelementbyid("canvas"); var ctx=canvas.getcontext("2d"); var $canvas=$("#canvas"); var canvasoffset=$canvas.offset(); var offsetx=canvasoffset.left; var offsety=canvasoffset.top; var scrollx=$canvas.scrollleft(); var scrolly=$canvas.scrolltop(); ctx.font="216px arial"; ctx.fillstyle="white"; ctx.filltext("2",100,200); ctx.stroketext("2",100,200); var cw=canvas.width; v...

javascript - RequireJS sugar for main require -

my javascript file starts configuration... require.config({ baseurl: 'scripts', paths: { 'code-mirror': 'codemirror/main', 'esprima': 'https://cdn.rawgit.com/jquery/esprima/1.2/esprima', 'jquery': 'http://code.jquery.com/jquery-1.11.2.min', }, }) ...and requires... require( ['jquery', 'code-mirror', 'profile', 'feedback', 'browser-detect'], function($, codemirror, undefined, feedback, browser){ ...and works! now, attempted use sugar syntax instead, so... require( function(require){ var $ = require('jquery'), codemirror = require('code-mirror'), undefined = require('profile'), // functions bound window feedback = require('feedback'), browser = require('browser-detect'); ...and not work! why? thank you! the commonjs sugar syntax available define , not require . if @ source...

javascript - Kendo Grid drag & drop not working properly in IE -

i have kendo grid implemented drag , drop. when selection mode set multiple rows...the drag , drop doesn't work in internet explorer, though works fine in chrome , firefox. selectable: "multiple row" so happens in ie, when try drag row, selects multiple rows. dragstart event doesn't fire. the way ie drag , drop me select row, go edit mode on cell , start dragging. is there else special have internet explorer? or kendo grid not work it?

html - How to Style a disable DIV element -

i can make input element respond :hover , :hover:disable but looks div doesn't respond same. .btn { width: 99px; border-color: 2px #787878; background-color: #cacaca; margin-left: 76px; margin-top: 21px; position: relative; border-radius: 26px; -moz-border-radius: 26px; -webkit-border-radius: 26px; cursor: pointer; } .btn:hover:disabled { background: red; cursor: no-drop; } <div class="btn" id="divdisable" style=" height: 30px;line-height: 30px; text-align: center;" disabled>disabled </div> <input class="btn" id="idisabled" type="submit" value="disabled" disabled> full sample tried bonus info question answer div doesn't have disable make div content disable http://jsfiddle.net/ws47f/ a div element doesn't have disable attribute. add class in case css. div.divdisable:hover {}

passport.js - Express Session Getting Overwritten -

i have express passport authentication , have added session below. app.use(cookieparser()); // read cookies (needed auth) app.use(bodyparser()); // information html forms app.set('view engine', 'ejs'); // set ejs templating // required passport // trust proxy behind web server. //app.set('trust proxy', 1); app.use(session({ secret: 'this secret', resave: false, store: new mongostore({ url: configdb.url }), saveuninitialized: true, cookie: { httponly: true, maxage: 2419200000 } })); // session secret app.get("/*", function(req, res, next) { if (typeof req.cookies['connect.sid'] !== 'undefined') { console.log(req.cookies['connect.sid']); } next(); // call next middleware }); app.use(passport.initialize()); app.use(passport.session()); // persistent login sessions app.use(flash()); // use connect-flash flash messages stored in session not sure issue is, in passport login setting sess...

SQL Server 2012 : insert data into table while checking for duplicates -

i have written query insert data sql server table excel, , need add check , see if information in table. when add where clause check table see if data i'm insert new, not add data, if new. here code: create table #master ( brnbr varchar(10), branchname varchar(100), region varchar(100), marketplace varchar(100), enumber varchar(120), fname varchar(100), lname varchar(100), sbslfname varchar(100), sbl varchar(100), title varchar(100), status varchar(100), startdate int ); insert #master (brnbr, branchname, region, marketplace, enumber, fname, lname, sbslfname, sbl, title, status, startdate) values ('tt000', 'test1', 'test2', 'test3', 't77777', 'test4', 'test5', 'test6', 'test7', 'sbs', 'a', '42005'); insert dbo.tbsbstest select distinct brnbr, branchname, region, marketplace, enumber, fname, ...

Remove &thinsp; from Ruby String -

i try parse data , meet trouble clean   symbol. knew "space" realy got trouble clean string code: require 'rubygems' require 'mechanize' agent = mechanize.new page = agent.get('my_page.hmtl') price = page.search('#product_buy .price').text.to_s.gsub(/\s+/, "").gsub(" ","").gsub("&thinsp;", "") puts price and result got "4 162" - dat spaces. don't know do. please meet issue previously. thank you html escape codes don't mean ruby's regex engine. looking "&thinsp;" literal characters, not thin space. instead, versions of ruby >= 1.8 support unicode in strings, meaning can use unicode code point corresponding thin space make substitution. unicode code point thin space 0x2009 , meaning can reference in ruby string \u2009 . additionally, instead of calling some_string.gsub('some_string', '') , can call some_string.delete(...

Where to load webix? -

trying learn webix (and javascript @ all). common practice loading javascript libraries @ end of body. the webix quick start doc says: <!doctype html>// specifies document type <html> <head> <link rel="stylesheet" href="../../codebase/webix.css" type="text/css"> <script src="../../codebase/webix.js" type="text/javascript"></script> </head> <body> e.g. loads library in head. questions: the webix lib should loaded in <head> ? if yes, should loaded jquery , twitter bootstrap ? and in order? you can place webix.js anywhere on page. sure js code uses webix api used after webix.js loading normally scripts placed @ end of html file add interactivity page. in case of webix ui, without webix.js not see content on page @ all, there no benefits putting webix.js @ end of page. as jquery - if plan use webix-jquery integration need load webi...

javascript - Display number of LinkedIn shares, client-only, without authentication -

https://www.linkedin.com/countserv/count/share?url=stackoverflow.com&format=json correctly shows number of shares meteor.com (935 @ moment). i'm trying display number in client: $.getjson('https://www.linkedin.com/countserv/count/share?url=stackoverflow.com&format=json&callback=?', { datatype: "jsonp" }, function (data) { alert(data.count); }); because of x-content-type-options: nosniff header being returned, i'm getting refuse execute script error in chrome: refused execute script ' https://www.linkedin.com/countserv/count/share?url=http://stackoverflow.com&format=json&callback=jquery210014496755180880427_1426891580561&_=1426891580562 ' because mime type ('application/json') not executable, , strict mime type checking enabled. is there workaround (aside routing request through proxy), or impossible, as case github , unless linkedin fixes issue ? this looks duplicate of post: get linked...

php - Extended Session in L5 does not persist between requests -

i extending session provider in order persist required data. started editing appserviceprovider's boot method : \session::extend('desk', function($app) { return new desk(); }); desk class looks like: namespace app\services; use illuminate\session\existenceawareinterface; class desk implements \sessionhandlerinterface, existenceawareinterface{ /** * existence state of session. * @var bool */ protected $exists; public function close() { return true; } public function destroy($session_id) { $session = $em->find('session', $session_id); $em->remove($session); $em->flush(); return true; } public function gc($maxlifetime) { // todo: implement gc() method. } public function open($save_path, $session_id) { return true; } public function read($session_id) { $session = $em->find('session',...

How to Query Big Data From SQL Server -

in table entries there 200w data in 2015-02-18 . in table entries there 250w data in 2015-03-18 . how can query data table entries , string of entrytext has same in 2015-03-18 not has same string in 2015-02-18`? i used below statement, slow: select entrytext entries convert(date, datecreated)='2015-03-18' except select entrytext entries convert(date, datecreated)='2015-02-18' you can use first query desired result: select entrytext entries convert(date, datecreated)='2015-03-18'

Sending and receiving multiple JSON literals via PHP sockets -

i trying send json data 1 php script through sockets. following client code $socket = socket_create(af_inet, sock_stream, sol_tcp); @socket_connect($socket, "localhost", 2429) or die("connect not opened"); $arr = ["hello", "i", "am", "a", "client"]; $count = 10; while($count-- > 0) { $msg = json_encode(["msg" => $arr[rand(0, 4)]]); // tried appending \n & \0 // $msg .= "\0"; // "\n"; echo "sending $msg \n"; socket_write($socket, $msg, strlen($msg)); } the following code piece of server handles reception: $count = 0; while(socket_recv($feed, $buf, 1024, 0) >= 1) { echo "obj ".++$count." : $buf"; // $obj = json_decode($buf); // error } the problem is, on socket server side, json_decode unable parse data because of following situation: expected output: obj 1: {"msg":"i"} obj 2: {...

Python list variables not getting modified by if-statement clauses -

i making game using langton's ant algorithm. want list tiles update number 0 in case... doesn't. why? note: direction variable based on compass (n, e, w, s) posx = 4 posy = 4 direction = 'w' tiles = [[1,1,1,1,1,1,1,1,1,1], [1,1,1,1,1,1,1,1,1,1], [1,1,1,1,1,1,1,1,1,1], [1,1,1,1,1,1,1,1,1,1], [1,1,1,1,1,1,1,1,1,1], [1,1,1,1,1,1,1,1,1,1], [1,1,1,1,1,1,1,1,1,1], [1,1,1,1,1,1,1,1,1,1], [1,1,1,1,1,1,1,1,1,1], [1,1,1,1,1,1,1,1,1,1]] def posision(posx, posy, tiles, direction): if tiles[posx][posy] == 1: tiles[posx][posy] = 0 if tiles[posx][posy] == 0: tiles[posx][posy] = 1 oldtiles = tiles if direction == 'n': if oldtiles[posx][posy] == 1: posx = posx+1 return 'w', tiles if oldtiles[posx][posy] == 0: posx = posx-1 return 'e', tiles if direction == 's': if oldtiles[posx][posy] == 0: ...

javascript - In a Firefox restartless add-on, how do I run code when a new window opens (listen for window open)? -

i starting build restartless firefox add-on , having trouble setting bootstrap.js. seems agree core of bootstrap.js pretty boilerplate code, along these lines: const cc = components.classes; const ci = components.interfaces; function startup() { let wm = cc["@mozilla.org/appshell/window-mediator;1"].getservice(ci.nsiwindowmediator); let windows = wm.getenumerator("navigator:browser"); while (windows.hasmoreelements()) { let domwindow = windows.getnext().queryinterface(ci.nsidomwindow); // can control happens domwindow.document } } function shutdown() {} function install() {} function uninstall() {} this code works , can control things in existing windows. example, domwindow.alert("text") creates standard alert saying "text" on every window open. however, can't find code allow me things in new windows; i.e. created after script runs. correct way handle creation of new windows , gain control on them, point "te...

php - Generating a string of file names, alternative to global variable? -

i'm creating function users can upload multiple images , upload them server. using global variable matter works, i've heard global variables bad in oop. so, i'm wondering alternative be? (i'm starting php programmer, detailed information appreciated) code: function addimgtonieuws($images){ if (isset($images) && $images != "") { $countfiles = count($images["name"]); ($i = 0; $i < $countfiles; $i++) { $filename = $images["name"][$i]; $filetype = $images["type"][$i]; $filesize = $images["size"][$i]; $fileerror = $images["error"][$i]; $filetmp = $images["tmp_name"][$i]; $kaboom = explode(".", $filename); $fileext = end($kaboom); $db_file_name = rand(100000, 999999) . "." . $fileext; $output = $this->db->real_escape_string($db_file_...

cytoscape.js - Change default size of nodes -

i'm starting use awesome library , want simple thing: change size of nodes. when nodes server, have size attribute, integer between 1 , 6. display size of node in consequence. i've tried weight attribute: for (var = 0; < self.galaxy.nodes.length; i++) { cy.add({ group: 'nodes', data: { id: self.galaxy.nodes[i].id.tostring(), weight: self.galaxy.nodes[i].size }, position: { x: self.galaxy.nodes[i].x , y: self.galaxy.nodes[i].y} }); } but unfortunately, size remains constant, , can't find direction in doc. have clue me? you can set width , height of nodes in stylesheet , using mapper on weight .

javascript - AngularJS: ngBindHtml that also contains child bindings? -

this question has answer here: angularjs ng-bind-html 2way data binding 2 answers angularjs v1.3.14: currently, i'm using 'ngsanitize' module in angular app "ng-bind-html" bind html output of area on page. works , doesn't require older $sce 'trust html' stuff. but, i'd embed child bindings within html. so... works... angular.module('myapp', ['ngsanitize'...) .controller('somectrl', ['$scope', function($scope) { $scope.myhtml = '<p>hello world</p>'; }]); ... <div ng-app="myapp" ng-controller="somectrl" ng-bind-html="myhtml"></div> something doesn't... angular.module('myapp', ['ngsanitize'...) .controller('somectrl', ['$scope', function($scope) { $scope.mycontent = '...

c - What is the -z option for in this gcc compiler command? -

the command: gcc -fno-stack-protector -z execstack -o exitcode exitcode.c i know need include -z execstack code work, , have idea execstack , allows me do. don't know -z option doing here. i've looked , grep 'd @ gcc , execstack man pages , used --help on both without finding straight answer. guessing enabling addition of execstack functionality...? in case -z execstack -z passed directly on linker along keyword execstack. source: https://gcc.gnu.org/onlinedocs/gcc/link-options.html#index-z-1241 about execstack linux has in past allowed execution of instructions on stack , there lots of binaries , shared libraries assuming behaviour. furthermore, gcc trampoline code e.g. nested functions requires executable stack on many architectures. avoid breaking binaries , shared libraries need executable stack, elf binaries , shared libraries can marked requiring executable stack or not requiring it. marking done through p_flags field in pt_gnu_stack pr...

MYSQL Query rows in a database for a phrase and append it if it doesn't exist -

i have table column maps, , map names end phrase _csgo , others don't. possible search through specific column , if string doesn't have ending _csgo add it? thanks this update query: update table set maps = concat(maps, '_csgo') maps not '%_csgo'; actually, underscore special character in like , can do: update table set maps = concat(maps, '_csgo') right(maps, 5) <> '_csgo';

php - Changing Text Size in Libchart -

i integrating libchart (the free php chart library) simple app purpose of drawing different types of graphs. have been able adapt use data changing size of generated graph. cant see change text size.in libchart, size of generated chart not specified , default small. for vertical bar chart have following code: echo"<br />"; //include "libchart/classes/libchart.php"; echo '<h3><b>graph a</b></h3>'; $chart = new verticalbarchart(880,400); $dataset = new xydataset(); if (!empty($pass_percent_eng))$dataset->addpoint(new point("english", $pass_percent_eng)); if (!empty($pass_percent_mat))$dataset->addpoint(new point("maths", $pass_percent_mat)); if (!empty($pass_percent_che))$dataset->addpoint(new point("chemistry", $pass_percent_che)); if (!empty($pass_percent_phy))$dataset->addpoint(new point("physics", $pass_percent_phy)); if (!empty($...

html - Embedd ppt file in Iframe -

is correct? or there way it? can u please me code? aim display ppt file onto frame when click link. <html> <head> <style type="text/css"> ul li{ font-size: 11px; list-style: none; } ul li a{ text-decoration: none; } </style> </head> <body bgcolor="lightgray"> <ul> <li><a href="http://docs.google.com/gview? url=wbste/ppt/smime.pptx&embedded=true" target="disiframe"><font face="lucida sans" color="black" >s/mime</font></a></li><br> </ul> </body> </html> make sure define iframe, src iframe page source <iframe name="disiframe" src="target.html"></iframe> here's working example <body> <a href="http://www.wikipedia.org/" target="myiframe">link text</a> <iframe src="http:...

javascript - Accessing a variable from inside a jquery drop down list? -

i have jquery dropdown list has 2 dropdowns. first 1 list of cars , second 1 shows car's models. working fine. use selection selected user search database (mysql) , find specific element within database. gives me else within code , once gave me undefined variable error message. can please me learn how code can access variables , display search result? here code: this example of jquery i'm using - i'm using cars shows cities: <select class="select" id="province" onchange="filtercity();"> <option value="1">rm</option> <option value="2">fi</option> </select> <select class="select" id="city" disabled> <option data-province="rm" value="1">roma</option> <option data-province="rm" value="2">anguillara sabazia</option> <option data-province="fi" value="3">firenz...

Java shutdown hook call on windows shut down -

i have situation in want perform task when user signals os(in case windows) shutdown. i have tried using java shutdown hooks. problem face when exit program using system.exit(0); , shutdown hooks called when directly shutdown computer, aren't. this code have used shutdown hooks- runtime.getruntime().addshutdownhook(new jvmshutdownhook()); //in main method //within main java class private static class jvmshutdownhook extends thread { @override public void run() { //perform tasks } } is there way interact os(i'm assuming native code) allows program exit gracefully? any appreciated. shutdownhooks indeed not work shutdown of windows. consider bug of java , opened bugreport last week. has not (yet) been published. there old bug report in 2008: runtime#addshutdownhook not work on windows vista, when user logs out . same problem occurs windows 7. ticket closed java.com without satifying response. windows gives shutdown time applications terminate gracef...

C# Regex needs additional characters -

my current string regex working wanted add <?php , <?php . here code: @"\b(public|private)\b" string keywords = @"\b(public|private)\b"; this how can div @"<\s*div[^>]*>(.*?)<\s*/div\s*>"; how can add <?php , <?php in same regex? to specify set of acceptable characters in pattern, can either build character class or use predefined one. character class lets represent bunch of characters single item in regular expression. can build own character class enclosing acceptable characters in square brackets. read using regular expressions php more details , learn how use php in regex . hope helps.

android - BluetoothGatt showing 10,000 identical characteristics for service -

Image
i've got problem i'm flummoxed about, because of how persistent is. i writing small android app communicate bluegiga ble113. i've connected device before, i'd made gatt modification not being reflected on android device (in none of apps tried - , verified desktop , ios app gatt updated expected). i tried turning off/on bluetooth , restarting nexus 7, , still nothing. finally, got desperate , tried solution mentioned here: https://stackoverflow.com/a/22709467/992509 uses reflection hit private bluetoothgatt method called refresh. it seemed work perfectly, new service showing up, however, ran service (with 1 characteristic) showing few hundred characteristics same uuid. number of identical characteristics climbed everytime ran app, , through device restarts , bt cycling. finally, got desperate , did factory reset on nexus (it's test device, don't care). didn't fix thing, , image shows i'm seeing (10k characteristics): my ble113 gatt looks ...

scala - Scoping unmanaged dependencies library sbt-assembly -

i'm trying scope unmanaged dependencies libararies main project. here scenario i have unamanaged dependency in lib folder called coinprism-api-assembly-1.2.jar has following build.scala file: 1 import sbt._ 2 import keys._ 3 object coinprismbuild extends build { 4 5 val appname = "coinprism-api" 6 val appv = "1.2" 7 val scalav = "2.11.2" 8 val akkav = "2.3.6" 9 val sprayv = "1.3.2" 10 11 val appdependencies = seq( 12 "com.typesafe.akka" %% "akka-actor" % akkav withsources() withjavadoc(), 13 "com.typesafe.akka" %% "akka-testkit" % akkav % "test" withsources() withjavadoc(), 14 "io.spray" %% "spray-client" % sprayv withsources() withjavadoc(), 15 "io.spray" %% "spray-can" % sprayv withsources() withjavadoc(), 16 "io.spray" %% "spr...