Posts

Showing posts from April, 2015

java - How to add back button arrow functionality in navigation bar -

i beginner programmer , resent started android developing. watched many answers , couldn't find answer witch fit me. have added arrow button in action bar, couldn't figure out how add navigation first loaded screen. mainactivity.java public class mainactivity extends appcompatactivity implements navigationview.onnavigationitemselectedlistener { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar); actionbar actionbar = getsupportactionbar(); if (actionbar != null){ actionbar.setdisplayhomeasupenabled(true); actionbar.sethomebuttonenabled(true); } drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout); final actionbardrawertoggle toggle = new actionbardrawertoggle( this, drawer, toolbar, r.string.navigation_drawer

discrete mathematics - Floating point number and range of floating point numbers that can be represented by a string -

refer string of bits 010011110110 we assume when number stored floating point (real) number, 6 of 12 bits reserved mantissa (or significand) if string represents floating point number, (smallest) number? and find range (or interval) of floating point numbers represented same string. value=(-1)^s (1+m/26 )^{e-24} think need in order solve 1 of the, these last 2 questions have assessment due on thursday 28th, i've completed other questions , @ point in time have no idea if of them right , i'm stuck on these question. have no idea why have computer science class networking major it's killing me. since base 2 , mantissa 6 , assuming 12 digit precision, according wikipedia on floating point numbers , believe range 100000 * 2^011111 011111 * 2^011111 or rather -32*2^31 31*2^31, smallest value 1*2^100000 or rather 1*2^-32.

php - fetch only X Product Model via eager loading in a ManyToMany Product Category relationship -

i have manytomany relationship between category , product model. product model : class product extends model { protected $primarykey = 'product_id'; public function categories () { return $this->belongstomany('app\category', 'category_product', 'product_id', 'cat_id'); } } and category model : class category extends model { protected $primarykey = 'cat_id'; public function products (){ return $this->belongstomany('app\product','category_product','cat_id','product_id'); } } now , want fetch last 4(for example) products of each category. write : $categories = category::with([ 'products' => function($query){ $query->select('products.product_id')->orderby('created_at','desc')->take(4); } ])->get(); but not work , re

Using index.html as UI doesn't work with eventReactive Shiny R -

i've been struggling issue in last 2 days , nothing seems work me far. what want piece of code do: user click searchbutton, empty data frame created. eventreactive works fine me on normal ui.r when tried use index.html doesn't work. code below: server.r: new_search <- eventreactive(input$searchbutton, { search_term <<- input$searchtext test <- data.frame() }) index.html <!-- search bar --> <form class="sidebar-form"> <div class="input-group"> <input id="searchtext" type="text" class="form-control" placeholder="ask me anything.."> <span class="input-group-btn"> <button id="searchbutton" type="button" class="btn btn-flat action-button"> <i class="fa fa-microphone"></i> </b

javascript - Changing a background image of <body> (in CSS) depending on the season (Current Calendar Month) -

i'd change html background depending on date, i've written isn't working properly. can't find applicable examples , i'm struggling complete it. i want start of new season change background of html page altering image used in css file. javascript: var d = new date(); var day = d.getdate(); var month = d.getmonth(); if (month == <3 && month == 5) { document.background-image: url("springtree.jpg"); } else if (month == < 6 && month == > 8) { document.background-image: url("summertree.jpg"); } else if (month == < 9 && month == > 11) { document.background-image: url("autumntree.jpg"); } else (month == 12 && month == > 2) { document.background-image: url("wintertree.jpg"); css: div.body { background-image: url("summertree.jpg"); width: 640px; height: 1136px; background-repeat: no-repeat; background-attachment: fixed; backgr

spring - java.lang.NullPointerException at com.ibm.ws.webcontainer.filter.WebAppFilterManager.getFilterChainContents -

i have war application (spring + jsf1.2/richfaces + hibernate) running on was8.5 server, when try access http://localhost:9080/name_app/login.xhtml , java.lang.nullpointerexception coming server internal source, below log trace of error : [28/01/16 09:45:06:325 wet] ffdc exception:java.lang.nullpointerexception sourceid:com.ibm.ws.webcontainer.filter.webappfiltermanager.invokefilters -re probeid:1123 reporter:com.ibm.ws.webcontainer.filter.webappfiltermanagerimpl@9afb2765 java.lang.nullpointerexception @ com.ibm.ws.webcontainer.filter.webappfiltermanager.getfilterchaincontents(webappfiltermanager.java:775) @ com.ibm.ws.webcontainer.filter.webappfiltermanager.getfilterchain(webappfiltermanager.java:379) @ com.ibm.ws.webcontainer.filter.webappfiltermanager.dofilter(webappfiltermanager.java:931) @ com.ibm.ws.webcontainer.filter.webappfiltermanager.invokefilters(webappfiltermanager.java:1107) @ com.ibm.ws.webcontainer.webapp.webapp.handlerequest(webapp.java:3

java - Improving Intersection Algorithm -

i have algorithm build intersection of 2 sorted lists. if compare java.util.bitset in performance test, algorithm slow. public static list<integer> intersection(list<integer> list1, list<integer> list2) { int size1 = list1.size(), size2 = list2.size(); int capacity = size1 < size2 ? size1 : size2; list<integer> intersection = new arraylist<integer>(capacity); int i1 = 0, i2 = 0; while (i1 < size1 && i2 < size2) { if (list1.get(i1) < list2.get(i2)) i1++; else if (list2.get(i2) < list1.get(i1)) i2++; else { intersection.add(list2.get(i2++)); i1++; } } return intersection; } anyone sees improvement? thanks are inputs function of type arraylist ? if are, algorithmically there noth

JSON Parsing issue with PHP -

i'm attempting pull in data wowprogress api. want parse data online , decode them directly while posting them view. i'm still learning, seem having issues array. need help. $json = file_get_contents("http://www.wowprogress.com/guild/eu/twisting-nether/hellenic%20horde/json_rank"); if($json == false) { throw new exception("failed load infomation. check setup options"); } $result = json_decode($json, true); echo "<pre>"; foreach ($result["realm_rank"] $value) { print_r($value); } echo "</pre>"; but receive "invalid argument supplied foreach()" would love help. in advance! sorry english. english not native language. the $result['realm_rank'] string, not array. therefore, foreach on causing error. this error causes when either array not set, or blank or not array. <?php $json = file_get_contents("http://www.wowprogress.com/guild/eu/twisting-nether/hellenic%20hord

magento2 - How to find css file path in browser -

i working on theming part in magento2. whenever compile .less file, 2 css files created : styles-l.css styles-m.css whenever inspect element , try see css applied in browser, not able find css file path. mean, cannot know files css coming from. is there way find css file path? use firebug extension in firfox, inspect element describe, lastly copy either css path visible.

bash - Calculate foldersize exlude files hardlink -

i'm using bash script rsync create daily , weekly backups. how works in short: the script sets variables days , weeks. current day folder gets emptied: rm -rf /path/to/$currentday/* previous day content gets copied current day (hardlinks): cp -ral /path/to/$previousday/* /path/to/$currentday/ the script syncs changes made: rsync -tru --progress /path/to/source/* /path/to/$currentday/ this being pulled 1 storage device on wan. since company growing need monitor how data being sent on wan every time script runs. is there way me calculate $currentday folder , exclude files didn't change (still hardlinked)? or maybe add line script log files being sent? i've been searching internet unfortunately didn't find useful, try comes total size of folder, 2tb. did willing share me? i observed du has hability count size of hardlinks once. test steps: mkdir 1 2 cd 1 dd if=/dev/zero of=f1 bs=1024 count=1024 dd if=/dev/zero of=f2 bs=1024 count=2048 cd .

c# - Why can't I call ToString() on an interface? -

i've had different issues re-creating in sample console app, interested know what's going on. the original problem in code, have class called icat , class written in c# public interface icat { string tostring(catcolour colour); } in same assembly, in c#, there implementation: public class magiccat : icat { public string tostring(catcolour colour) { return $"i {colour} cat"; } } this compiles without problems. in assembly, written in vb.net, have code: dim mycat icat = getcat() dim result = mycat.tostring() ' error on line this gives compiler error saying argument not specified parameter 'colour' of 'function tostring(format addressformat) string'. i tried recreate in c# app, code: public class cat : ianimal { public string tostring(catcolour colour) { return $"i {colour} cat."; } //public string tostring() //{ // return "i cat.";

php - convert date format with utc -

this question has answer here: convert 1 date format in php 12 answers i want convert date format 'wed, 27 01 2016 00:00:00 est' '2016-01-27'.i got wrong value '1970-01-01' <?php date_default_timezone_set("europe/helsinki"); $var='wed, 25 11 2015 00:00:00 gmt'; echo $d=date('y-m-d',strtotime($var)); //date_rfc2822 ?> it means datetime string cannot recognised automatically. need specify format of input: echo date_create_from_format( 'd, d m y h:i:s e', // <== input format 'wed, 27 01 2016 00:00:00 est' // <== string )->format("y-m-d") // <== output format more formats here: http://php.net/manual/en/datetime.createfromformat.php

security - Firefox Scratchpad ' s javascript code has more privileges than a standar website javascript code? -

i've copy paste , run through scratchpad code form source code of website. want know if code has more privileges when runs through scratchpad of firefox or has same privileges when runs directly through webpage. before pasting on scratchpad firefox alerts message: scam warning: take care when pasting things don't understand. allow attackers steal identity or take control of computer . know there javascript exploits run through website but.. the message firefox seems like: "the javascript on scratchpad has more privileges javascript of webpage , attackers can steal without exploits, standar code" is true? the same code can act differently website , differently scratchpad in terms of security? or it's including inside html , safety measures has javascript inside website? why firefox alert on scratchpad done anyway visiting malicious webpage (potential javascript attack) ? by default, code running in scratchpad can javascr

php - Where to put a "common" controller (for admin/front catalogs) in MVC pattern -

in symfony 3 created 2 subfolders in "controller" folder: "admin" , "front", first 1 responsible administrative tasks, , second 1 for, well, displaying frontpage. i have "usercontroller", sits in "front" folder, because there methods "register" or "login" cannot in "admin" folder (because 1 must logged in access url) now want create possibility edit user details in admin panel. method called "edit" example. what's best way it? architectural pattern point of view? create usercontroller in "admin" folder. move existing usercontroller new folder, called e.g. "common", , add "edit" method there. from 2 options have specified go 1st option. it's idea seperate controllers functionality. (eg. modifying tasks, etc). but understand have 3 roles together. (admin, member , anonymous). might think grouping categories followed: admin, public, me

symfony - calling console function in symfony2 -

i have 1 controller save data in database want run controller in crontab. make class getapicontroller extends controller { public function getapiaction() { download xml data.. saved in database used querybuilder function..... } } now try define console function class getapicommand extends containerawarecommand { protected function execute(inputinterface $input, outputinterface $output) { $getapicontroller =new getapicontroller(); $getapicontroller->getapiaction(); } } making instance of getapi controller , try call action method there give me error that kbundle\controller\controller.php on line 291 fatal error: call member function has() on null.. i try make controller service , try call here of $this->forward('app.get_controller:getapiaction'); they give again error forward not recognizeable any idea how solve issue? in advance help.... you need create service job w

excel - Provider not found may not be installed properly Error -

i have excel workbook contains macros connect access database (both 2007). same sheet works in different systems except one. i checked aceoledb.dll file present @ correct location. (c:\program files (x86)\common files\microsoft shared\office12) looks similar other systems. getting provider not found may not installed error when try run macro. the error msg comes @ connection open statement. (connection access db) the connection string is: public oconn adodb.connection public sconn string sconn = "provider=microsoft.ace.oledb.12.0;" & _ "data source=folderpath\database.accdb;" & _ "jet oledb:database password=pwd;" oconn.open sconn

.net - How to increase label box text Size in c# windows application? -

i using following code, when run below code, half of text displayed in label box. want display full line in label box text? how it? label dynamiclabel1 = new label(); dynamiclabel1.location = new point(280, 90); dynamiclabel1.name = "lblid"; dynamiclabel1.size = new size(150, 14); dynamiclabel1.text="smith had omitted paragraph in question (an omission had escaped notice twenty years) on ground unnecessary , misplaced; magee suspected him of having been influenced deeper reasons."; dynamiclabel1.autosize = true; dynamiclabel1.font = new font("arial", 10, fontstyle.regular); panel1.controls.add(dynamiclabel1); label dynamiclabel = new label(); dynamiclabel.location = new point(38, 30); dynamiclabel.name = "lbl_ques"; dynamiclabel.text = question; //dynamiclabel.autosize = true; dynamiclabel.size = new system.drawing.size(900, 26); dynamic

php - Selecting a property from JSON -

i have json similar one: {"request": {"target":"affiliate_offer","format":"json","service":"hasoffers","version":"2","networkid":"adattract","method":"getpayoutdetails","api_key":"bd2e82f029c50b582db85868b7c0b8ab99d095886ab079f87b464bb68486c891","offer_id":"9463"},"response": {"status":1,"httpstatus":200,"data":{"offer_payout": {"payout":"0.820"}},"errors":[],"errormessage":null}} and want select value of payout 0.820 . here try <?php include 'db.php'; $result = mysql_query("select * ada require_approval='0' order i2 asc limit 0,10") or die(mysql_error()); // keeps getting next row until there no more while ($row = mysql_fetch_array($result)) { echo "<div>";

r - Colour just the top border of geom_bar -

Image
a chart lot of bars looks squished, instance - ggplot(data.frame(x = 1:1000, y = (rnorm(1000)), fill = sample(c('a','b','c'), 1000, replace = t)), aes(x, y, fill = fill)) + geom_bar(stat = 'identity') i have chart similar dataset feel able make more sense out of colouring top border of bar. i'm unable achieve this. closest can incorporate geom_step adds vertical lines y value changes , crowds chart more. geom_point sizes aren't synced separation on x axis spill on side small x values. sure shot solution i'm able think of manipulate data such i'm able draw geom_segment s work me. there other way ps: need stick format reasons. you use geom_errorbar() , set ymin= , ymax= y values. can play width= , size= need. ggplot(data.frame(x = 1:1000, y = (rnorm(1000)), fill = sample(c('a','b','c'), 1000, replace = t))) + geom_errorbar(aes(x=x,ymin=y,ymax=y,color=fill),size=0.5,width=3)

opencv - ImportError in ipython Console in spider but not in command line ipython -

i'm working on win64 anaconda 2.4.1. installed described here . windows command line running ipython can import cv2. unfortunatelly, when try cv2.imshow() images not shown gray region of correct size. tried spyder. spyder ipython console, cannot import cv2: traceback (most recent call last): file "<ipython-input-1-72fbbcfe2587>", line 1, in <module> import cv2 the path variable same, working directory. how can more information, dll not found. hints? in advance. edit: cv2.waitkey() helps in windows command line case, bad. why doesn't work in spyder?

php - move event from myservice account to my regular account error occur NOT FOUNND -

whenever try move event myservice account regular account problem occur not founnd ,everything ok ,event id, calendar id, destination id, move google interface google move , code says not found, i tried move(last line) after inserting event require 'src/google/autoload.php'; require_once 'src/google/client.php'; require_once 'src/google/service/calendar.php'; $email_address = 'stafftesting@stafftesting-1204.iam.gserviceaccount.com'; $key_file_location = 'stafftesting-546f9e1a6522.p12'; $client = new google_client(); $client->setapplicationname("google calendar api php quickstart"); $key = file_get_contents($key_file_location); $scopes = "https://www.googleapis.com/auth/calendar"; $cred = new google_auth_assertioncredentials( $email_address, array($scopes), $key); $client->setassertioncredentials($cred); if ($client->getauth()->isaccesstokenexpired()) { $client->getauth()-&g

Syntax error near "#5018" in android sqlite database -

in android application, have database store contacts. in that, have "number" column of "text" type. syntax error near: "#5018" (code 1) error while executing below query: string passednumber = "#5018"; db.delete("contact_table, "number=" + passednumber, null); if use quotte aroung number like: db.delete("contact_table, "number='" + passednumber + "'", null); working properly. my concern why giving error although have number column of text type. because #5018 syntactically not number or other valid construct. when enclose in single quotes '#5018' becomes string literal , syntactically correct. 5018 syntactically valid numeric literal. column type affinities have nothing literal syntax.

Is Tcl nested dictionary uses references to references, and avoids capacity issues? -

according thread: tcl max size of array tcl cannot have >128m list/dictionary elements. however, 1 have nested dictionary, total values (in different levels) exceeds number. now, nested dictionary using references, by design ? mean long in 1 level of dictionary tree, there no more 128m elements, should fine. true? thanks. the current limitation no individual memory object (c struct or array) can larger 2gb , , it's because high-performance memory allocator (and few other key apis) uses signed 32-bit integer size of memory chunk allocate. this wasn't significant limitation on 32-bit machine, os restrict @ time when started near limit. however, on 64-bit machine it's possible address more, while @ same time size of pointers doubled, e.g., 2gb of space means 256k elements list, since each needs @ least 1 pointer hold reference value inside it. in addition, reference counter system might hit limit in such scheme, though wouldn't problem here. if creat

ruby on rails - Allow registered user to access their account without doing login -

i sending link registered user. when click link want them redirect access their account without authentication(login). when access site should login. using digest/sha password encryption.any 1 have idea? you can try following.. you have send link mail account. so user can access account in 5 minutes. after 5 minute link not worked. have pass unique key link. like. www.google.com?id=12d123e33ert you have generate unique link each , every request user. , store 1 database table. email ,timestamp. if user dont click link within 5 minutes. you have clear database timestamp bigger 5 minutes using crone job functionality of server. if eamil , link key matched our store key user can access website. otherwise not. you got point?

java - Json array inside array retrieve values Android -

i m trying values jsonarray inside array, m able retrieve whole json values jsonarray not able retrieve values inside jsonarray . when convert jsonarray jsonobject values stored inside jsonarray . gives error: org.json.jsonexception: no value "banner" here json code, verified json code jsonlint.com , showed json validate, [ {"code":"banner","moduletitle":0, "banner": [ {"image":"http://imageurl"}, {"image":"http://imageurl"}, {"image":"http://imageurl"} ] } ] i m trying 3 hour no luck. m new in json , not know how json work, , read abut gson library json values. here java code. jsonarray jsonobj = null; string image_url = ""; string banner_code =""; try { jsonobj =new jsonarray(lib_function.getjsonurl( jsontags.top_banner_josn_urls));

c# - Regex: Keep unkknown substring -

Image
i try modify set of strings. need replace unknown parts keep unkknown middle part. in notepad++ used as regex-input: .*(themeresource .*?brush).* and regex-output: /1 with result: input: "<setter property="foreground" value="{themeresource systemcontrolforegroundbasehighbrush}" />" "<setter property="background" value="{themeresource systemcontrolbackgroundaltmediumlowbrush}" />" "<setter property="borderbrush" value="{themeresource systemcontrolforegroundbasemediumlowbrush}" />" "<discreteobjectkeyframe keytime="0" value="{themeresource systemcontrolpagebackgroundaltmediumbrush}" />" output: "themeresource systemcontrolforegroundbasehighbrush" "themeresource systemcontrolbackgroundaltmediumlowbrush" "themeresource systemcontrolforegroundbasemediumlowbrush" "themeresource systemcontrolpagebac

python 2.7 - Connecting with mysql server running on Compute Engine instance from GAE -

how communicate mysql server running on compute engine instance google app engine? using google app engine frontend. want host our database on mysql server running on compute engine. there way achieve this? we have gone through this: https://cloud.google.com/solutions/mysql-remote-access code snippet: if (os.getenv('server_software') , os.getenv('server_software').startswith('google app engine/')): db=mysqldb.connect(host="internalip", port=3306, db='test_database', user='root',passwd="db_password") else: db = mysqldb.connect(host='127.0.0.1', port=3306, db='test_database', user='root', charset='utf8') cursor = db.cursor() logging.info("hey there looks connected") igor's comment above hints at how working; i've managed produce working app, following changes documented solution . specify public (external) ip address host parameter, rather unix_sock

css - Make margin effect on elements padding? -

Image
i have element bottom margin , below element padding. margin effective element's text, not padding. how can make effective element including padding? p { margin-bottom: 50px; } { padding: 40px; background: green; } <p class="first">first</p> <a href="#">link</a> http://codepen.io/anon/pen/lgmevv inline elements not affected vertical margings. make anchor tag display: inline-block

c# - How to split strings with two chars ('||') -

this question has answer here: string.split - multiple character delimiter 4 answers othermatcharray= "march | monday | tuesday|| december | wednesday | friday" string[] matchdata = othermatcharray.split('||'); how can split 1 string , split again using || , | ? string[] matchdata = othermatcharray.split(new string[] { "||" }, stringsplitoptions.none);

JavaScript/jQuery on click, confirm fires twice -

problem solved itself... fyi : apparently was mac os or chromium engine bug after last system , browser updates problem disappeared appeared before. looks there not relevant jquery or javascript api. i'll keep question few days , i'll delete later doesn't fit stackoverflow rules in such situation. original post: i have simple js confirm inside on click listener, in code below, no more requests (i.e. ajax, no duplicated js includes etc...). the problem confirm dialog fired twice in browsers (i.e. chrome , opera @ mac os) , question is, did miss obvious or considerable bug of mentioned browsers? there workaround me prevent this? tried e.preventdefault(); no luck. edit should've mention if there's no confirm('...'); within on click it's fired once (so 1 let check... in console occurs). confirm both logs appears twice in console, boolean in opposite order of clicking - sample - if i'll click cancel first , ok later console logs

SSH command can not start remote java process -

i have start function, , put in script resides on remote site, function's code shows below. function start() { cd $install_dir mkdir -p logs export classpath=$classpath:$target_jar nohup java -xms2048m -xmx8192m -server -xx:permsize=128m -xx:maxpermsize=256m \ -xx:+printgcdetails -xx:+printgcdatestamps \ -xx:-omitstacktraceinfastthrow \ -cp $target_jar $main_class >> logs/jvm.log 2>&1 & echo "service started, see logs" } and when try call function use ssh ssh xxx@host "./service.sh start" , can not start java process, got response message "service started, see logs" , there's no error, jvm.log empty. apparently me script has executed, target java process didn't run. if logon remote site, , execute ./service.sh start , works. since able run service manually, ssh , script part fine. what go wrong environment. example referred java without absolute path. hence ma

c# - Checking if a row has been selected entirely -

my datagridview in rowheaderselect mode. clicking on rowheader selects whole row. however, @ point, when use context menu shortcuts or shortcut keys keyboard, need check if whole row selected, or single cell, , perform actions accordingly. how check this? you can check e.commandname property. check foolowing patch of code >> protected void gridview1_rowcommand(object sender, gridviewcommandeventargs e) { sxengine.classx user = (sxengine.classx)session["appobj"]; if (e.commandname == "select") { user.browselect = true; } else { user.browselect = false ; } } study link more info regarding different properties of gridview>> http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.selectedindexchanging.aspx

css - Transitions run slower on first use in IE -

i have element has transition: .25s linear; . it runs slower on first use whenever page loaded in ie11, , thereafter works expected. why this? there caching of animation? works expected in chrome. this sounds nitpicky, it's noticeable , annoying glitch elements position effected it, , on slower load, can see background element shouldn't able to. i suspect runs first time due initial page load. there may other processes running may slow transition down too. second time smoother because resources have been cached , performance isn't hampered. run site through https://developers.google.com/speed/pagespeed/?hl=en find render-blocking scripts may hampering performance. also see article identify properties can animated cheaply. http://www.html5rocks.com/en/tutorials/speed/high-performance-animations/

java - Why is httpclientandroidlib in my android apk as a dependency? -

when analyse app apk method count analysis tools apk method count i've found ch.boye.httpclientandroidlib there dependency in app. (with 3000+ methods) when try analyse dependencies using ./gradlew app:dependencies 'ch.boye.httpclientandroidlib' not show dependency in way. i understand 'ch.boye.httpclientandroidlib' repackaging of httpclient 4.3.1 android have no idea why there, suggestions on why shows up? i compiling against api level 23 , our min api level 14. edit: adding current dependencies: +--- com.android.support:appcompat-v7:23.1.1 | \--- com.android.support:support-v4:23.1.1 | \--- com.android.support:support-annotations:23.1.1 +--- com.android.support:support-v13:23.1.1 | \--- com.android.support:support-v4:23.1.1 (*) +--- com.android.support:support-annotations:23.1.1 +--- com.google.dagger:dagger:2.0.1 | \--- javax.inject:javax.inject:1 +--- javax.annotation:javax.annotation-api:1.2

c++ - OpenCV Background substraction using Absdiff -

i've been working program detect hands background substracting. have tried save first frame of camera background , substract current frame, appeared have different brightness somehow. i've tried several times , dont have , light changing, can problem? image1 image2 #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <iostream> #include "camera.h" #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/video/background_segm.hpp> using namespace cv; using namespace std; int main() { const int laptop_cam = 0; const int lifecam = 1; const int max_fps = 25; camera cam(lifecam); mat background; cam.takeshot(); cam.mirrorimage(); cam.getframe().copyto(background); //deep copy imshow("background", background); mat diff; while (true) { cam.takeshot(); cam.mirrorimage(); absdiff(cam.getfra

cocoa touch - How to integrate iOS app with playback controls in lock screen and bottom panel? -

i want use play/stop, next, prev buttons, seeker & show album arts in "standard" ios user interface, many other apps. what classes should use? you need mpnowplayinginfocenter setting current album art. and can use - (void) remotecontrolreceivedwithevent:(uievent *)event handeling playback controls. explained in remote control events a simple search on google have found this.

jquery - Delete and add nodes with click on a node in d3.js -

how add or remove nodes , links onclick event in code? here ( d3js ) code fiddle . how use: right click on node , click on delete remove nodes no link. want remove 1 node , it's links click delete. //right click menu items $('g.node').contextmenu('cntxtmenu', { itemstyle: { fontfamily : 'arial', fontsize: '13px' }, bindings: { 'open': function(t) { alert(t.__data__.name); }, 'email': function(t) { alert('trigger '+t.__data__.name+'\naction email'); }, 'save': function(t) { alert('trigger '+t.__data__.name+'\naction save'); }, 'delete': function(t) { $('g.node').remove(); //alert('trigger '+t.__data__.name+'\naction delete'); } } }); just use $(t) instead of $('g.node')

mysql - Using a nested query to get details of two tables -

table 1 table 2 id name mob id course mark 1 joe 0000 1 english 77 2 john 0000 2 maths 89 i need show name of person table 1 has max(grade) in table 2 using nested query. select t1.name t1 t1.id = t2.id = ( select id t2 mark = ( select max(mark) t2 ) ); well, satisfies brief ;-): select a.* table_a join (select * table_b) b on b.id = a.id order mark desc limit 1;

python - Iterating through list of lists of lists and list of tuples -

i'm trying iterate on list of lists of lists , list of tuples @ same time, replacing values within list of lists of lists values list of tuples. here code far: tups = [(1,2,3),(4,5,6),(9,8,7)] lsts = [[[1, 0, 1], [2, 3, 1, 0], [1, 1, 1, 1, 10, 0]], \ [[1, 0, 1], [2, 3, 1, 0], [1, 1, 1, 1, 10, 0]], \ [[1, 0, 1], [2, 3, 1, 0], [1, 1, 1, 1, 10, 0]]] index1, aitem in enumerate(tups): index2, in enumerate(aitem): index3, mega_item in enumerate(lsts): index4, bitem in enumerate(mega_item): index5, b in enumerate(item): if == 0: lsts[index3][index4][index5] = break else: continue break else: continue break else: continue break i want solution produce lsts 0s replaced values in tups in sequential order t

machine learning - Python - Intra similarity -

i'm trying code in python intra similarity on iris data set. distance between elements same class. example on set: 1 2 3 4 |0 5 6 7 8 |0 1 3 5 6 |1 11 12 13 14 |0 10 2 4 6 |1 distance1 = (1-5)^2 + (2-6)^2 + (3 - 7)^2 + (4-8)^2 distance1 = sqrt(distance1) distance2 = (1- 11)^2 + (2-12)^2 + (3 - 13)^2 + (4-14)^2 distance2 = sqrt(distance2) similarityclass0 = (ditance1 + distance2) / 2 and have same class 1, 2 , 3 , on. for code think functionnal pretty ugly in input have x , y. when finish compute tab0, same tab1, tab2 etc. my question is: how can create code n classes? goal have each line measure of intra similarity from sklearn import datasets import numpy np iris = datasets.load_iris() iris.data.shape, iris.target.shape x = iris.data #0 = setosa // 1 = versicolor // 2 = virginica y = iris.target #at first, retrieve indexes of each classes #for example if tab0 has classes on ligne 1,2,6. tab0 store 1,2,6 tab0 = list() tab1 = list() tab2

angularjs - Angular.js ui-sref is not creating hyperlink -

i know question might stupid,but after searching through on stackoverflow , other blogs,and video tutorials,i have no other choice left ask on stackoverflow. have been learning angular.js through online tutorials. i have 2 files. index.html , app.js here snaps of code. states configuration part inside app.js angular.module('flappernews', ['ui.router']).config(['$stateprovider','$urlrouterprovider',function($stateprovider, $urlrouterprovider) {$stateprovider .state('home', { url: '/home', templateurl: '/home.html', controller: 'mainctrl' }) .state('posts', { url: '/posts/{id}', templateurl: '/posts.html', controller: 'postsctrl' }) $urlrouterprovider.otherwise('home')}]); inline templates inside index.html (1-home.html , 2-posts.html) <ui-view></ui-view> <script type="te

javascript - Adding map marker to floor plan in HTML5 -

i have building floor plan image , intend put 2d image on canvas. have no problem do. at place, say, @ front door, want put marker of sort (similar google map marker, or blue/red pin) mark sensor (i.e motion, etc..). if click marker display info on particular sensor. how do this? can't seem find correct term result want when tried google on this. hope of can point me right direction on this. ok, first thing, didn't know term image tiles after looking minecraft overviewer, suggested daedalus looks have create image tiles. can done using maptiler software can obtained here . in option, choose "image based tiles" suits me fine. after edited html file generated openlayer apis display zooms , markers , popups . so, that's it.

google chrome - Force TCP for WebRTC PeerConnections -

is possible force tcp tunneled (tls) connection webrtc? we developing webrtc application our business, experiencing major issues incoming udp streams caused our internal network. using turn server , getting bunch of ice candidates (even relay udp ones). the thing is, stated above, our incoming udp traffic not work reliable here (stuttering, bad image quality, low fps). it's enough give browser impression, webrtc can use it's peerconnection(s), actual result bad on udp. if block outgoing , incoming udp streams, can see (in wireshark) webrtc falls tcp traffic using our turn server. with tcp connections, getting results (with high frame rates , image quality). i've tried several things force tcp: i deleted udp part in m=video line m=video tls/rtp/savpf 100 116 117 96 i've excluded every single udp candidate candidate list in each case not able establish connection. is there can force tcp in webrtc or depend on browser here? configure peerc

c# - How to set SQL Server connection string? -

i'm developing simple c# application, i'd know this: when connect application sql server on pc, know connection string (server name, password etc.), when connect pc, sql server connection string different. there common account in sql server come default account can connect? have heard sa account in sql server, sa ? // .net dataprovider -- standard connection username , password using system.data.sqlclient; sqlconnection conn = new sqlconnection(); conn.connectionstring = "data source=servername;" + "initial catalog=databasename;" + "user id=username;" + "password=secret;"; conn.open(); // .net dataprovider -- trusted connection sqlconnection conn = new sqlconnection(); conn.connectionstring = "data source=servername;" + "initial catalog=databasename;" + "integrated security=sspi;"; conn.open();

.net - Visual studio trying to load pdb file when starting the application -

i'm running trouble when try start asmx webservice in visual studio can't initialize service, exception thrown "stackoverflow exception" , it's saying system.web.pdb/system.runtime.serialization not loaded. checking module's window , can see of dlls symbol status "cannot find or open pdb file" own dll of project, pdb file correctly loaded. if right click , select "load symbols", visual studio automatically loads many dll's pdbs, appointing temporary directory , error keeps going, now, visual studio says "source information missing debug information module". checking bin folder, there webservice pdb(and think that's right). i have tryed enabling/disabling "enable code" in symbol's options, enabling load pdb files microsoft symbols server(just check if error's gone) not happend. any other advice situation? i have checked happend when web service(.asmx) running on iis express. if run in visua

ios - CLLocationManager location monitoring not working properly -

i have app notify user every time approaches 1 of client's stores. there more 20 stores, have function takes user's location , finds 20 nearest stores him , start monitoring location of these stores, every time user moves, app finds 20 nearest stores again, removes previous stores monitoring , start monitoring new ones. for reason, doesn't work, i'll happy if 1 of (or more :)) me find problem, thanks!! mycode (scroll see full code): note: cllocationmanager created on appdelegate.m , it's delegate class ( uiviewcontroller ). -(void)sortcloseststores { [self.allstores sortusingcomparator:^nscomparisonresult(id _nonnull obj1, id _nonnull obj2) { cllocation *location1=[[cllocation alloc] initwithlatitude:((store*)obj1).geopoint.latitude longitude:((store*)obj1).geopoint.longitude]; cllocation *location2=[[cllocation alloc] initwithlatitude:((store*)obj2).geopoint.latitude longitude:((store*)obj2).geopoint.longitude]; float dist1