Posts

Showing posts from April, 2015

r - Error message while converting 2.1 mil rows from long to wide format -

i have been battling code day trying convert data long wide format. let me explain data set , code used. i have on 2 million rows 700k unique subject(usb), 125 unique days(date, m-d-y format), 83 unique group (grp), kyc , val1. here last code looks based on solution found on stackoverflow: n1 = unique(mydata[,c("usb","date")]) n1$idv = 1:nrow(n1) n2=merge(mydata,n1) dcast(n2,usb + idv ~ grp, value.var="val1"). this worked small portion of data other failed whole data set. i noticed unique(mydata[,c("usb","date","kyc")]) works better small sample , genesis of problem. for privacy reason can not post portion of data. please appreciate suggestion or how fix this. below other examples here have tried no luck library(splitstackshape) out_df <- dcast( getanid( x_df, 'time' ), time~.id, value.var='measure' ) qcc( out_df[,-1], type = 'xbar', labels = out_df[,1] ) i tried :

javascript - Check if "instanceof" is going to fail -

function a(){} a.prototype = "foo bar"; new a() instanceof a; // typeerror: function has non-object prototype 'foo bar' in instanceof check as can see, if prototype of constructor not object, fail , throw error. there way make sure instanceof not fail? typeof new a().constructor.prototype === "object" and typeof object.getprototypeof(new a()) === "object" apparently not work. the error says a.prototype needs object, should check that: function isobject(x) { return x != null && (typeof x == "object" || typeof x == "function"); } but isobject(a.prototype) not can assert instanceof call won't throw. going spec, should test function allowsinstancecheck(c) { try { if (!isobject(c)) return false; var m = c[symbol.hasinstance]; if (m != null) return typeof m == "function"; if (typeof c != "function") return false; return is

python - why the for loop and the list comprehension produce a different result? -

animals = ['lion' ,'tiger', 'lepord', 'cheetah', 'cat'] find = [] name in animals: if name == 'lion': find.append(name) print (find) find = [find.append(name) name in animals if name=='lion'] print (find) the loop output ['lion'] whereas list comprehension ['none'] . why it? the none comes list method append returns none . rather calling append in: [find.append(name) name in animals if name=='lion'] write: [name name in animals if name=='lion']

time - Best timing method in Python? -

i need assignment ,its first time computer science .please one. question.****type return statement: "return " followed expression performs calculation described in table above. (remember return statement used give value caller of function.) def seconds_difference(time_1, time_2):**** """ (number, number) -> number return number of seconds later time in seconds time_2 time in seconds time_1. >>> seconds_difference(1800.0, 3600.0) 1800.0 >>> seconds_difference(1800.0, 3600.0) -1800.0 >>> seconds_difference(1800.0, 2160.0) 360.0 >>> seconds_difference(1800.0, 1800.0) 0.0 """ i wish best of luck in class. here's help: def seconds_difference(first, second): return second - first print(seconds_difference(1800.0, 2160.0)) you should read functions: http://anh.cs.luc.edu/python/hands-on/3.1/handsonhtml/functions.html

python - Getting profile data user without additional model -

Image
i have user customize model several roles or users types such as: student user professor user executive user my user model of way: class user(abstractbaseuser, permissionsmixin): email = models.emailfield(unique=true) username = models.charfield(max_length=40, unique=true) slug = models.slugfield( max_length=100, blank=true ) is_student = models.booleanfield( default=false, verbose_name='student', help_text='student profile' ) is_professor = models.booleanfield( default=false, verbose_name='professor', help_text='professor profile' ) is_executive = models.booleanfield( default=false, verbose_name='executive', help_text='executive profile', ) other fields ... i have functions user model too, let me profiles according user type: def get_student_profile(self): student_profile = no

mysql - Best way to design table with many category columns -

i have book table columns like book-id title description author category1 category2 category3 100001 micro blah blah michael crichton scifi action mystery but categories available 22 each book allowed 3 category column can have of categories for searching set up, becomes extremely hard , there 6000 books far listed on it. what best way categories in database design make searching easier? tried giving them index column caused table throw 1070 error. in advance gary try architecture: book_detail: hold book related information auto-increment id category: hold categories list in auto-increment id book_category: hold mapping of book -> categories, 1 many mapping, means 1 book can map different categories primary key like: book_detail.id -> category.id

clojure - What does ^{ mean? -

in following code, have noticed ^ character before seems map data structure. ^ used for, or ^{ used for? (ns temper.core (:gen-class) (:require [mount.core :as mount])) (mount/defstate ^{:on-reload :noop} http-server :start (http/start (-> env (assoc :handler (lazy-run 'temper.handler 'app)) (update :port #(or (-> env :options :port) %)))) :stop (http/stop http-server)) the ^ character metadata. please see https://clojure.org/reference/reader#macrochars , https://clojure.org/reference/metadata . ^{:on-reload :noop} , (with-meta obj {:on-reload :noop}) equivalent.

org.w3c.dom.DOMException: Only one root element allowed in android xml parsing -

i have method in pass xml , returns parsed document.in devices got above shown error.(the xml contains 1 root element actually) public document getdomelement(string xml) { document doc = null; documentbuilderfactory dbf = documentbuilderfactory.newinstance(); try { documentbuilder db = dbf.newdocumentbuilder(); inputsource = new inputsource(); is.setcharacterstream(new stringreader(xml)); doc = db.parse(is); //i got error here } catch (parserconfigurationexception e) { log.e("error: ", e.getmessage()); return null; } catch (saxexception e) { log.e("error: ", e.getmessage()); return null; } catch (ioexception e) { log.e("error: ", e.getmessage()); return null; } return doc; } starting of xml this <?xml version="1.0" encoding="utf-8"?>

reactjs - React Material-UI browser support -

where can find information supported os/browsers react material-ui ? can`t find anywhere. see many bugs on ios6. please see related issue in github repo - https://github.com/callemall/material-ui/issues/200 .

maximum limit on Java array -

i trying create 2d array in java follows: int[][] adjecancy = new int[96295][96295]; but failing following error: jvmdump039i processing dump event "systhrow", detail "java/lang/outofmemoryerror" @ 2017/04/07 11:58:55 - please wait. jvmdump032i jvm requested system dump using 'c:\eclipse\workspaces\tryjavaproj\core.20170407.115855.7840.0001.dmp' in response event jvmdump010i system dump written c:\eclipse\workspaces\tryjavaproj\core.20170407.115855.7840.0001.dmp jvmdump032i jvm requested heap dump using 'c:\eclipse\workspaces\tryjavaproj\heapdump.20170407.115855.7840.0002.phd' in response event jvmdump010i heap dump written c:\eclipse\workspaces\tryjavaproj\heapdump.20170407.115855.7840.0002.phd a way solve increasing jvm memory trying submit code online coding challenge. there failing , not able change settings there. is there standard limit or guidance creating large arrays 1 should not exceed? int[][] adjecancy = new int[962

ios - Frequency from lightning sound card -

my app uses audiokit measure frequency , amplitude microphone. displays if people speaking within given area. works charm built in mic on ipad, , mic headset connected. try connect presonus audiobox ione, kind of soundcard, can connect professional mic to. amplitude more accurate mic, frequency measurement on place. playing constant sine wave of 500 hz, built in , headset mics measure perfectly, audiobox measures anywhere occasional correct 499 hz 43500 hz. i tried various filters (aklowpassfilter , akhighpassfilter) audiokit not seem much. the presonus box faulty thought, bought another, gives me same results. tried installing splnftt , app measures correct, hope can help override func viewdidload() { super.viewdidload() recordingsession = avaudiosession.sharedinstance() { try recordingsession.setcategory(avaudiosessioncategoryplayandrecord) try recordingsession.setactive(true) recordingsession.requestrecordpermis

android - How to show welcome screen or tutorial screen in cordova app -

greetings. creating app using cordova. there way show welcome screen or tutorial screen on start of app. want show 3 or 4 slides button in last slide. when user click button want welcome screen close. , want show welcome screen first time after app installed. thanks in advance. in past have created separate welcome html/js file or jquery page. set show first everytime. @ end of showing welcome page set flag using localstorage.setitem(). https://www.w3schools.com/html/html5_webstorage.asp then have check flag when app runs, if set skip whatever page want user see.

exe - The value Address of Entry Point different in PE Explorer and UltraEdit -

i wrote basic helloworld.exe c simple line printf("helloworld!\n"); then used ultraedit view bytes of exe file , used pe explorer see header values. when comes address of entry point , pe explorer displays 0x004012c0 . magic 010bh pe32 linker version 1902h 2.25 size of code 00008000h size of initialized data 0000b000h size of uninitialized data 00000c00h address of entry point 004012c0h base of code 00001000h base of data 00009000h image base 00400000h but in ultraedit see 0x000012c0 after counting 16 bytes after magic 0x010b . 3f 02 00 00 e0 00 07 03 0b 01 02 19 00 80 00 00 00 b0 00 00 00 0c 00 00 c0 12 00 00 00 10 00 00 00 90 00 00 00 00 40 00 00 10 00 00 00 02 00 00 04 00 00 00 01 00 00 00 04 00 00 00 00 00 00 00 00 10 01 00 00 04 00 00 91 f6 00 00 03 00 00 00 00 00 20 00 00 10 00 00 00 00 10 00 00 10 00 00 00 00 00 00 10 00 00 00

c# - How do I do unit tests in Visual Studio 2015 -

Image
i have below. using system; using system.collections.generic; using system.io; using system.linq; using system.net; using system.text; using system.threading.tasks; namespace syncfusion.gitlab { public class branches { public void createbranch(list<string> projectname, string sourcebranch, string destinationbranch) { } public void createtag(list<string> projectname, string sourcebranch,string tagname) { } public static list<string> getbranchlist(string projectid) { } public static list<projectdata> getprojectlist() { } } public class exceloperation { public void generateexcel(list<projectdetails> finalexceldata, list<string>projecturl,list<string>tagsorbranchurl) { } } } i can able test method , got positive output. not know how test these 2 method pu

debugging - Strange error with Symfony-2.8 -

i using symfony 2.8.18. able debug previous error messages had. searched on google same errors did not find anything. worked before. restarted local server , following error message: warning: class_implements(): class �]� not exist , not loaded here link screenshot of message: strange bug screenshot . i deleted cache removing corresponding folders , using following command: php app\console doctrine:cache:clear-metadata && php app\console doctrine:cache:clear-query && php app\console doctrine:cache:clear-result but did not solve problem. not know how understand error message. do have ideas on how debug code? i did not change seems 1 or several files corrupted. solution to: remove vendor folder; run composer install. my problem solved doing this.

php - Json deserialize list of objects and save to DB -

im trying insert json format db. { "firstname": "brett" } this format inserting properly. but if change format below: [ { "firstname": "brett" }, { "firstname": "john" } ] for below script insert 1st record. <?php $data = json_decode(file_get_contents('php://input'), true); /*server credentials*/ $arraykey=array_keys($data); $array=$data[$arraykey[0]]; try { //sql server execute foreach($data $array) { $count = $dbh->exec("insert table(firstname) values ('" . implode("', '", $array) . "')" ) or die(print_r($dbh->errorinfo(), true)); echo count($data); $dbh = null; echo 'data inserted!!<br />'; } } catch(pdoexception $e) { echo $e->getmessage(); } how i

javascript - Ckeditor Attachment plugin not working -

i using ckeditor latest version full package in angular2 project. in added plugin attachment. can browse file upload using attachment functionality. when click on upload attachment button says bad request. can check request going server. one more thing if upload image plugin gets uploaded server (java service)but after upload per link http://docs.ckeditor.com/#!/guide/dev_file_browser_api , calling following function java service. window.parent.ckeditor.tools.callfunction($funcnum, '$url', '$message'); but getting error : uncaught domexception: blocked frame origin accessing cross-origin frame. can please me resolve issue. searched lot not getting exact solution this. thanks

javascript - What's the simplest way to track visitors to an order confirmation page on a 3rd party site? -

i'm non-technical trying "build without code" (don't hate me) my friend has website. have blog. blog sends traffic website , gives me 10% every visitor signs up. he happy put code in order confirmation page if share him. not happy give me access google analytics. i want know: - how many visitors came through links made order confirmation page - how did spend - exact link clicked through on site i don't want ask him though. there easy way info can sent me automatically? he wont happy share customer info, ones came me. does makes sense? i've searched everywhere on web can't find clear answer or step-by-step guide. thanks everyone james

python - ValueError: setting an array element with a sequence. -

i working on classification problem using iris dataset , having trouble valueerror: setting array element sequence. converted dataset numpy.ndarray still having same error here code import tensorflow tf import numpy np import pandas pd rawdata = pd.read_csv('/home/akki/desktop/tf/iris.csv') print(np.shape(rawdata)) rawdatashuffel = rawdata.reindex(np.random.permutation(rawdata.index)).as_matrix() data = rawdatashuffel[:,range(0,7)] print(np.shape(data)) labels = rawdatashuffel[:,8] print(np.shape(labels)) ############################################################## # 1 hot genration number_of_op_class = 3 lab = np.eye(number_of_op_class) print(lab) #print(type(lab[0])) ########################################################################### # converting label 1 hot in range(0,100): if labels[i] == 'setosa': labels[i] = lab[0] elif labels[i] == 'versicolor': labels[i] = lab[1] elif labels[i] == 'virginica':

mysql - Getting columns name from my sql stored procedure result in python django -

i have stored procedure (sp) returns table result. have got sp results using code below. cur = connection.cursor() cur.callproc('manifest_item_list', [start_time, end_time]) results = cur.fetchall() now want result in form of list of dictionary (with column names keys). can use map , lambda function job given have column names. there smart way make dictionary out of or @ least column names result. currently list of tuples

pthreads - valgrind complains leak on detached thread -

ubuntu eglibc 2.19-0ubuntu6.6 valgrind-3.11.0 runnable code snippet: https://godbolt.org/g/9juh05 valgrind complains leak on detached thread. problem? a. joinable + pthread_join => ok b. pthread_detach => valgrind complains leak ==51206== 288 bytes in 1 blocks possibly lost in loss record 1 of 3 ==51206== @ 0x4c2c9b4: calloc (vg_replace_malloc.c:711) ==51206== 0x4012e54: allocate_dtv (dl-tls.c:296) ==51206== 0x4012e54: _dl_allocate_tls (dl-tls.c:460) ==51206== 0x5151da0: allocate_stack (allocatestack.c:589) ==51206== 0x5151da0: pthread_create@@glibc_2.2.5 (pthread_create.c:500) ==51206== 0x400986: start() (pt.cc:29) ==51206== 0x400a02: main (pt.cc:39) c. pthread_attr_setdetachstate => valgrind complains leak (not in code snippet)

java - How can you use Spring Boot validation annotations with Jackson Custom Deserialization? -

so basically, have json payload want deserialize custom object. i'm using jacksondeserializer. i'm using spring validation annotations validate fields. there way spring validation inside deserializer can return appropriate exceptions/errors.

node.js - I am trying to send array of images but I am unable to get data in server using nodejs -

here plunker link https://plnkr.co/edit/0i0bbymoekwpyixsofju?p=catalogue i want know how upload array of images. for single file, it's working, multiple files want know need write in node js. my code router.route('/events') .post(upload.single('event_image'),function(req,res){ console.log('**inside create events**'); console.log(":req.body",req.body); console.log(":req.fileeeeeee",req.body); var event = new event(); event.name = req.body.name; event.description = req.body.description; event.location = req.body.location; event.startdate = req.body.startdate; event.enddate = req.body.enddate; event.tagline = req.body.tagline; event.password = req.body.password; event.passcode = geteventpasscode(); event.uid = req.body.user_id; }) use upload.array('event_images', 20) (20 maxcount) instead of upload.single('event_image') edit: here code snippet shows working route in node.js router.post('/upload&

php - How do I tell which radio button was selected in file HTML-Twig -

i have 4 radio buttons in code html: <input id="spa-price" name="price" class="w3-radio" value="spare {{ price.getspareprice }}" type="radio"> <input id="spa-price" name="price" class="w3-radio" value="repair {{ price.getrepairprice }}" type="radio"> <input id="spa-price" name="price" class="w3-radio" value="test {{ price.gettestprice }}" type="radio"> <input id="spa-price" name="price" class="w3-radio" value="std-exchange {{ price.getexchangeprice }}" type="radio"> on post, want output hidden field value of selected radio button, eg: <input type="hidden" name="lt" value="{{ price.getlt }}"> the code have @ moment: {% if $_post['price'] == 'spare' %} <input type="hidden" name="lt&quo

postgresql - Postgres: Best way to determine changes in table without scanning entire table -

i designing etl take incremental changes postgres table. how detect whether table rows modified after last etl run without doing full table scan ? i'd save stats , compare pg_stat_all_tables that, eg ran sequentially: t=# select schemaname,relname,n_tup_ins,n_tup_upd,n_tup_del pg_stat_all_tables relname = 'rapid_inserts'; schemaname | relname | n_tup_ins | n_tup_upd | n_tup_del ------------+--------------------+-----------+-----------+----------- public | rapid_inserts| 254681563 | 0 | 0 (1 row) time: 10.921 ms t=# select schemaname,relname,n_tup_ins,n_tup_upd,n_tup_del pg_stat_all_tables relname = 'rapid_inserts'; schemaname | relname | n_tup_ins | n_tup_upd | n_tup_del ------------+--------------------+-----------+-----------+----------- public | rapid_inserts| 254681569 | 0 | 0 (1 row) time: 10.980 ms it means 6 rows inserted in barely second. same work updates , deletes...

python - Pandas - Columns not read though Present -

i have following set of data. url, team1, team2, win_toss, bat_or_bowl, outcome, win_game, date,day_n_night, ground, rain, duckworth_lewis, match_id, type_of_match "espncricinfo-t20/145227.html","western australia","victoria","victoria","bat","western australia won 8 wickets (with 47 balls remaining)","western australia"," jan 12 2005","1"," western australia cricket association ground,perth","0","0","145227","t20" "espncricinfo-t20/212961.html","australian institute of sports","new zealand academy","new zealand academy","bowl","match tied",""," jul 7 2005 ","0"," albury oval, brisbane","0","0","212961","t20" "espncricinfo-t20/216598.html","air india","new south wales","

javascript - Angular 2/4 loading component dynamically in newly added container -

i have angular-module. on "item"-click container added module, happens via jquery ("external" script) , not via angular. want dynamically render component within container. if have following, can viewcontainerref of "dynamicjquerycontent": <button id="clickme">spawn box</button> <div id="dynamicjquerycontent" #dynamicjquerycontent></div> this works: @viewchild('dynamicjquerycontent', {read: viewcontainerref}) dynamicjquerycontent: viewcontainerref; if add new conatiner "dynamicjquerycontent" via jquery: $("#dynamicjquerycontent").append("<div id='dynamiccomponentcontent' #dynamiccomponentcontent></div>"); this won't work: @viewchild('dynamiccomponentcontent', {read: viewcontainerref}) dynamiccomponentcontent: viewcontainerref; i can't viewcontainerref . i'm not able add dynamic component. info: i'm able

html - How can i filter values in angularjs? -

hi how can filter values in angularjs? i have created plunker reference :- my plunker . i want filter user categories in ng-repeat question list page user datas:- "user": { "_id": "58072aba0f82a61823c434df", "displayname": "table 1", "dob": "2016-12-22t18:30:00.000z", "location": "chennai", "religion": "hindu", "roles": [ "admin" ], "profileimageurl": "./modules/users/client/img/profile/uploads/ac4fbab396c2f725ed5211524f171136" }, categories values in array, need filter categories values in ng-repeat list page.... for example:- if user categories values "categories": [ "religion & culture", "social psychology" ], these 2 values should filter in list of category... my html:- <div ng-repeat="question in questions | filter:user.categories "> <small>

php - Passing a parameter in Laravel Form Request -

i have admin able create , update users. made new form request called 'userupdaterequest'. how can pass user id can update user detail? here rules: // userupdaterequest public function rules() { return [ 'firstname' => 'required|min:2|max:255', 'lastname' => 'required|min:2|max:255', 'username' => 'required|max:255', 'password' => 'required|min:6|confirmed', 'email' => 'required|email|max:255|unique:users,email,????', 'contact' => 'required|integer', 'gender' => 'required|in:m,f', 'role_id' => 'required|exists:roles,id', ]; } // controller public function update(userupdaterequest $request, user $user) { $user->update([ 'firstname' => request('firstname'),

html - Creating a hover overlay on an image, but cant seem to make it correct size? -

i'm trying create cards hover overlay effect on image, can't seem overlay fit size of image. got ideas? http://codepen.io/srbet/pen/pexoox thanks help! .flexwrapper { max-width: 1280px; margin: 0 auto; display: flex; flex-wrap: wrap; justify-content: center; } .card { display: flex; flex-direction: column; margin: 5px; max-width: 400px; height: auto; box-shadow: 1px 3px 16px -5px rgba(0,0,0,0.75); transition: 0.1s ease-in-out; } .card:hover { box-shadow: 1px 3px 16px 0px rgba(0,0,0,0.75); } .card img { max-width: 100%; max-height: 100%; } .overlaycontainer { position: relative; max-height: 100%; max-width: 100%; } .overlay { position: absolute; top: 0; left: 0; bottom: 0; right: 0; width: 100%; background-color: rgba(0,0,0,0.5); opacity: 0; transition: 0.5s ease; } .overlay:hover { opacity: 1; } .overlaytext { color: white; position: absolute; left: 50%; top: 50%; margin-right: 5

Angular CLI + npm + prebuild -

i've angular 2 project (that uses npm) created angluar-cli. i'd copy folder in folder before each compilation. idea have multiple theme (multiple folders) , copy 1 of theme ( choosen via variable 'themeid' ). is possible ? how execute copy script before each compilation ( script has work on windows or linux!) ? how set param themeid argument passed script , how set default value of variable if not set ? thx in advance. now use nodejs script executed in npm scripts conf (package.json) , use environnement variables using --projectname:client=client1 here part of package.json "config": { //default value "client": "client0" } "scripts": { //link nodejs file who's using process.env.npm_package_config_client variable "prestart": "node inoscripts/copyfiles.js", "ng": "ng", "start": "ng serve", "test": "ng test&qu

c# - Convert File To Byte-Array, Save In Access-DB, Read From DB And Create File -

hello, trying convert file byte[] write byte[] in access database read byte[] db recreate file that 1. byte[] bytes = system.io.file.readallbytes(@"c:\users\user\docs\1.pdf"); 2. accessconnector.writebytearraytoid(122, bytes); public static void writebytearraytoid(int aid, byte[] afile) { conn.open(); dbcommand = new oledbcommand("update belege set datei = @file where(id = @id)", conn); dbcommand.parameters.add("@id", oledbtype.integer).value = aid; dbcommand.parameters.add("@file", oledbtype.varbinary).value = afile.tostring(); dbdataadapter = new oledbdataadapter(dbcommand); dbcommand.executenonquery(); conn.close(); } 3. datatable table = accessconnector.getfilebytearraybyid(122); datarow row = table.rows[0]; system.text.utf8encoding enc = new system.text.utf8encoding(); byte[] newbytes = enc.getbytes(row.itemarr

multithreading - How to write thread-safe C# code for Unity3D? -

i'd understand how write thread safe code. for example have code in game: bool _done = false; thread _thread; // main game update loop update() { // if computation done handle start again if(_done) { // .. handle ... _done = false; _thread = new thread(work); _thread.start(); } } void work() { // ... massive computation _done = true; } if understand correctly, may happened main game thread , _thread can have own cached version of _done , , 1 thread may never see _done changed in thread? and if may, how solve it? is possible solve by, applying volatile keyword. or possible read , write value through interlocked 's methods exchange , read ? if surround _done read , write operation lock (_someobject) , need use interlocked or prevent caching? edit 1 if define _done volatile , call update method multiple threads. possible 2 threads enter if statement before assign _done false?

Convert timestamp to simple date in Java and add to ParseObject -

not duplicate: intended question address java.lang.illegalargumentexception thrown when attempting add formatted date parseobject rendering purposes. i've got list of dates want display in more readable format when render them page. i.e. want wed mar 29 13:32:35 cest 2017 become wed mar 29 . for (parseobject requestobject: requestsarraylist) { simpledateformat sdf = new simpledateformat("yyyy-mm-dd"); date date = null; try { date = sdf.parse(sdf.format(requestobject.getdate(parseconstantsutil.request_date_requested))); log.info(string.valueof(date)); } catch (java.text.parseexception e1) { e1.printstacktrace(); } requestobject.add(parseconstantsutil.request_date_requested, date); } requestobject.add(parseconstantsutil.request_date_requested, date); i thought simpledateformat enough can't ditch additional timestamp info , add object collection. should do? exception: java.lang.illegalargumentexception:

C# How can detect cyclic references? -

for 1 given instance of treelist, how can check whether or not instance of treelist, added first treelist, contains (possibly indirect) reference first treelist (which create cyclic reference)? for example: treelist t1 = new treelist(); treelist t2 = new treelist(); treelist t3 = new treelist(); t1.add(t2); t2.add(t3); t3.add(t1); because when iterrate through stuck in loop, because after t3 t1. how can check if 1 included in order. class treelist { public string name { get; set; } list<treelist> items = new list<treelist>(); public readonlycollection<treelist> items { { return items.asreadonly(); } } public treelist(string name) { this.name = name; } public void add(string item) { items.add(new treelist(item)); } public void add(treelist subtree) { items.add(subtree); } public override string tostring() { return name; } } i think these m

zapier - Expiration policy for the StoreClient (Python) -

running python script zapier quite easy, in combination requests , storeclient it's possible understand how hack datasources. question is, doc mention limitations , not mention policy storeclient self-expire, assume default cached data never expire. it's assumption asserted? that not correct - keys expire if not touch them in 3 months. made sure documentation reflects clearly!

java - Override HTTP status code for tomcat error page configuration -

tomcat allows specify error pages different error codes, <error-page> <location>/error.html</location> </error-page> but response code remains same. i'm looking option override status code 200 in catch-all error page. one option have error.jsp , set error code, wanted know if tomcat supports such configuration out of box. edit: modified error.html error.jsp , sending 200 status code. <% response.setstatus(200); %>

ios - How to use dispatch queue for high Priority in background in Swift 3.1 -

let dict_one=result[i] let product:allproducts=allproducts() product.applications=dict_one.objectforkey("applications") as? string product.desc=dict_one.objectforkey("description") as? string product.familyid=string(dict_one.objectforkey("familyid") as! int) if dict_one.objectforkey("imagename") as? string != nil { product.imagename=dict_one.objectforkey("imagename") as? string let url:string = appconstant.getallimages + (dict_one.objectforkey("imagename") as? string)! dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_background, 0)) { let imagepath=self.fileindocumentsdirectory((dict_one.objectforkey("imagename") as? string)!) self.saveimage(url, image_name1: (dict_one.objectforkey("imagename") as? string)!,path: imagepath) } } else { product.imagename="" } i

asp.net mvc - Get Http Status Code and Status Description in Custom Error Page -

where set http status code , http status description in "handleunauthorizedrequest" method of custom authorizeattribute, can in error page. have error pages different status codes. example: if user not authorized access resource, setting http status code 403 , description says permissions needed access resource. hence, when user redirect 403 custom error page, can show description. is there way set except in tempdate or viewdata? i want same in custom authorize attribute of web api.

c# - create, add, filter,search by tag strategy in mvc 5 -

i 'm working on first blog website, have of functionality working , need implement kind of feature - working tags. here drill: i have 2 classes have field tags , remove of fields save time: public class media { public int id { get; set; } public string title { get; set; } public string body { get; set; } public string tags { get; set; } } and public class video { public int id { get; set; } public string title { get; set; } public string description { get; set; } public string body { get; set; } public string tags { get; set; } } when i'm creating each of objects, can give tag name. example "sci-fi news", "world economy", "interesting stuff" , on. idea every time create tag new name being added index page list , when click 1 of them gives list of news same tags. stored in db. i thinking use anchored names in action links, correct direction? wo

java - JTable not appearing though populated from database -

Image
i've populated jtable database. table not appearing. can not figure out problem code. can not understand whether problem layout or code block retrieving data database. not getting exception message. i've added frame.getcontentpane().add(scroll, borderlayout.center); in code, still can not table. please see attached image getting. import java.awt.eventqueue; import java.sql.connection; import java.sql.preparedstatement; import java.sql.resultset; import javax.swing.jframe; import javax.swing.jscrollpane; import java.awt.borderlayout; import javax.swing.jtable; import javax.swing.table.defaulttablemodel; import controller.db_con; public class jtable { private jframe frame; private jtable table; string[] columnnames = {"id", "name", "username", "contact", "gender"}; /** * launch application. */ public static void main(string[] args) { eventqueue.invokelater(new runnable() {

image processing - Issue regarding detection of red and green colour using Matlab and Arduino -

Image
this question has answer here: how can convert rgb image grayscale keep 1 color? 3 answers i'm working on smartcar project in on detecting red color car should stop , on detecting green color should start running. using matlab color detection , arduino run car. problem m not able detect green color, code detect red color , stop car. not able figure out problem. my code is: vid = videoinput('winvideo',1 ,'yuy2_320x240'); s=serial('com9','baud',9600); fopen(s); %open serial port set(vid, 'framespertrigger', inf); set(vid, 'returnedcolorspace', 'rgb') vid.framegrabinterval = 10; start(vid) %set loop stop after 100 frames of aquisition i=1:100 imred = getsnapshot(vid); % snapshot of current frame diff_im = imsubtract(imred(:,:,1), rgb2gray(imred)); % subtract red component grayscale image extract red comp

java - Why does handshaking fail when I configure my bayeux_browser cookie to be secure? -

i have web application running on jetty, uses cometd long-polling between server , client. when configure bayeux_browser cookie secure constant flood of requests, in following order: handshake cometd/ connect cometd/ it repeats, , sequence takes 9ms. that's lot of requests flying around every minute. looks handshake returns secure bayeux_browser cookie, it's not being used cometd/ , connect requests. assume not sending secure cookie out on these causing handshake process fail, , try again? i've configured bayeux_browser secure setting option in applicationcontext config server: <bean id="bayeuxserver" class="org.cometd.server.bayeuxserverimpl" init-method="start" destroy-method="stop" lazy-init="true"> <property name="options"> <map> <entry key="loglevel" value="0"/> <entry key="timeout" value="15000"/

r - Tabulizer extraction missings -

i'm using extract_tables tabulizer -package extract tables pdf file. works fine if table less 4 lines headers it's not extracted. if table more 4 lines it's extracted. this code use : text <- extract_tables("file path, file name") table <- do.call(rbind, text) table <- as.data.frame(table) i tried solution fixing area: text <- extract_tables("file path, file name", area = c(0,0,595,842)) but in case columns missing , columns merged. did face same issue , knows how solve it?

kendo ui - How to set kendoTooltip custom width with function? -

i want kendo tooltip custom width: here code: $(".tooptip_labell").kendotooltip({ position: "right", animation: { open: { effects: "fade:in" }}}); you can add 'width: 500' configuration. in case should below(i set value 150px.you may change whatever want.) $(".tooptip_labell").kendotooltip({ position: "right", width:150, animation: { open: { effects: "fade:in" }}});

windows - How to obtain the handle to keyboard device? -

i trying hook keyboard isr, can't open device because createfile returns 0000007bh error_invalid_name . have done incorrectly? invoke definedosdevice,[raw],filename1,devicename lea rcx,[filename2] invoke createfilea,rcx,generic_all,file_share_write or file_share_read,0,3,0,0 ret section '.data' data writeable readable devicename db '\\device\\keyboardclass0',0 filename1 db 'keyboard',0 filename2 db '\\.\keyboard',0 raw dq 1 this flat assembler syntax, should pass devicename without escaping slashes: devicename db '\device\keyboardclass0',0 there's tutorial source code in c how access keyboard device in windows. might find interesting. translating assembly, you'll want like include 'include\win64ax.inc' .code start: invoke definedosdevice, 1, kbdfilename, kbddevicename mov rcx, kbdpath invoke createfile, rcx, generic_write, 0, 0, open_existing,

jquery - Coded UI fails to locate UI element after page refreshed -

i have web page jquery pop window in new frame. coded ui test builder able identify element if coded ui test builder opened after pop displayed, if close pop , opened again use coded ui test builder spy element test builder throws error error hresult e_fail has been returned call com component. additional details: control details not specified. main page pop window

`Required session does not exist` error while using REST api of Quickblox -

i using rest api of quickblox. everytime , getting response : {"errors": { "base": ["required session not exist"] }} and using below api : url : http://api.quickblox.com/users.json data & header : curl -x post \ -h "content-type: application/json" \ -h "quickblox-rest-api-version: 0.1.0" \ -h "qb-token: cf5709d6013fdb7a6787fbeb8340afed8aec4c69" \ -d '{"user": {"login": "xyz", "password": "xyz@123", "email": "xyz@domain.com", "external_user_id": "68764641", "facebook_id": "87964654", "twitter_id": "132132", "full_name": "test 1234", "phone": "87654351", "website": "", "tag_list": ""}}' \ can me resolve error? when connects app using quickblox, app has obtain access token provides tempo

html - Autocomplete behavior in Internet explorer and chrome -

i've been checking web application cross-browser compatibility , noticed few issues. 1 of major issue autocomplete. when user enters in input text, default, ie take auto-complete on , fills entered data. in chrome, exact opposite. won't retain entered data. this i've observed above behavior in browsers. ie 11 -> retains (even when auto-complete off) chrome 54 -> retains opera 38 -> retains firefox 52 -> retains safari 5 (windows) -> retains when checked kendo ui control, same browser, behavior changes this. ie 11 -> no chrome 54 -> no opera 38 -> no firefox 52 -> yes safari 5 (windows) -> no if need ensure same behavior these browsers, i'm supposed do? preferably both kendo ui , html5? how keep changed form content when leaving , going https page? (works http) configure firefox remember form changes when accidentally leaving https page? autocomplete attribute | autocomplete property autocomplete attrib

java - Multiple users using same Servlets will they override eachothers variables? -

i'm making calls java backend through servlets , each call api im using need supply password , username. can save users password/username in variable can use every time user makes call api? or variable overwritten if there multiple users? the overall question perhaps is: every user new "fresh" servlets or data saved users before? servlets shared performance reasons, should stateless (or thread-safe, you'd reinventing wheel). if need keep state user, put httpsession .

python - Send an email via. deferred library in Google App Engine -

i'm attempting send mail using emailmessage class , which, when used normally, in: message = mail.emailmessage() message.sender = ... message.to = ... message.subject = ... message.send() works fine; receive email expected. however, trying add email.send() event push queue using deferred library : def email(): message = mail.emailmessage() message.sender = ... message.to = ... message.subject = ... // elsewhere def send_email(message): deferred.defer(message.send, _countdown=10) app = webapp2.wsgiapplication([ ('/api/email', emailhandler) ], debug=false) i can see added push queue on admin interface, never receive email or kind of failure notification/bounce message. i've seen limitations of deferred library don't think i'm running of here? deferred.defer takes arguments function , arguments passed function. when this: deferred.defer(message.send, _countdown=10) you pass function message.send data

windows - Assistance with updating a group of Linux machines from a Powershell script or some other script -

i know can use putty ssh each linux machine , update centos servers...but i'm hoping can point me in right direction on how can perhaps powershell or other scripting language within windows. we use batchpatch patching our windows machines...works charm. we've been adding linux machines mix , i'd continue use batchpatch task. batchpatch not have ability talk linux (no ssh support)...but batchpatch allow me execute scripts i'm going test out running script against each machine listed in batchpatch view. what i'm looking through windows script connect linux machine , issue commands patch "yum upgrade". have common user added each of our linux machines can execute script using account (and account has nopasswd sudoer access should able execute sudo instructions in script without having type in password during running of script). have example of script or can point me script me started in testing of task? thank in advance advice can provide.

python - Pandas dataframe: how to summarize columns containing value -

here dataframe: df= pd.dataframe( {"mat" : ['a' ,'a', 'a', 'a', 'b'], "ppl" : ['p', 'p', 'p', '', 'p'], "ia1" : ['', 'x', 'x', '', 'x'], "ia2" : ['x', '', '', 'x', 'x']}, index = [1, 2, 3, 4, 5]) i want select unique values on 2 first columns. do: df2 = df.loc[:,['mat','ppl']].drop_duplicates(subset=['mat','ppl']).sort_values(by=['mat','ppl']) i get, expected: mat ppl 4 1 p 5 b p what want is, df3 be: mat ppl ia1 ia2 x p x x b p x x that is: in df3 row a+p, in column ia1, got x because there x in column ia1 in 1 of row of df , a+p solutions aggregate , unique , if multiple unique values joined , : df = df.groupby(['mat','ppl']).agg(lambda

How to delete session in Django -

i have used request.session['username']=username . have read session in django documentation. did not understand request.session . here session created if set request.session['username']=username . in code doing del request.session['username'] not deleting session session getting replaced same session_key different session data. we need modify , tell session modified. request.session['username']={} request.session.modified = true

python - Distributed Tenserflow: Cannot colocate nodes and Cannot merge devices with incompatible tasks -

if job_name == "ps": server.join() elif job_name == "worker": tf.device( tf.train.replica_device_setter( worker_device="/job:worker/task:%d" % task_index, merge_devices = false, cluster=cluster, ps_strategy=greedy ) ): norm_prjct_op = _norm_projected_cxx() normprjctop self-defined c++ operation, , program ran 1 parameter server. however, after added parameter server, got error: cannot colocate nodes 'normprjctop' , 'h_grad/shape: cannot merge devices incompatible tasks: '/job:ps/task:1' , '/job:ps/task:0' [[node: normprjctop = normprjctop[ _class=["loc:@entitys", "loc:@relations", "loc:@mh", "loc:@mt"], _device="/job:ps/task:0"](mh, mt, relations, entitys)]] in tf.train.replica_device_setter , tried greedyloadbalancingstrategy , merge_devices = false none of them worked.

sql server - SQL - Modify Query to create Columns -

i have query. used work requirements. select sites.sitename, severity.severity, coalesce(count(vulns.id), 0) totals sites inner join systems on sites.id = systems.siteid cross join severity left join vulns on vulns.systemid = systems.id , vulns.risk_factor = severity.severity group sites.sitename, severity.severity and returns results like sitename | severity | totals orlando | red | 0 orlando | yellow | 1 orlando | green | 22 orlando | orange | 1321 tampa | red | 22 tampa | yellow | 111 tampa | green | 223 tampa | orange | 121 how can modify query break out severity columns. such sitename | red | yellow | green | orange orlando | 0 | 1 | 22 | 1321 you can use conditional aggregation : select sites.sitename, count(case when severity.severity = 'red' vulns.id end) red, count(case when severity.severity = 'yellow' vuln

xUnit test Uwp project get 'Unsupported MRT profile type' exception -

i trying test uwp project xunit. on create instance of windows.applicationmodel.resources.resourceloader() , exception: unsupported mrt profile type. (exception hresult: 0x80073b20) example method test: public int sum(int a, int b) { var loader = new windows.applicationmodel.resources.resourceloader(); return + b; } with mstest test passed.

azure data lake - How to parse big string U-SQL Regex -

i have got big csvs contain big strings. wanna parse them in u-sql. @t1 = select regex.match("id=881cf2f5f474579a:t=1489536183:s=alni_mzsmmpa4voge4kqmyxoocew2aor0q", "id=(?<id>\\w+):t=(?<t>\\w+):s=(?<s>[\\w\\d_]*)") p (values(1)) fe(n); @t2 = select p.groups["id"].value gads_id, p.groups["t"].value gads_t, p.groups["s"].value gads_s @t1; output @t "/inhabit/test.csv" using outputters.csv(); severity code description project file line suppression state error e_csc_user_invalidcolumntype: 'system.text.regularexpressions.match' cannot used column type. i know how in sql way explode/cross apply/group by. may possible without these dances? one more update @t1 = select regex.match("id=881cf2f5f474579a:t=1489536183:s=alni_mzsmmpa4voge4kqmyxoocew2aor0q", "id=(?<id>\\w+):t=(?<t>\\w+):s=(?<s>[\\w\\d_]*)").