Posts

Showing posts from February, 2012

c++ - OpenGL fixed spot map glitch -

i developed game using opengl , c++, works fine glitch need fix: when move camera around (using mouse) map not remain in fixed spot. square (gl_quad) draw in front of me. this example of glitch: video this drawing code of square if needed texture = scene->gettexture("map_papyrus.png"); glblendfunc(gl_src_alpha, gl_one_minus_src_alpha); glenable(gl_blend); gluseprogram(this->shader->getres()); glactivetexture(gl_texture0); glint texture_location = glgetuniformlocation(this->shader- >getfragment(), "color_texture"); gluniform1i(texture_location, texture_location); glbindtexture(gl_texture_2d, this->texture->getres()); glbegin(gl_quads); float size = .5f; float offsetx = 0.0f; float offsety = 0.0f; if (set->easymode) { size = .2f; offsetx = 0.8f; offsety = 0.35f; } gltexcoord2f(0,0); glvertex2f(-size + offsetx, -size + offsety); gltexcoord2f(1, 0); glvertex2f(size + offsetx, -size +offsety);

c - Calling readline()'s Tab Completion Directly -

i know if want tab completion can use char *readline (const char *prompt); and i'll tab completion while it's running, if have string want completed? there specific function in readline library can call directly , send string parameter have run tab completion on it? i've read through lot of source code of complete.c find main function send string no luck. i don't know c side api lives, bash side calling of stuff, compgen can accept "partial" input. the main problem "partial" input typically provided shell scripts located in /usr/share/bash-completion/completions/"program", there chance seek not "c api" output of 1 or more bash scripts.

SIP Publish event -

i'm newbie sip. i send whole address book of registered sip user using sip message ( publish ) i not understand event package should use. --> event package list can me? riccardo nb: i'm writing handle sip messages... i not aware of standardized event package purpose. sip publish used publish event state (like presence or dialog state) entity in turn composes state , possibly maintains subscriptions other entities. is necessary use sip purpose? sip not meant content delivery protocol. sounds more job http or webdav me.

collections - Scala unFlatMap -

i perform unflatmap. lets have stream: stream("|","a","d","a","m","|","j","o","h","n", ...) stream infinite. convert to: stream("adam", "john", ...) ofcourse example. in general perform operation on elements separated delimiter, generic signature be: def unflatmap[b](isseparator:a => boolean)(group:seq[a] => b):traversableonce[b] how in clean , memory efficient way? you this: def groupstream[a, b](s: stream[a])(isseparator: => boolean)(group: seq[a] => b): stream[b] = group(s.takewhile(!isseparator(_)).tolist) #:: groupstream(s.dropwhile(!isseparator(_)).drop(1))(isseparator)(group) or if want easier read more verbose version: def groupstream[a, b](s: stream[a])(isseparator: => boolean)(group: seq[a] => b): stream[b] = { def isnotseparator(i: a): boolean = ! isseparator(i) def dogroupstream(s: stream[a]): stream

datetime - Algorithm to estimate total active time from timestamps -

say have a series of timestamps (from visitor impressions), , looks (omitting dates): 01:02:13 01:03:29 01:04:34 02:19:29 09:45:10 09:46:20 ..... in above case, i'd want sum time passed first 4 timestamps (1 2am), , separate them 9am events. is there clever way estimate combined active time, other utilizing timeout (say 300+ seconds timeout indicates new session). if not, what's standard / timeout use?

javascript - Lodash get repetition count with the object itself -

i have array of objects like: [ { "username": "user1", "profile_picture": "testjpg", "id": "123123", "full_name": "user 1" }, { "username": "user2", "profile_picture": "testjpg", "id": "43679144425", "full_name": "user 2" }, { "username": "user2", "profile_picture": "testjpg", "id": "43679144425", "full_name": "user 2" } ] i want get: [ { "username": "user1", "profile_picture": "testjpg", "id": "123123", "full_name": "user 1", "count": 1 }, { "username": "user2", "profile_picture": "testjpg", "id": "43679144425", "full_name": "user 2", "count": 2 } ] i've

the output of re.split in python doesn't make sense to me -

print (re.split(r'[a-fa-f]','finqwenlaskdjriewasfsdfddsafsafasa',re.i|re.m)) print (re.split(r'[a-fa-z]','finqwenlaskdjriewasfsdfddsafsafasa',re.i|re.m)) print (re.split(r'\d*','sdfsfdsfds123212fdsf2')) print (re.split(r'\d','sdfsfdsfds123212fdsf2')) print (re.split(r'\w+','dsfsf sdfdsf sdfsdf sfsfd')) ['', 'inqw', 'nl', 'sk', 'jri', 'w', 's', 's', '', '', 'dsafsafasa'] ['', 'inqw', 'nl', 'sk', 'jri', 'w', 's', '', '', '', 'ddsafsafasa'] ['sdfsfdsfds', 'fdsf', ''] ['sdfsfdsfds', '', '', '', '', '', 'fdsf', ''] ['', ' ', ' ', ' ', ''] i think output here weird. pattern split string turned '' in

ios - Store Array into NSUserDefaults -

i've got small problem permanently storing array using nsuserdefaults. extract of viewcontroller.m @property (strong, nonatomic) nsmutablearray *locationarray; - (ibaction)onaddclick:(id)sender { nslog(@"onaddclick"); cllocationdegrees lat = self.mapview.userlocation.location.coordinate.latitude; cllocationdegrees longi = self.mapview.userlocation.location.coordinate.longitude; cllocation *currentlocation = [[cllocation alloc] initwithlatitude:lat longitude:longi]; [self.locationarray addobject:currentlocation]; nsdata *data = [nskeyedarchiver archiveddatawithrootobject:self.locationarray]; [[nsuserdefaults standarduserdefaults] setobject:data forkey:@"locationdata"]; [[nsuserdefaults standarduserdefaults] synchronize]; } and in locationtableviewcontroller.m want retrieve array: nsdata* data = [[nsuserdefaults standarduserdefaults] objectforkey:@"locationdata"]; self.locationarray = [nskeyedunarchi

rust - Can the compiler tell when a `break` is never reached -

i have code: fn make_guess() -> u32 { loop { let mut guess = string::new(); io::stdin().read_line(&mut guess) .ok() .expect("failed read line"); match guess.trim().parse() { ok(num) => return num, err(_) => { println!("please input number!"); continue; } }; break; } } when run code, compiler complains about: expected `u32`, found `()` seemingly break; results in returning void value. however, there no way break; reached because of return , continue . in fact, if remove break; works fine. is bug in compiler or intended reason? a loop expression doesn't contain break expression evaluates ! (i.e. diverges), compatible types. fn main() { let _x: u32 = loop {}; // compiles } on other hand, loop break returns () , compatible () type. fn main() { let _x: u32 = loop {

c++ - Union float and int -

i'm little bit confused. during development of 1 function based on predefined parameters, pass sprintf function exact parameters needed based on type, found strange behaviour ( "this %f %d example", typefloat, typeint ). please take @ following stripped working code: struct param { enum { typeint, typefloat } paramtype; union { float f; int i; }; }; int _tmain(int argc, _tchar* argv[]) { param p; p.paramtype = param::typeint; p.i = -10; char chout[256]; printf( "number %d\n", p.paramtype == param::typeint ? p.i : p.f ); printf( "number %f\n", p.paramtype == param::typeint ? p.i : p.f ); return 0; } my expected output printf( "number %d\n", p.paramtype == param::typeint ? p.i : p.f ); number -10 but printed number 0 i have put breakpoint after initialization of param p, , although p.paramtype defined typeint , actual output if -10.0000. checking p.f gives undefined value expected, , p.i shows -10 ex

linux kernel - Getting a user ID and a process group ID from a task_struct and a pid_namespace -

i'm trying modify linux kernel , need user id , process group id task_struct , pid_namespace . although searched definitions in source code, couldn't find global variables or functions (maybe missing because of lack of comments in codes) access them. is there method inside kernel space since can not use user-space functions getuid() , etc.? you should able use task_struct->cred->uid or task_struct->real_cred->uid . being said, have not tested , cursory reading of lxr (include/linux/sched.h line 1508 , include/linux/cred.h line 127). if want pgid, try pid_vnr(task_pgrp(task_struct)) . code kernel/sys.c line 990.

python - simple-salesforce not recognizing custom object -

i using simple_salesforce , records of custom object called "ser__condition__c". know fact that name because got list of table names our administrator. "api" instance of "simple_salesforce.salesforce". command i'm executing: pprint(api.query('select id ser__condition__c')) which returns error: file "path\to\lib\simple_salesforce\api.py", line 698, in _exception_handler raise exc_cls(result.url, result.status_code, name, response_content) simple_salesforce.api.salesforcemalformedrequest: malformed request https://xxx.salesforce.com/services/data/v29.0/query/?q=select+id+from+ser__condition__c. response content: [{'message': "\nselect id ser__condition__c\n ^\nerror @ row:1:column:16\nsobject type 'ser__condition__c' not supported. if attempting use custom object, sure append '__c' after entity name. please reference wsdl or describe call appropriate names.", 'errorcode'

css - White bar between my nav bar and main text? -

after looking on stackoverflow long not find answer question, that's why asking instead! there's strange white part between navigation bar , main container, tested typing under bar this code: body, html { width: 100%; height: 100%; overflow: hidden; } body { background-color: gray; } #wrapper { margin: 32px 160px 0 160px; background-color: white; height: 90%; } #nav { background-color: #48d1cc; margin: 0; padding: 0; } #nav ul li { margin: -7px 4px 1px 0; background-color: #48d1cc; width: 19.5%; height: 42px; display: inline-block; text-decoration: none; text-align: center; color: black; } #nav { line-height: 42px; font-family: arial, serif; font-size: 20px; } #nav ul li:hover { background-color: #40e0d0; } #right { margin: 0; width: 15%; height: 10px; color: black; } <!doctype html> <html lang="en"> <head> <meta charset="utf-8"

python - How to redirect back to my app page from github -

i writing view in django take user github , access of repositories , all. import requests def authenticated_user(request): if request.method == 'get': req = requests.get('https://github.com/login/oauth/authorize', params = { 'client_id': 'something', 'redirect_uri': 'localhost:8000/app/', 'scope': 'user,public_repo,user:email.user:follow', } ) content = req.content return httpresponse(content) this taking me login page problem when logged in, redirects me http://localhost:8000/session instead of http://localhost:8000/app/ . tried also req = requests.get('https://github.com/login/oauth/authorize?client_id=something&redirect_uri=localhost:8000/app&scope=something,something but getting same result. not getting what's problem is. please me. , want know how use "code" oauth2 after logging in.

java - Strange behavior of graph stream -

i developing application using graphstream library. when using standard viewer of library every thing normal (click inside node manipulate it). when embedding in application, act strange. manipulate node, have click outside node control of it. i think has mouse events. how solve this? edit i have solved partially following change: had jsplitpane containing jpanel. later containing view graphstream library. removed jpanel , put view graphstream library directly jsplitpane. but still dont know why first solution did not work

Testing for the first weekday of the month in PHP -

i'm working on scheduling function handle repeating events in application. 1 option 'every first weekday' (of month). have function working, i'm afraid may not using efficient method , hoping input. i'm using php 5.5. code have: function isfirstweekday($dateobject){ $daytotest = $dateobject->format('l'); $monthtotest = $dateobject->format('f y'); $priorday = clone $dateobject; $priorday->modify('- 1 day'); $weekdaylist = array("monday", "tuesday", "wednesday", "thursday", "friday"); //return false if it's not weekday if (!in_array($dateobject->format('l'), $weekdaylist)) { return false; } //make sure weekday first of name in month if ($dateobject->format('y-m-d') !== date('y-m-d', strtotime("first $daytotest of $monthtotest"))) { return false; } //make sure day before not weekday in same month if (in_a

javascript - Error in using Typed.js Typewriter effect -

i creating typing effect using html5 , css ,javascript,typed.js. code= <!doctype html> <html> <head lang="en"> <meta charset="utf-8"> </head> <body> <p class ="typewirter_effect"></p> <script src="jquery-ui.min.js>"></script> //this downloaded jquery's website n pasted in same folder <script src="jquery.js"></script> //this downloaded jquery's website n pasted in same folder <script src="typed.min.js"></script> //this downloaded typed.js main website n pasted in same folder <script> $(function() { $("#typewirter_effect").typed({ strings: ["want learn coding ?", "want learn c++","java","python"], typespeed: 0, loop: true, backspeed: 30, showcursor: true, backdelay: 500, startdelay: 1

java - Is there a way to change method parameter list intellij? -

to generalized, let's take example this. i have method this. public void mymethod(int param1, string param2){ //do } and want change this. public void mymethod(int param1, string param2, string param3){ //do } is there preferred way intellij without breaking usages? you can followings intellij. with refactor -> change signature menu, can: change method name, return type , visibility scope. add new parameters , remove existing ones. note can add parameter using dedicated extract parameter refactoring. reorder parameters. change parameter names , types. add , remove exceptions. propagate new parameters , exceptions through method call hierarchy. to go refactor -> change signature menu in editor, place cursor within name of method signature want change. 1 of following: press ctrl + f6 . choose refactor | change signature in main menu. select refactor | change signature context menu (right-click). for more, please have @ h

java - UnfoldingMaps tutorial wrong -

to below code run, need either: comment out maputils.createdefaulteventdispatcher(this, map); or change map type unfoldingmap[] map; it seems me tutorial wrong in regard. error see in eclipse is: the method createdefaulteventdispatcher(papplet, unfoldingmap[]) in type maputils not applicable arguments (samplemapapp, unfoldingmap) can suggest me how can fix this? import processing.core.papplet; import de.fhpotsdam.unfolding.unfoldingmap; import de.fhpotsdam.unfolding.providers.abstractmapprovider; import de.fhpotsdam.unfolding.providers.google; import de.fhpotsdam.unfolding.geo.location; import de.fhpotsdam.unfolding.utils.maputils; public class samplemapapp extends papplet { unfoldingmap map; public void setup() { abstractmapprovider provider = new google.googleterrainprovider(); size(800, 600, p2d); map = new unfoldingmap(this, 50, 50, 500, 350, provider); // show map around location in given zoom level. map.zoomandp

objective c - May I declare the *shape outside the for loop? -

nsmutablearray *shapes = [[nsmutablearray alloc] init]; (nsdictionary *object in array) { nsstring *type = [object objectforkey:@"type"]; shapefactory *shape = [[[shapefactory alloc] init] shapewithtype:type dictionary:object]; [shapes addobject:shape]; } self.shapes = shapes; i want know if can declare variable *shape outside loop , still work first of: yes, roee84 said, valid syntax , can that. however, fact have (deducing method name) factory class pattern here , type of created shape seems defined special argument, wonder why you're using shapefactory . why not use id ? array won't care object , it's better not pretend objects of same type factory class object. that being said, code correct. of course, can also declare shape (the * considered part of type, btw) outside of loop. don't need declare local mutable array (assuming property mutable array). i'll use id in example illustrate said above: self.shapes = [[nsmuta

Android - onActivityResult from DialogFragment -

i have webview app , want upload image files camera of gallery web page. i implemented camera upload i'm trying implement dialogfragment let user choose upload file. the code in fragment , can't pass camera results onactivityresult function, dialogfragment class`public static class editnamedialog extends dialogfragment { private button buttoncamera; public file createimagefile() throws ioexception { // create image file name string timestamp = new simpledateformat("yyyymmdd_hhmmss").format(new date()); string imagefilename = "jpeg_" + timestamp + "_"; file storagedir = getactivity().getexternalfilesdir(environment.directory_pictures); file image = file.createtempfile( imagefilename, /* prefix */ ".jpg", /* suffix */ storagedir /* directory */ ); // save file: path use action_view intents mcurren

php - Why isn't my contact form using PHPMailer working? -

i made contact form send information email, , whenever submit form, redirected php file (mywebsite.com/contact.php) , shown internal server error (the 500 kind). did wrong? because have html , php code in different files? included contact form in case relevant. <?php if(isset($_post['submit'])) { $message= 'full name: '.$_post['name'].'<br/> comments: '.$_post['comments'].'<br/> email: '.$_post['email'].' '; require 'phpmailer/phpmailerautoload.php'; $mail = new phpmailer; //$mail->smtpdebug = 3; // enable verbose debug output $mail->issmtp(); // set mailer use smtp $mail->host = 'smtp.mail.yahoo.com'; // specify main , backup smtp servers $mail->smtpauth = true; // enable smtp authentication $mail->username = 'aroncea@yahoo.com'

android - Why onDestroy recreates the Fragments when Activity recreate after process killed -

i'm trying understand happens fragments when activity recreates after process gets killed , activity destroy . scenario : have application multiple activities , first activity loads configuration , used other activities. on low memory when application on background ,the process gets killed . after process killed if select application (from recent apps) , activity recreating. current activity when recreates try access configuration , app crashes. so , decided finish activity if configuration not loaded on activity recreate , , navigate first activity loads configuration. resolves of problems , if activity has fragment , when ondestroy happens on recreate , app crashes ondestroy trying recreate fragments. at android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:973) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1138) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1120) @ android.suppo

Bulk rename files on media device matched with regex on Windows -

i feel on linux machine bash, don't have enough experience batch it. basically, lot of music files on phone start track number : 01 - song 02 - song 03 third song (different format) i can of files regex match: dir /b | findstr /i "^[0-9]+ .*" and i'm assuming should assign these values variable. can loop on them doing for %filename in %var ren file [something here] the thing have issues getting onto media device (how windows handle under hood?) , removing prefix, while dealing 2 possible formats (detecting '-' shouldn't hard). able sed, don't know batch equivalent. i've been meaning while anyway. there's handy perl rename script written years ago larry wall use rename files via regexp. since have need perl in windows, , installing perl 1 script seems waste, thought it'd idea rewrite prename using native windows scripting languages. hopefully if there bugs, won't debilitating. didn't test script

python - Command 'sbt assembly' taking long to build Spark -

i have installed pyspark in pc. have used command 'sbt assembly' build it's showing progress more hour in terminal didn't complete process. be patient spark take time compile , build source manually.

c# - named system mutex not recognized -

i trying named system mutex approach synchronize 2 processes- a c# windows service a desktop c# app when mutex created, process didn't create mutex doesn't seem detect existing mutex. below in more detail: windows service responsible creating mutex(no prefixes-global/local etc. normal named system mutex) follows: mutex mymutex= null; try { mymutex= mutex.openexisting(mymutexname); } catch (waithandlecannotbeopenedexception x) { //doesn't exist. try { this.getlogger().info("create mutex"); bool creatednew = false; new mutex(false, mymutexname, out creatednew); if (!creatednew) throw new exception("unable create mutex"); } catch (exception ex) { this.stop(); } } catch (exception x) {

Unable to load rss feeds from packaged chrome application -

i trying rss feed packaged chrome application getting error below. undefined angular.js:8642 refused load script ' https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=50&callback=a ….callbacks._0&q=http%3a%2f%2...%2frss%2fheadlines.php' because violates following content security policy directive: "default-src 'self' blob: filesystem: chrome-extension-resource:". note 'script-src' not explicitly set, 'default-src' used fallback. what doing wrong

vb.net - SSRS code to determine distinct count of a lookupset -

i trying create custom code, coupled ssrs expression, allow me display number of distinct values in lookupset array dataset ("faults"). expression in target dataset ("stations") this: =code.countdistinct(lookupset(fields!stationnumber.value,fields!opid.value, fields!opid.value, "faults")) unfortunately can't seem countdistinct function work. have functions allow me determine max, min, , average of lookupset, can't find me determine distinct count of items in lookupset. i not vb expert, have been able create other simple functions little trouble. can't figure out countdistinct function, though. any appreciated. perhaps there's better way find distinct count , reference in dataset in ssrs, besides using custom code? if so, please advise. give try in code report. modified code little other answer return integer count of distinct values. reference. public shared function countdistinct(m_array object()) integer system

How to get the row content of an Apexgrid in VB6 using Testcomplete? -

we using testcomplete automate desktop application written in vb6 . we stuck in getting row content of apex grid wndclass tg60.apexgirdoledb32.20 . there some information in link not sufficient. select row based on content instead of index number. please can help? there native vb object properties used cell text of selected column , row. sub clicktherowusingtext(rowtext, rowindex) dim textfromcell, rowindex, rowcount, rowcount = tgridnew.approxcount i=1 rowcount-1 textfromcell = tgridnew.columns.item(0).celltext(rowindex) if textfromcell = rowtext 'call here methods given in above links exit end if next end sub

javascript - Get AngularJS object property name in the markup -

let's have object: $scope.golovkin = { id:12, like:0, dislike:0, url:"https://twitter.com/gggboxing" }; and in view have button: <input type="button" value="like" ng-click="incrementlikes(golovkin)" /> how replace value of button property name of $scope.golovkin.like string? <input type="button" ng-model="golovkin.like" ng-click="incrementlikes(golovkin)" />

jsp - How to pass scriptlet value to text of combobox? -

i want pass value of name text combobox. getting value of name database. { string name=resultset.getstring(1); } thanks. here why should use jstl jsp scriptlets . should start use jstl . i've given scriptlet code here. can iterate resultset between select tag , set values option. <select name="username"> <% while(resultset.next()){ %> <option value="<%=resultset.getstring(1)%>"><%=resultset.getstring(1)%></option> <% } %> </select>

VBA Excel extracting data from website with changing date in URL -

i extremely new vba appreciated. trying extract data website https://www.census.gov/construction/bps/txt/tb3u201601.txt . 201601 in url represents jan 2016. create program cycles through months until 2003 , puts data in excel spreadsheet. far have written isolated date (below) cannot figure out how have loop through dates need. again. sub macro2() ' ' macro2 macro ' ' dim str1 string dim str2 string dim str3 string dim str string str1 = "url;https://www.census.gov/construction/bps/txt/tb3u" str2 = "201601" str3 = ".txt" str = str1 & str2 & str3 activesheet.querytables.add(connection:= _ str, destination _ :=range("$a$2")) .name = "tb3u201601_4" .fieldnames = true .rownumbers = false .filladjacentformulas = false .preserveformatting = true .refreshonfileopen = false .backgroundquery = true .refreshstyle = xlinsertdeletecells .savepassword = false .saved

c - struct array element initialization -

how may init below structure these values: struct test_str { unsigned char add[6]; unsigned int d; unsigned char c; }my_str; i tried resulted in error: struct test_str { unsigned char add[6]; unsigned int d; unsigned char c; }my_str {.add[0]=0x11,.add[0]=0x22,.add[0]=0x33, .add[0]=0x44,.add[0]=0x55,.add[0]=0x66, .d=0xffe,.c=10}; in modern c++11 or later (as question tagged c++ only) have called aggregate initialization . works this: struct test_str { unsigned char add[6]; unsigned int d; unsigned char c; } my_str { {0x11, 0x22, 0x33, 0x44, 0x55, 0x66}, 0xffe, 10 }; int main() {} live on coliru the inner pair of braces not necessary, prefer sake of clarity. ps: should hands on introductory c++ book learn basics of language. edit in c (as re-tagged question) , pre c++11, need equal sign. furthermore, in c inner braces not optional: struct test_str { unsigned char add[6]; unsigne

AngularJS Select list has a blank item -

i have few select lists on page 1 of them works fine rest of them have blank item @ top of options list. this works <td> <select data-ng-model="c.resultoptionid" ng-change="checkresult(c)"> <option value="" selected>--select option--</option> <option data-ng-repeat="opt in c.resultoptions" value="{{opt.value}}">{{opt.text}}</option> </select> </td> this has blank item <td> <select data-ng-model="c.equipmentid"> <option value="" selected>--select equipment--</option> <option data-ng-repeat="eq in c.equipment" value="{{eq.value}}">{{eq.text}}</option> </select> </td> the html generated select list item is <td> <select data-ng-model="c.equipmentid" class="ng-pristine ng-valid ng-not-empty ng-touched">

newline - sed: Why does command q add a new line? -

suppose following command echo -en "abc1\ndef2\nghi1" | sed -n 'p; d;' in case output same without sed @ all. last line still has no new line character. next command echo -en "abc1\ndef2\nghi1" | sed -n '$! {p; d;}; /1$/ {s/1$//; p; d;}' sed prints last line without modification. last line shortened 1 character. still there no new line character on last line. next command echo -en "abc1\ndef2\nghi1" | sed -n '$! {p; d;}; /1$/ {s/1$//; p; q1;}' ("d" replaced "q1" in last command block. same output before, time there additional new line character in last line. why? how fix? (for interested in intention command: given stdin, want scan last character, pass on stdin stdout without last character , set exit code based on character. there should no other modification. sed seems perfect, if there wouldn't newline problem sed -n ' $! {p; d;}; #print non last line, next cycle

In Python debugger pydb, how can I set breakpoing in a function in another module? -

i can use graphical debugger using - ddd --pydb script.py i can set breakpoints in current module or module using - b filename:linenumber . but how can set breakpoint @ function in "another" module? (if in current module can b funcname )

python 3.x - How do I match text location to randomly placed text on my Canvas? -

i have function: storeitems = random.sample(set(['sword','pickaxe','toothpick','hammer','torch','saw']), 5) #selects 5 random strings list. ^ xbase, ybase, distance = 300, 320, 50 i, word in enumerate(storeitems): canvas.create_text( (xbase, ybase + * distance), text=word, activefill="medium turquoise", anchor=w, fill="white", font=('anarchistic',40), tags=word) canvas.tag_bind('sword', '<buttonpress-1>', buysword) canvas.tag_bind('pickaxe', '<buttonpress-1>', buypick) canvas.tag_bind('toothpick', '<buttonpress-1>', buytooth) canvas.tag_bind('hammer', '<buttonpress-1>', buyhammer) canvas.tag_bind('torch', '<buttonpress-1>', buytorch) canvas.tag_bind('saw', '<buttonpress-1>', buysaw) which randomly selects list: storeitems[] , puts 5 of them on canvas

java - Issue with Struts2 Filter Exception -

working on simple web application @ moment , cant struts project work because of: severe: exception starting filter struts2 java.lang.instantiationerror: com.opensymphony.xwork2.util.finder.classfinder @ org.apache.struts2.convention.packagebasedactionconfigbuilder.findactions(packagebasedactionconfigbuilder.java:390) @ org.apache.struts2.convention.packagebasedactionconfigbuilder.buildactionconfigs(packagebasedactionconfigbuilder.java:347) @ org.apache.struts2.convention.classpathpackageprovider.loadpackages(classpathpackageprovider.java:53) @ com.opensymphony.xwork2.config.impl.defaultconfiguration.reloadcontainer(defaultconfiguration.java:274) @ com.opensymphony.xwork2.config.configurationmanager.getconfiguration(configurationmanager.java:67) @ org.apache.struts2.dispatcher.dispatcher.getcontainer(dispatcher.java:970) @ org.apache.struts2.dispatcher.dispatcher.init_preloadconfiguration(dispatcher.java:438) @ org.apache.struts2.dispatcher.dispatcher.init(dispatcher.java:482) @

botframework - Which bot framework to use (if any) for a Kik, Facebook, & Slack messaging bot using javascript? -

i'm building chatbot need launched on kik, facebook, , slack. i'm unsure of start in terms of using bot framework or whether should create custom myself. i don't believe need nlp. user going pushed down structured path, use buttons guide users next prompts , share user links , media. microsoft bot framework seems main framework should at, unclear me how useful if end wanting deliver responses custom each messaging platform. meaning, on facebook may want take advantage of custom feature have buttons or templates , on kik want take advantage of suggested keyboards. any suggestions or guidance appreciated. botframework translation you. write botframework schema , using buttons facebook , keyboards kik.

android - Radio Button setOnChangeListener not working inside fragment -

i want check whether radio button checked do. inside fragment not working cannot figure out because of why? if 1 can appreciate much! my fragment: public class onefragment extends fragment { radiogroup radiofanstatus; radiobutton radiobuttonon; radiobutton radiobuttonoff; view inflateview; tabdisplay tabdisplay; public onefragment() { // required empty public constructor } @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // inflate layout fragment inflateview=inflater.inflate(r.layout.fragment_one, container, false); radiofanstatus = (radiogroup)inflateview.findviewbyid(r.id.radioonoff); radiobuttonon=(radiobutton)inflateview.findviewbyid(r.id.radiofanon); radiobuttonoff=(radiobutton)inflateview.findviewbyid(r.id.radiofanoff); radiofanstatus.setoncheckedchangel

How to fetch data and pass. into form and response customername onkeyup or keydown json and php -

this mysql db connection.php <?php $conn = new mysqli("localhost", 'root', "", "laravel"); $query = mysqli_query($conn,"select * customers"); while ($result2=mysqli_fetch_assoc($query)) { $data[] = $result2['customername']; } echo json_encode($data); ?> the json not responding onkeyup or keydown displaying whole output. want display current related matched names on display. new json , ajax. think ajax , json both respond same. <form action=""> first name: <input type="text" id="txt1" onkeyup="showhint(this.value)"> </form> <p>suggestions: <span id="txthint"></span></p> <script> function showhint(str) { var xhttp; if (str.length == 0) { document.getelementbyid("txthint").innerhtml = ""; return; } xhttp = new xml

c# - LINQ IQueryable returning same rows with skip and take -

using mvc entity framework i'm calling function ajax passes in skip , take parameters. [httpget] public async task<actionresult> _viewmore( int take, int skip) { var c = await getcontent( take, skip); return view(c) } public async task<list<partialcontent>> getcontentforculture(int take, int skip) { return await contexthelper.searchcontent(take, skip); } public static async task<list<partialcontent>> searchcontent( int take, int skip) { try { using (var context = new context()) { var content = context.contententities.searchcontent(take, skip); var f = await content.select(s => new partialcontent { subtype = s.subtype, id = s.id, mainimage = s.mainimage, }).tolistasync(); return f; } } catch (exception ex) { // log.err(ex.message, ex); return null

interact.js - How to access Polymer functions from JS -

Image
sorry if comes out bit garbled, i'm not sure how ask question. what trying keep dom synced localstorage value, , updating localstorage value interact.js mouse event. currently, able set localstorage value, having problems updating dom. my current build within polymer framework, having trouble selecting shadow dom content. the dom tree looks like parent-element # shadow root el el div custom element el el here ways have failed solve problem. custom element in pure js, since not sure how wrap interact.js function in polymer: i tried directly accessing parent-element's shadow dom custom element in pure js. var shadowdomnode = document.queryselector('parent-element'); var dom_object_1 = shadowdomnode.queryselector('#dom_object_1'); dom_object_1.innerhtml = localstorage.dom_object_1; i tried selecting helper updatedom() function parent polymer element , running custom element's setter directly. if

Error while doing Salesforce Authentication from C# Client Application -

below complete code have written work login() salesforce authentication. but, getting error if execute code in .net client (console application). can please suggest me how solve problem. my onsite coordinator has confirmed fine long salesforce concerned. code private bool login() { string username = "kak.mca@gmail.com"; string password = "temp0r@ry"; string securitytoken = ""; string resultsessionid = string.empty; string resultserverurl = string.empty; binding = new sforceservice(); binding.timeout = 60000; loginresult lr; try { #region method1 //lr = binding.login(username, password); #endregion method1 #region method2 using(binding) { lr = binding.login(username, password); resultsessionid = lr.sessionid; resultserverurl = lr.serverur

ecmascript 6 - How call router navigate method from Angular 2? -

i use angular 2, systemjs , es6 (not typescript). what want? want navigate link route. i'm doing // route exam simple export let routes = [ {path: '', name: 'home', component: homecomponent, terminal: true}, {path: 'auth', name: 'auth', component: authcomponent} ] it works if use [routerlink]. , want programmatically use router this import { component } '@angular/core'; import { router, router_directives } '@angular/router'; @component({ selector: 'tf-main', directives: [router_directives], template: '<p>home</p><router-outlet></router-outlet>' }) export class homecomponent { static parameters() { return [[router]] } constructor(router) { this.router = router; // wrong way!!!! help!!!! this.router.navigatebyurl(['auth']); } } just this.router.navigate(['auth']); or this.router

Matching between two arrays in excel and then outputting a value -

screenshot so have situation want match values in a2:a4 values in b2:f4 , output values in b5:f5 in cell a5 (depending on column matched). in particular case, values in column match values in column e output in a5 should 1. want excel formula me (no vba). can kindly this. thanks in advance. b5 =if(a2=b2&a3=b3&a4=b4,1,0)

python mysql error in query -

i want generate dynamic table: columnames=[element[0] element in bufferdata['data'] ] index,element in enumerate(columnames): columnames[index]=re.sub("[(%./)-]","",element) tuple(columnames) querycreatetable='''create table test (id int auto_increment,name varchar(50),symbol varchar(10),sector varchar(50), %s float,%s float,%s float,%s float,%s float, %s float,%s float,%s float,%s float,%s float, %s float,%s float,%s float,%s float,%s float, %s float,%s float,%s float,%s float,%s float, %s float,%s float,%s float,%s float,%s float, %s float,%s float,%s float,%s float,%s float, %s float,%s float,%s float,%s float,%s float,

node.js - RxJs How to Observe object property change -

i'm running issue. have client instantiates has ready boolean property. want wait until switches true resolve promise. tried lot of different ways including while loop blocks thread without checking updates. here's attempt var startclient = function() { return new promise((resolve, reject)=> { var client = createclient(); while(!client.ready) {} resolve(client); }); }; my question is: there way use rxjs help.. maybe emit , event if ready property changed? below more pseudo code i'm trying do. var startclient = function() { return new promise((resolve, reject)=> { var client = createclient(); var emitter = observable.watch(client, 'ready'); emitter.on('ready', function(result) { if(result) resolve(client); }); }; any suggestions? thanks! if can, overwrite ready property on client trap assignments it, follows: // check if ready flag set.

asp.net mvc - What's the difference between using @Html.DisplayFor and just use @Model? -

this question has answer here: when should use html.displayfor in mvc 2 answers take account model class property partnername on it. in case looks these 2 code produce same results: @model.partnername @html.displayfor(m => m.partnername) is there advantages in using 1 against other? because first 1 way more cleaner. edit , clear i'm talking specific overload. when display value using @model.partnername places plain value html without surrounding markup. when use @html.displayfor(m => m.partnername) invoking displaytemplate render object. these displaytemplates contain markup make sure value displayed in way. can create custom displaytemplates can always, example, display strings inside fancy boxes borders , colors. check out article creating custom displaytemplates. http://www.codeguru.com/csharp/.net/net_asp/mvc/using-display-temp

image - MATLAB: layer detection, vector combination and selection by tortuosity/arclength -

Image
i have greyscale image similar 1 below have achieved after post-processing steps (image 0001). vector corresponding bottom of lower bright strip (as depicted in image 0001b). can use im2bw various thresholds achieve vectors in image 0002 (the higher threshold value higher tendency vector line blip upwards, lower threshold higher tendency line blip downwards)..and thinking of going through each vector , measuring arclength on increment (maybe 100 pixels or so) , choosing vector lowest arclength...and adding 100 pixel stretch final vector, creating frankenstein-like vector using straightest segments each of thresholded vectors.. should mention when there multiple straightish/parallel vectors, top 1 best fit. first off, there better strategy should employing here find line on image 0001? (this needs fast long fitting code wouldn't work). if current frankenstein's monster solution works, suggestions how best go this? thanks in advance image=im2bw(image,0.95); %or 0.85, 0.