Posts

Showing posts from June, 2011

google maps - trace a route avoiding a street -

¿is't possible trace route gps location point (the gps location of user) point b (a marker given user), ¡¡but!!, avoiding street on google maps api? i have half of this, know how trace b gps location on google maps api doing click on button, im not sure if can avoid street. this example of want do, assuming blue marked street 1 cant cross

r - create stack bar with counts and fill/group levels in the same graph -

Image
i trying create stack bar counts , group levels in same graph (inside of plot). since group variable has 25 levels, prefer bring name of group levels inside of plot (since have 25 different colour , difficult visualization).i took " showing data values on stacked bar chart in ggplot2 ". wondering how can add name of each group level inside of graph. year <- c(rep(c("2006-07", "2007-08", "2008-09", "2009-10"), each = 4)) category <- c(rep(c("a", "b", "c", "d"), times = 4)) frequency <- c(168, 259, 226, 340, 216, 431, 319, 368, 423, 645, 234, 685, 166, 467, 274, 251) data <- data.frame(year, category, frequency) library(dplyr) data <- group_by(data,year) %>% mutate(pos = cumsum(frequency) - (0.5 * frequency)) library(ggplot2) #plot bars , add text p <- ggplot(data, aes(x = year, y = frequency)) + geom_bar(aes(fill = category), stat="identity"...

javascript - pass the context on to an inner function -

here code: function link(scope, element, attrs, formctrl) { element.tooltipster({ content: '', theme: 'validation-notify', arrowcolor: '#d9534f', contentashtml: true, functionbefore: generatecontent }); } function generatecontent() { var formfield = formctrl[element]; var = 0; } the above code broken because formctrl , element not available in generatecontent . now, realize use: functionbefore: generatecontent.bind({formctrl: formctrl, element: element}) and in generatecontent reference them by this.element i declare generatecontent inside of link. there better way of doing this? there anyway of binding generatecontent entire context within link, like: functionbefore: generatecontent.bind(this) (except in case this undefined)? like there anyway of binding generatecontent entire context within link nope, functions lexically scoped , remember environment in created. canno...

How to autofill form fields with google+ account? -

i've got few landing pages , wanted add feature. basically, user lands on 1 of pages , they're given option to: fill in data manually or click on google+ account button if they're signed google+ data autofill fields on form (name, email, phone, etc) anyone have insights on this? thanks!

mongodb - How to run a mongod instance -

i starter of mongodb . according "import example" section of mongodb 3.2 manual, prerequisite importing data database have running mongod instance. limited background knowledge of mongodb , failed understand line of instruction. please give me explanation on how run mongod instance step step in mac terminal? thanks. here several steps start mongodb var mongod created ./bin/data/db directory storing mongodb data file. start 1 terminal mongodb server go mongo/bin , , execute command ./mongod start terminal mongodb shell go mongo/bin , , run ./mongo now can connect mongodb now, more command show dbs , show collections , use dbname , more commands in mongodb, refer db.help() ...

Get all Messages in a RabbitMQ queue as csv or excel -

i have around 10000 messages in rabbitmq queue in ready state. thinking of purging messages before purging need message details downloaded csv or excel backup purpose. is there way this. using rabbitmq management plugin (web ui). thanks in advance no, can't export messages web-management csv/excel. you can consume it, , save messages prefer

Undefined method for 'n' in ruby while loop -

i trying write algorithm solve math problem Σ n = 1 49 of n(n+1). keep getting error "undefined method 'n' main object" def solver(n) sum = 0 while n < 49 temp = n(n+1) n+=1 sum = sum + temp end return sum end puts solver(1) instead of: temp = n(n+1) put: temp = n*(n+1)

command line - Crop down to circle -

i crop rectangular image down circle. ran command: convert -crop 500x500+100+100 in.jpg out.jpg however creates square rather circle. convert in.jpg -extent 400x400+100+100 \ '(' +clone -alpha transparent -draw 'circle 200,200 200,0' ')' \ -compose copyopacity -composite out.png this +100+100 part optional: allows shift viewport. how make circle thumbnail graphicsmagick?

javascript - How to send html email line by line using google apps script and google sheet data -

i have script send email line-by-line. problem have cannot use data in current line iteration in email template. know how call functions template though in case cannot call function being evaluated. my solution create function loop through data again , send line instance in email break. problem takes long loop through lines twice when im sure can done once. i hope made sense. code.gs function sendmail() { var ss = spreadsheetapp.getactivespreadsheet(); var sheet = ss.getsheetbyname('emaillist'); // data array var data = sheet.getdatarange().getvalues(); // loop on each line (var = 1; < data.length; i+=1) { // check status of email if (data[i][4] != 'sent') { // html file content var html = htmlservice.createtemplatefromfile('index').evaluate().getcontent(); // send email mailapp.sendemail({ to: data[i][2], subject: 'hi ' + data[i][0], htmlbody: html }); ...

php - Laravel 5 route get parameters SQLinjection -

i have route route::get('/car-{traveltype}/{cityfrom}-{cityto}-{id}.html','articlecontroller@getdetail')->name('articles_detail'); and in controller, catch parameters this public function getdetail($cityfrom, $cityto, $id, request $request) { $article_detail = db::select("call article_detail(?,?,?)", [$cityfrom,$cityto,$id]); return $article_detail; } this working fine there have problem query getting sqlinjection because route sent raw parameter. in post request can catch request $request->input('some_fields') , laravel protect me behind screen, not in request. how can resolved issue? you can use $request->get('somefield') on request using www.site.com/page?somefield=value in case when take $request->get('somefield') should give "value" so in case : www.site.com/page?travel-type=foo&city-from=berlin&city-to=munich&id=1 $request->get('travel-type...

Can I declare a function inside of the parameter of another function in PHP? -

i writing helper functions allow me build tables quickly. have function called responsive_table accepts 2 parameters: headings, , rows. rows dynamic , pulled database. build array of rows foreach loop because of db table rows don't match contents or order of html table... of cells in html table contain combinations of db columns, etc. , can't displayed directly db. none of rows in html table array being displayed. nothing inside of function that's being declared in function parameter being displayed. here's code: <?php $output = responsive_table(array('<input type="checkbox" name="all">', 'thumbnail', 'title', 'location', 'author', 'date submitted', 'actions'), function(){ foreach($listing_results $listing){ $listings[] = array( '<input type="checkbox" name="delete[]" value="'.$listing['listing_id'].'...

class - Extending multiple classes in java -

this question has answer here: java multiple inheritance 16 answers i have java class extends class. have found need inherit yet class , not sure how this. have tried class implements class b, class c. not work. class extends class b. need inherit class c. have tried create interface extends class c, says interface cannot extend class. not sure now.. you need c extends b extends a. or using interface u can multiple inheritance in java. jdk 1.8 defalut feature has been added multiple inheritance using interfaces. using composition on inheritance update : can use this class seaplane implements vehicle { private vehicle plane, ship; @override public void safetycheck() { plane.safetycheck(); ship.safetycheck() } }

java - AutoCloseable metric wrapper -

is semantically correct use autoclosable class wraps block of code , produces time metric? understand there no resource here, concern according http://mail.openjdk.java.net/pipermail/coin-dev/2009-march/000157.html class metric implements autocloseable { private final logger logger; private int starttime; public metric(logger logger) { this.logger = logger; } static metric createstarted(logger logger) { metric metric = new metric(); metric.starttimer(); return metric; } public starttimer() { this.starttime = system.milliseconds() } @override public close() { logger.debug(system.milliseconds() - starttime); } } class client { public static void main(string... args) { try (metric metric = metric.createstarted()) { // stuff } } there reasons why using lambdas not option here.

powershell - How to change the ps1 file in Unicode BigEndian to ASCII? -

our automated build script sign powershell scripts too. of our powershell scripts not signed . when analyzed , found there known gotcha files saved powershell ise saving in unicode bigendian can't signed. as automated process, if way check whether file saved in unicode big endian change ascii solve our issue. in powershell there way? i found function here gets file encoding: <# .synopsis gets file encoding. .description get-fileencoding function determines encoding looking @ byte order mark (bom). based on port of c# code http://www.west-wind.com/weblog/posts/197245.aspx .example get-childitem *.ps1 | select fullname, @{n='encoding';e={get-fileencoding $_.fullname}} | {$_.encoding -ne 'ascii'} command gets ps1 files in current directory encoding not ascii .example get-childitem *.ps1 | select fullname, @{n='encoding';e={get-fileencoding $_.fullname}} | {$_.encoding -ne 'ascii'} | foreach {(get-content $_.fullname) | set-conte...

javascript - Practically using script async or defer with frameworks like angular -

have been studying use of async , defer in script tags. given following... async - allows rest of html parse, while js script being loaded. once script loaded html parser paused execute script. however, note order of loading can't controlled. defer - allows rest of html parse, loaded js executed once html parsing complete. so, if can afford show html without loading js script first... use async . if more 1 script involved , order loaded matters use defer . on other hand, if scripts must loaded first (and can't rewritten allow html parse first) load script without using async or defer in header. how fit modern frameworks angularjs... since, delaying loading results in error. pointers appreciated.

bit - why x>>1 is not always same as x/2? -

why x>>1 not same x/2 ? especially when negative odd number, example: x = -3; assert.assertnotequals(x / 2, x >> 1); x = 3; assert.assertequals(x / 2, x >> 1); thanks helps. because of how >> works. >> not "divide 2", ends same answer situations. example, on 8-bit values: 3 0b00000011 ; right-shift 1 bit 0b00000001 , 1 . -3 0b11111101 ; right-shift 1 bit 0b11111110 , or -2 . however, integral division / in java defined round down towards 0 - (-3) / 2 becomes -1 (as closer 0 -2 is). edit: comments refer brainfart in switching >> , >>> around.

r - knit2pdf failing to produce pdf in Shiny Apps -

as title states, attempting create shiny application can generate pdf file user can download. (note not duplicate question because have not found question similar error) in search solution, found gist knitr package author: https://gist.github.com/yihui/6091942 , attempting recreate. there questions on s.o use same code, out = knit2pdf('input.rnw', clean = true) of them seem date before 3.2.3 release of r. the error given is: output file: input.tex warning: running command '"pdflatex" -interaction=nonstopmode "input.tex"' had status 1 error in texi2dvi(file = file, pdf = true, clean = clean, quiet = quiet, : unable run 'pdflatex' on 'input.tex' warning: error in texi2dvi: unable run 'pdflatex' on 'input.tex' stack trace (innermost first): 52: texi2dvi 51: tools::texi2pdf 50: knit2pdf 49: download$func [d:...\app-2/server.r#44] 1: shiny::runapp what have tried far: updating r, ...

css - Show "..." in HTML table content when the content is too big for its size -

i have given html table row space of 200px. text of more space can inserted it. want row display "..." @ end of row if content more space. use width: 200px; overflow: hidden; text-overflow: ellipsis; in css have overflowing text replaced ... . but doesn't work td elements, you'll have add element in between, example div. see demonstration .

beagleboneblack - How to blink two led simultaneously using Beaglebone black PWM pins in python -

i writing program in python blink 2 led simutaneously. using beaglebone black pwm pins. earlier wrote blink 5 led's 1 one worked fine. trying blink 2 led together, that's not working. not able maintain proper sequence, , led 1 , led 3 remains @ high, both , 1 of them. new python any appriciated. piece of code below: `` import adafruit_bbio.pwm pwm import time first = "p8_13" second = "p8_19" third = "p9_14" fourth = "p9_16" fifth = "p9_42" in range (0, 4): pwm.start(first, 50, 1000) pwm.start(second, 50, 1000) pwm.stop("p8_13") pwm.stop("p8_19") time.sleep(1) pwm.start(second, 50, 1000) pwm.start(third, 50, 1000) pwm.stop("p8_19") pwm.stop("p9_14") time.sleep(1) pwm.start(third, 50, 1000) pwm.start(fourth, 50, 1000) pwm.stop("p9_...

MongoDB Java - How to assign variables from a document -

is there way store variable document in mongodb? have document: { "math" : { "variableone" : 3, "variabletwo" : 4, } } i assign data int variables , add 2 , print out sum. a simple way write class represents document: public class math { private int variableone; private int variabletwo; //getters & setters } you can use jackson here convert document string object of class math.

.net - how to copy all files from a folder to another folder in c# -

please let me know how copy files within folder folder in c# .net. currently using : int j = 1; int k = 1; (j = 1; j < 5; j++) { (k = 1; k < 32; k++) { string sourcepath = @desktop_location + "\test" + k + ".log"; if (system.io.file.exists(sourcepath)) { file.copy(@desktop_location + "\\statistics\\server" + j + "\test" + k + ".log", @desktop_location + "\\statistics\\transfer\\test" + j + k + ".log"); //console.writeline("test result"); } else { //console.writeline("test"); string[] filepaths = directory.getfiles(@"c:\mydir\"); see getting files directory string mypath = @"c:\test"; foreach (string file in filepaths) { fileinfo info = new fileinfo(file); if (!file.exists(info.fullname)) { ...

pdo - SQLite Insert or Ignore/Replace with lastInsertID in one statement -

i feel should easy... i have table this: create table table_name ( id integer primary key, name text not null, unique (name collate nocase) ) no 2 names same, case insensitive. right have users adding names , this: insert table_name (name) values ("my name"); and need id of row, easy php pdo's lastinsertid(). want, if user adding name that's in database, nothing added database, still id without having database call. hoping insert or replace table_name (name) values ("my name"); and have overwrite same data cell , return lastinsertid (even though wasn't inserted?). doesn't work. other options? have separate database query see if name field exists? with or replace clause, statement deletes old row. just use 2 statements. (there no technical reason doing in single statement.)

sql - Grant security permissions to a database role -

i'd grant security-level permissions of users of database role . need them able execute alter login , create login , grant , exec sp_addrolemember , etc. the way i've found far add each user security admin server role following command: exec sp_addsrvrolemember 'username', 'securityadmin' this little cumbersome , i'm not able perform each user. there anyway grant these privileges database role? role, administrator owns db_accessadmin , db_securityadmin schemes, apparently don't help. not in sql 2008, no. specifically, ability create user-defined server role introduced in sql 2012. , since creating , altering logins server-level permissions, need, well, server-level permission. but not lost. can you're looking writing stored procedure , using module signing. granted, it's little more cumbersome both , end user, cost may worth benefit.

python - Write a Graph into a file in an adjacency list form [mentioning all neighbors of each node in each line] -

i need write graph in text file each line of file composed 1 node followed neighbors. it's adjacency list is, , function write_adjlist supposed do. unfortunatly it's not case, edge not replicated. in exemple of wikipedia adjacency list : a adjacent b, c b adjacent a, c c adjacent a, b we can see edges present 2 times (the edge (a,b) in lines 1 , 2, edge (b,c) in lines 2 , 3...). but if use following code generate small world network : import networkx nx n=5 #number of nodes v=2 #number of neighbours p=.1 #rewiring proba g = nx.connected_watts_strogatz_graph(n,v,p) nx.write_adjlist(g.to_undirected(),"test.txt") it gives me : #adj.py # gmt thu jan 21 06:57:29 2016 # watts_strogatz_graph(5,2,0.1) 0 1 4 1 2 2 3 3 4 4 where have 0 1 4 1 2 0 2 3 1 3 2 4 4 0 3 do know how have output want? actually how write_adjlist defined in order have file written want simple work around can done following fu...

pdf extraction - iTextSharp extract each character and getRectangle -

i parse entire pdf character character , able ascii value, font , rectangle of character on pdf document can later use save bitmap. tried using pdftextextractor.gettextfrompage gives entire text in pdf string. the text extraction strategies bundled itextsharp (in particular locationtextextractionstrategy used default pdftextextractor.gettextfrompage overload without strategy argument) allows direct access collected plain text, not positions. chris haas' mylocationtextextractionstrategy @chris haas in his old answer here presents following extension of locationtextextractionstrategy public class mylocationtextextractionstrategy : locationtextextractionstrategy { //hold each coordinate public list<rectandtext> mypoints = new list<rectandtext>(); //automatically called each chunk of text in pdf public override void rendertext(textrenderinfo renderinfo) { base.rendertext(renderinfo); //get bounding box chunk of text ...

dart - What is the smartest way to find the larger / smaller of two numbers -

in search of smartest, efficient , readable way below: int 1 = 1, 2 = 2; int larger = 1 < two?two:one; i prefer(or variadic version of below): int largest(one,two){return one<two?two:one;} int larger = largest(one,two); but dart has no inline or macro. with list: var nums = [51,4,6,8]; nums.sort(); in largest = nums.last or(thank you, günter zöchbauer): print([1,2,8,6].reduce(max)); using math library: import 'dart:math'; int largest = max(21,56); probably best, how efficient max in comparison first approach? why question? first approach must check comparisons done right each of them;hundreds of them sometimes. second, 1 function verify, hundreds of function calls. i'm pretty sure just import 'dart:math'; int largest = max(21,56); is best way. small enough inlined compiler (dart2js, vm) , least surprise reader. custom implementation reader had investigate function sure does. for collections of values find elegant wa...

c# - How can I rewrite the following SQL query into LINQ query? -

i want rewrite following sql query in linq. problem don't know how write add and(&&) operator linq left join(look @ 2nd left join). can please? select emp.employeeid, dsg.name, pob.companycontribution, pob.employeecontribution, pob.openingincome hrmemployees emp left join hrmdesignations dsg on emp.hrmdesignationid=dsg.id left join pfmopeningbalance pob on emp.id=pob.hrmemployeeid , pob.cmncalendaryearid=2 emp.id=6 i tried following one. getting compile error- from emp in dbcontext.employeelist join dsg in dbcontext.hrmdesig on emp.hrmdesignationid equals dsg.id dsgleftjoin dsglj in dsgleftjoin.defaultifempty() join pob in dbcontext.pfopeningbalances on emp.id equals pob.hrmemployeeid pobleftjoin poblj in pobleftjoin.defaultifempty() && poblj.cmncalendaryearid == clndrid ...

Android studio 2 issue after update to preview 6 -

Image
i updated android studio 2.0 preview 6. i got error message: error:(1, 0) plugin old, please update more recent version, or set android_daily_override environment variable "aed79d567e57792ed352e708d2b7ca891ff897c6" when click on options fix plugin version , sync project project synced nothing happens. when click on open file, opens build.gradle file associated app module. puts cursor on line: apply plugin: 'com.android.application' any clue android_daily_override environment variable ? or can error ? could try changing class path of build.gradle com.android.tools.build:gradle:2.0.0-alpha6 buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.0.0-alpha6' } } hope help.

rally - Lookback API _ProjectHierarchy not returning defects for child project -

i need defects particular project , of children. the rally lbapi documentation says: for project hierarchy project 7890 project 6543 project 3456 retrieve work items in project 7890 or of child projects, include clause in query: "_projecthierarchy": 7890 but doing in below query https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/xxx/artifact/snapshot/query.js?find={"_projecthierarchy":12345,"_typehierarchy": "defect","__at": "current","release":9999}&fields=["formattedid","name","state","openeddate","closeddate"]&hydrate=["state"]&sort={"formattedid":1}&start=0&removeunauthorizedsnapshots=true only return defects project 12345 none of child projects. i have read lookback api _projecthierarchy not scoping down , says same thing written in doc. is there else missing? ...

reactjs - Can I use an HTML form's action property to move between React Routes? -

i'm trying build react app, , getting trouble react router. first of all, url has weird hashstring @ its' end. example: http://localhost:3000/#/?_k=gb3epe also, i'm not sure whether hashtag in url , following gibberish part of same problem or if they're related 2 different problems. (i'm using react-router v1.0). secondly, think weird url preventing me using "action" property on forms, , know if there better way move around react renders relaying on forms. thanks. if we're talking react-router v1.0 , remove hash string should pass { querykey: false } parameter createbrowserhistory function. var createbrowserhistory = require('history/lib/createbrowserhistory'); reactdom.render( <router history={ createbrowserhistory({ querykey: false }) } routes={ reactroutes } />, document.getelementbyid('some-container') ); to move between routes react-router provides link component can use inside ...

how to display data stored in an array for android using C# and ListView -

i have following code written in c# using xamarin android : edittext nametext = findviewbyid<edittext> (resource.id.editname); button btnaddcontact = findviewbyid<button> (resource.id.btnaddcontact); listview contactview = findviewbyid<listview> (resource.id.listview1); btnaddcontact.click += delegate { string[] contactarr = nametext.text.split('\n'); }; first off .. data input edittext field stored array contactarr when btnaddcontact clicked? there no build errors wasn't sure if work.. my main question is, if data has been stored array, how go displaying data in list view? code example me world of don't have clue go this.. thanks. edit new code tried. edittext nametext = findviewbyid<edittext> (resource.id.editname); button btnaddcontact = findviewbyid<button> (resource.id.btnaddcontact); listview contactview = findviewbyid<listview> (resource.id.listview...

javascript - Gulp browserify babel and watchify to output multiple bundles -

i want output multiple bundles using gulp,browserfiy , use feature of babel , watchify.i produce mutliple bundles non wiser use feature of babel , watchify. here's have done multiple bundling var gulp = require('gulp'); var minifycss = require('gulp-minify-css'); var uglify = require('gulp-uglify'); var browserify = require('browserify'); var source = require('vinyl-source-stream'); var reactify = require('reactify'); var babel = require('babelify'); var watchify = require('watchify'); var csssrcdir = './css/'; var jssrcdir = './js/react/'; var builddir = './build/'; var distdir = './dist/'; var mapsdir = './maps/'; gulp.task('minify-css',function(){ return gulp.src(csssrcdir + '**/*.css') .pipe(minifycss()) .pipe(gulp.dest(builddir+'/css')) }); gulp.task('uglify',function(){ return gulp.src(jssrcdir + '/**/*.js...

ajax - ajaxSubmitButton beforeSend add vars to request -

i have ajaxsubmitbutton beforesend option: echo chtml::ajaxsubmitbutton('', chtml::normalizeurl(array('site/index')), array( 'datatype'=>'json', 'data'=>'js:jquery(this).parents("form").serialize()', 'beforesend'=>'js:function(data){ // myarr "good" array param mydata =$.param(myarr); /** somethig **/ }', ) ); so how can add mydata request data , send post request? it's easier expect, need create function returns params: <script type="text/javascript"> function getmydata(){ return $.param(myarr); } </script> and concatenate data: echo chtml::ajaxsubmitbutton('', chtml::normalizeurl(array('site/index')), array( 'datatype'=>'json', 'data'=>'js:jquery(this).parents("form")....

Share video from android phone to facebook -

i developing video recorder in android. requirement user should able share/upload video his/her facebook account or youtube account. need use facebook , youtube apis purpose or there easier way share android phone internet. maybe silly question take me immature , new programming world. regards there 2 different approaches: 1) upload youtube via data api video id , send link facebook using facebook api. (if want video available outside fb , reach larger audience) 2) upload facebook directly facebook api. (if want have video straight fb , share in fb.)

To know the sass structure -

this sass structure please explain mean? actually analysing code structure. unable understad structure. .class-name{ styles.. &.class-name2{ styles.. } } the & tells pre-processor add parent selector in-front of nested class. so this: .class-name{ background: blue &.class-name2{ background: red; } } would compile too: .class-name {background: blue;} .class-name.class-name2 {background: red;} the usage be: <div class="class-name">this background blue</div> and <div class="class-name class-name2">this background red</div>

Pass request to every Swig template using Express -

is possible pass request/req object every template render, wouldn't have pass local in every render() method? you can use res.locals that. insert following middleware somewhere before routes: app.use(function(req, res, next) { res.locals.req = req; next(); }); this exposes req variable in templates.

performance - fixing a Python progress bar in Command Prompt -

Image
i have wrote following code (reviewed in code review) in order print progress bar in python 2.7 (ps: know there progressbar module in python) from __future__ import division import sys class progress(object): def __init__(self, maxval): self._pct = 0 self.maxval = maxval def update(self, value): pct = int((value / self.maxval) * 100.0) if self._pct != pct: self._pct = pct self.display() def start(self): self.update(0) def finish(self): self.update(self.maxval) def display(self): sys.stdout.write("|%-100s| %d%%" % ('#' *self._pct, self._pct) + '\n') sys.stdout.flush() # test import time toolbar_width = 300 pbar = progress(toolbar_width) pbar.start() in xrange(toolbar_width): time.sleep(0.1) # real work here pbar.update(i) pbar.finish() i wish use progress bar in ide (ex: pyscripet, pycharm , etc) , command prompt. when run command ...

android - Troubles with overlay window -

i'm writing android application simulates mouse. used code pocketmagic.com cursor overlay , on droid maxx (4.4.4) works on minix neo x5 mini (4.4.2) (set top box) doesn't here's code mview = new overlayview(this); windowmanager.layoutparams params = new windowmanager.layoutparams( windowmanager.layoutparams.wrap_content, windowmanager.layoutparams.wrap_content, windowmanager.layoutparams.type_system_overlay,//type_system_alert,//type_system_overlay, windowmanager.layoutparams.flag_not_focusable | windowmanager.layoutparams.flag_not_touchable | windowmanager.layoutparams.flag_layout_in_screen, //will cover status bar well!!! pixelformat.translucent); params.gravity = gravity.left | gravity.top; params.settitle("cursor"); windowmanager wm = (windowmanager) getsystemservice(window_service); wm.addview(mview, params); and class overlayview extends viewgroup { ...

linux - Design of multi-threaded server in c -

when trying implement simple echo server concurrent support on linux. following approaches used: use pthread functions create pool of thread, , maintained in linked list. it's created on process start, , destroy on process termination. main thread accept request, , use posix message queue store accepted socket file descriptor. threads in pool loop read message queue, , handle request gets, when there no request, block. the program seems working now. the questions are: is suitable use message queue in middle, efficient enough? what general approach accomplish thread tool needs handle concurrent request multiple clients? if it's not proper make threads in pool loop & block retrieve msg message queue, how deliver requests threads? this seems unneccesarily complicated me. usual approach multithreaded server is: create listen-socket in thread process accept client-connections in thread for each accepted client connection, create new threads...

ios - Application Loader ERROR ITMS-90062 -

i trying upload update app on app store using application loader. getting following error. error itms-90062: "this bundle invalid. value key cfbundleshortversionstring [1.0.0] in info.plist file must contain higher version of approved version [1.0.0]." i thought cfbundleshortversionstring allowed remain same, build number (or "bundle version/cfbundleversion"), should increment on each build. is because version label (cfbundleshortversionstring) has increment on each approved version? meaning bug fix updates , such needs bump version label displayed in app store? regards you don't need change cfbundleshortversionstring, issue here app approved, , guess in "pending developer release" state. remove app through "cancel release" , try upload again. should work.

Get cell address of a defined cell in excel by excel formula -

Image
if lets define cell "b6" name value_date how can cell address "b6" excel formula ? if "define cell b6 value_date" mean create named range refers b6 , has range name "value_date", can use formula return address of named range: =cell("address",value_date) be aware if named range contains more 1 cell, formula return address of top left cell of range. in screenshot below, cell c6 has formula per above. edit after comment: if range name stored text in cell, can use indirect() function evaluate cell text range. =cell("address",indirect(a1)) to row of value_date via text in cell a1, use =row(indirect(a1))

Add a row similar to previous row in my webgrid in asp.net mvc -

i facing issue adding new row webgrid. webgrid data has dropdownlist in each column. when click button add new row must repeat same format of row. pasting webgrid code here. please me im new asp.net mvc <div id="grid1"> @wg1.gethtml( tablestyle: "gridtable", headerstyle: "gridhead", rowstyle: "gridrow", footerstyle: "gridfooter", alternatingrowstyle: "gridaltrow", htmlattributes: new { id = "tablegrid" }, columns: wg1.columns( wg1.column("condition", format: @item => html.dropdownlist("condition", (ienumerable<selectlistitem>)model.sourcetablemodel[0].condition, "select condition", new { style = "width:100px", @class = "condition" })), wg1.column("sourcetable1", format: @item => html.dropdownlist("sourcetable1", (ienumerable<selectlistitem>)model...

How to start or stop IIS and also a Windows Service in remote machine using C# -

getting exception code... eventhough i've administrator privileges in remote machine class program { static void main(string[] args) { var sc = new system.serviceprocess.servicecontroller("w3svc", "10.201.58.114"); sc.start(); sc.waitforstatus(system.serviceprocess.servicecontrollerstatus.running); sc.stop(); sc.waitforstatus(system.serviceprocess.servicecontrollerstatus.stopped); } } exception : an unhandled exception of type 'system.invalidoperationexception' occurred in system.serviceprocess.dll additional information: cannot open service control manager on computer '10.201.58.114'. operation might require other privileges. are machines in same domain? if not administrator on machine1 not equivalent administrator on machine2, problem. one possibility need grant access user - on remote machine - stop , start s...

mysql - SQL request using left join -

i have 2 tables. table : (id, type, ...) here id primary key table b : (id, timestamp, old_type, new_type, ...) here id not primary key i want make sql request return such ids each a.type not same last (by timestamp) b.new_type. is helpful nikita? select a.* a a.type!= ( select b.new_type b b order `timestamp` desc limit 1 )

php - Apple Push notifications working sometimes but not always -

i using php in backend send apple push notification. receiving notifications not. i know simple code use, if there other ways send notifications. cant understand why not delivering , does. ps: using production build function sendpush($user_id,$message,$video_id,$not_type,$devicetoken) { $passphrase = 'xxxxx'; $ctx = stream_context_create(); stream_context_set_option($ctx, 'ssl', 'local_cert', 'xxx.pem'); stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase); $fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, stream_client_persistent, $ctx); if (!$fp) exit("failed connect: $err $errstr" . php_eol); $body['aps'] = array( 'alert' => $message, 'badge' => '1', 'sound' => 'default'); $body['payload'] = array( 'type' => $not_type, 'user_id' ...

PHP Header doesn't work in web expressions 4 -

i using header redirect page: ob_start(); header('location: index.php'); it working fine when open page directly browser or other editor. doesn't works when open through microsoft expression web 4, editor. try this: in site settings dialog box, on preview tab, select use microsoft expression development server, , select php , asp.net web pages. by default, expression web locates php-cgi.exe file installed @ c:\php or c:\program files\php. if installed php in different location, or if text box under path php executable previewing php pages in website empty, under path php executable previewing php pages in website, click browse, locate , select php-cgi.exe, , click ok.

java - How to mock jdbc connection and resultSet using Mockito in TestNG -

i have write unit tests have problem mocking resultset , jdbc connection . i have method: @test public void test3() throws sqlexception, ioexception { connection jdbcconnection = mockito.mock(connection.class); resultset resultset = mockito.mock(resultset.class); mockito.when(resultset.next()).thenreturn(true).thenreturn(true).thenreturn(true).thenreturn(false); mockito.when(resultset.getstring(1)).thenreturn("table_r3").thenreturn("table_r1").thenreturn("table_r2"); mockito.when(jdbcconnection .createstatement() .executequery("select name tables")) .thenreturn(resultset); //when list<string> nameoftableslist = null; try { nameoftableslist = helper.gettablesname(jdbcconnection); } catch (sqlexception e) { // todo auto-generated catch block e.printstacktrace(); } //then assert.assertequals(nameoftableslist.size(), 3); } ...

Declare long list of variables quickly using Javascript without arrays? -

i know can use arrays there way declare multiple variables - lets 50 using loop , integer @ end of each variable going 1 every time. <!doctype html> <html> <body> <h1>javascript variables</h1> <p id="demo"></p> <script> var price1 = 5; var price2 = 6; var price3 = 7; var price4 = 8; var price5 = 4; var price6 = 1; var price7 = 9; var price8 = 8; var total = price1 + price2 + price3 + price4 + price5 + price6 + price7 + price8; document.getelementbyid("demo").innerhtml = "the total is: " + total; </script> </body> </html> i know can use arrays yes. , absolutely should use arrays purpose. designed for. is there way declare mutiple variable quickly only if create global variables. globals awful . window["price" + i] = somevalue;

python - Removing old elements from the time-ordered list -

let's have list l each element has attribute time stores float representing how many seconds past benchmark point. whenever event happens, remove list elements happened more t seconds before event, is l = [x in l if x.time > current_time - t] which seems slow way things. how can done faster? elements ordered here time, thought of finding first element not satisfy condition, e.g. for i, x in enumerate(l): if x.time > current_time - t: break l = l[i:] perhaps there beter way? you can use deque collections . gives o(1) complexity remove element head of list. since elements sorted time , oldest in head of list can remove elements 1 one.

Launch application passing parameters service android -

please imagine application closed , created new thread in service. didn't stop service. question 1: show dialog or notification service , clicking results in launch of application using parameters passed service android. question 2: else can display service class except notifications.

c# - Windows Phone Contacts and Date Modified -

is there way can know last modification date of contact or when added ? because in application need example synchronize , newly added contacts , that. isn't there unique identifier contact or @ least account ? there no unique identifier , no properties modified date or creation date. i suspect intention try , protect user privacy discouraging building of apps track contact information. the best can done use combination of fields unlikely change (i.e. name & dob) , use these identifying factor. store hash of information against id , if hash doesn't match when checked in future you'll know has changed.

date - PHP check if two Datetimes are not on the same calendar day -

i have 2 datetimes (the dates being $vars) $starttime = \datetime::createfromformat('y/m/d h:i', '2015/01/01 23:00'); $endtime = \datetime::createfromformat('y/m/d h:i', '2015/01/02 01:00'); i struggle (possibly pretty) simple problem: how determine if 2 dates on different calendar days? i cannot < 2015/01/01 22:00 < 2015/01/01 23:00 true. can not this: $diff = $starttime->diff($endtime); $days = $diff->format('%d'); echo $days; as gives me 0 . this gives me idea how it, javascript, equivalent php? //update $startdate = $starttime->format('y/m/d'); $enddate = $endtime->format('y/m/d'); $diffdates = $startdate->diff($enddate); $daysdiff = $diffdates->format('%d'); echo $daysdiff; i think might right approach now, comments, error: call member function diff() on string //update clarification i'm trying do i want have difference in days, above '...

apache - HTTP Status 404 - /ks-with-rice-bundled/kew/ActionList.do -

on front end below screen comes when enter kuali student login ui admin/admin account. http status 404 - /ks-with-rice-bundled/kew/actionlist.do type status report message /ks-with-rice-bundled/kew/actionlist.do description requested resource not available. this error in log file: 192.168.0.134 - - [21/jan/2016:15:33:00 +0530] "post /ks-with-rice-bundled-2.0.3-cm/org.kuali.student.lum.lu.ui.main.lummain/rpcservices/serverpropertiesrpcservice http/1.1" 200 46 192.168.0.134 - - [21/jan/2016:15:33:00 +0530] "post /ks-with-rice-bundled-2.0.3-cm/org.kuali.student.lum.lu.ui.main.lummain/rpcservices/securityrpcservice http/1.1" 200 21 192.168.0.134 - - [21/jan/2016:15:33:00 +0530] "post /ks-with-rice-bundled-2.0.3-cm/org.kuali.student.lum.lu.ui.main.lummain/rpcservices/metadatarpcservice http/1.1" 200 4745 192.168.0.134 - - [21/jan/2016:15:33:00 +0530] "post /ks-with-rice-bundled-2.0.3-cm/org.kuali.student.lum.lu.ui.main.lumma...

PHP script to show when a store is open -

i'm trying build php script when store opened show words "is open" , when it's closed it'll show "is closed" based on timezone , hours. can't seem work, found script doesn't work properly.. should work on dutch timezone.. +1 amsterdam.. can aid me? i'd appreciate help! script: <?php $schedule[0] = "700-1730"; $schedule[1] = "700-1730"; $schedule[2] = "700-1730"; $schedule[3] = "700-1730"; $schedule[4] = "10:00-17:30"; $schedule[5] = "700-1300"; $schedule[6] = "0"; $today = $schedule[date('w')]; list($open, $close) = explode('-', $schedule); $now = (int) date('gi'); $state = 'is geopend.'; if ($today[0] == 0 || $now < (int) $today[0] || $now > (int) $today[1]) { $state = 'is gesloten.'; } ?> <?php echo $state;?> the colon causing bit of problem can remove quick str_replace(); instead of $s...

c# - Convert Word document to pdf byte array in memory -

i need open microsoft word document, replace of text convert pdf byte array. have created code involves saving pdf disk , reading bytes memory. avoid writing disk not need save file. below code have done far... using system.io; using microsoft.office.interop.word; public byte[] convertwordtopdfarray(string filename, string newtext) { // temporary path save pdf string pdfname = filename.substring(0, filename.length - 4) + ".pdf"; // create new microsoft word application object , open document application app = new application(); document doc = app.documents.open(docname); // make necessary changes document selection selection = doc.activewindow.selection; selection.find.text = "{{newtext}}"; selection.find.forward = true; selection.find.matchwholeword = false; selection.find.replacement.text = newtext; selection.find.execute(replace: wdreplace.wdreplaceall); // save pdf disk doc.exportasfixedformat(p...