Posts

Showing posts from August, 2011

python 3.x - How to get these tkinter scrollbars working? -

hi cant these scrollbars working though code comes advanced user on site have tried everything. no errors dont show up import tkinter tk #make window root = tk.tk() root.geometry("612x417") root.title("exchange rates") root.resizable(0,0) root.configure(background='lightgrey') #end #create listboxes currency selection listbox1 = tk.listbox(root, font="helvetica 11 bold", height=3, width=10) listbox2 = tk.listbox(root, font="helvetica 11 bold", height=3, width=10) #try create scroll bar scrollbar1 = tk.scrollbar(root, orient="vertical", command=listbox1.yview) listbox1.configure(yscrollcommand=scrollbar1.set) scrollbar2 = tk.scrollbar(root, orient="vertical", command=listbox2.yview) listbox2.configure(yscrollcommand=scrollbar2.set) listbox1.place(x=300,y=50) listbox2.place(x=300,y=125) scrollbar3 = scrollbar(root) scrollbar3.pack(side="right", fill="y") listbox = listbox(root, yscroll...

math - subtract two numbers in base 3 in java -

this question has answer here: how work other base numbers in java? 5 answers what's going on here? i'm trying subtract 2 integers in base 3 system. int x=222211; int y=112222; string result = integer.tostring(x-y,3); and result 109989 answer should 102212 it seems clear library doesn't think - result i'm getting base 10 result of subtraction. converting result base 3 gives me wildly incorrect result this embarrassing, figured out seconds after posting this... maybe else out. int x = integer.parseint("222211",n); int y = integer.parseint("112222",n); string result = integer.tostring(x-y,n); convert numbers beforehand appropriate base

jquery - How to trigger bootstrap collapse in Angular 2/Typescript -

let's i've panel . want able expend/collapse it, depending on selected value of dropdownlist. <div class="collapse" id="collapseexample"> <div class="well"> ... </div> </div> this dropdownlist . <select id="state" name="state" [(ngmodel)]="stateid" (change)="onchange($event.target.id, $event.target.value)" class="form-control"> <option *ngfor="let r of stateslist" value="{{ r.id }}">{{ r.name }} </option> </select> this event handler . and, if state selected, expends panel. otherwise, collapse panel. //events onchange(id: string, devicevalue: string) { if (id == "state") { if (devicevalue) { //expend panel... } else{ //collapse panel... } } } using jquery , like: $("...

Migrating web api authentication from .NET Core 1.1 to 2.0 -

i'm trying convert old authentication .net 2.0. had following code: app.usejwtbearerauthentication(new jwtbeareroptions { automaticauthenticate = true, includeerrordetails = true, authority = "https://securetoken.google.com/xxxxx", tokenvalidationparameters = new tokenvalidationparameters { validateissuer = true, validissuer = "https://securetoken.google.com/xxxxxx", validateaudience = true, validaudience = "xxxx", validatelifetime = true, }, }); my new code following: public void configure(...) { ... app.useauthentication(); ... } public void configureservices(iservicecollection services) { ... services.addauthentication(jwtbearerdefaults.authenticationscheme) .addjwtbearer(options => { options.requirehttpsmetadata = false; options.includeerrordetails = true; options.authority = "https://securetoken...

javascript - Target problems in JQuery -

i have problem. have similar divs same classes. when click on (toggle#1) .comments-toggle class need div below .toggle-container expand. code stands trigger .toggle-container div below (toggle#1) div expand. how click on toggle#1 , div below class toggle-container expand , not divs class toggle-container? *** edited html **** i need jquery changed, please don't change html solution. i hope make sense. html: <div> <div class="comments-toggle">toggle #1</div> </div> <div> <div class="comments-expanded-container toggle-container"> <p>lorem ipsum dolor sit amet, consectetur adipiscing elit, sed eiumdod tempor incididunt ut labore et dolore magna aliqua. ut enim ad minim veniam, quis nostrud exercitation</p> </div> </div> <div> <div class="comments-toggle">toggle #2</div> </div> <div> <div class="comments-expanded-cont...

json - Finance data on alphavantage -

i trying json company calling api of alphavantage .for company data coming , company, it's failing. company data coming - tcs,infy,msft company data failing - tatamotors,rcom,sbin link tcs json https://www.alphavantage.co/query?function=time_series_daily_adjusted&symbol=tcs&outputsize=full&apikey=mcaf9b429i44328u link tatamotors https://www.alphavantage.co/query?function=time_series_daily_adjusted&symbol=tatamotors&outputsize=full&apikey=mcaf9b429i44328u can please me why happening? i've noticed alpha vantage when retrieving data list of stocks, response have empty body. are having error same stock tickers each time fetch data, or happening different tickers each time? what response body like? when did problem start? has been this, or intermittent? it seems bug on end, , seems follow period of 500 server errors effect of "heroku app: application error". doesn't happen every day, , doesn't happen same stock...

ios - Swift: Thread 1 signal SIGABRT in class AppDelegate: UIResponder, UIApplicationDelegate -

Image
i'm following tutorial , every time click button error in appdelegate.swift says thread 1 signal sigabrt . import uikit @uiapplicationmain class appdelegate: uiresponder, uiapplicationdelegate { //thread 1 signal sigabrt here's screenshot of storyboard. i have looked on , answers refer iboutlet connection doesn't exist can see in screenshot connections don't know problem is. here's viewcontroller.swift code : import uikit class viewcontroller: uiviewcontroller { @iboutlet weak var input: uitextfield! @iboutlet weak var label: uilabel! @ibaction func button(_ sender: uibutton) { label.text = input.text userdefaults.standard.set(input, forkey: "myname") input.text = " " } override func viewdidload() { super.viewdidload() } override func didreceivememorywarning() { super.didreceivememorywarning() } override func viewdidappear(_ animated: bool) { if let x = userdefaults.standard.object(forkey: "myna...

python - Adding multiple lines of different colors in matplotlib -

i trying plot multiple lines in single figure, , want each line of unique color, came know matplotlib default. in case isn't working. same color each of lines in figure. from sklearn import datasets import pandas pd import numpy np import random import matplotlib.pyplot plt # loading boston dataset sklearn , creating dataframe boston = datasets.load_boston() data = pd.dataframe(boston.data, columns = boston.feature_names) #for dropping multiple column datadrop = data.drop(['crim','dis', 'zn', 'indus','chas','nox', 'rad', 'tax','lstat', 'b', 'ptratio', 'rm'], axis=1) #converting numpy array m = 20 dataarray = datadrop['age'].values absmean = dataarray.mean() k in range(0,10): n = len(datadrop.index) p = random.random() c = int(n*p) #uniform sampling of c elements above mean = 0 values = np.empty([1, 2]) in range(0,m): mean = ( me...

c++11 - c++ decltype how to use to simplify variable definition -

say, have piece of code, in 1 of classes, defines a map of key , map the second map key , function handler the function hander signature takes 2 params right now, signature define variable looks incredible. std::map<std::string, std::map<std::string, std::function<void(std::shared_ptr<httprequest>, std::shared_ptr<httpresponse>)>>> routefunctions_; i came know decltype, unable use correctly. decltype(x) routefunctions_; // should there in place of x ? use typedef type, if declare variables of it. use auto or decltype , if want return value of type function. use decltype , if want type of structure/class member. look @ articles: http://en.cppreference.com/w/cpp/language/auto http://en.cppreference.com/w/cpp/language/decltype http://www.cprogramming.com/c++11/c++11-auto-decltype-return-value-after-function.html your choice in case typedef : typedef std::map<std::string, std::map<std::string, std:...

reactjs - How to render a react component on every button click? -

iam creating react app in want render component on every button click.but once. class addform extends react.component{ constructor(props){ super(props); this.state={ anotherform:false, } this.newform=this.newform.bind(this); } newform(){ this.setstate({ anotherform:true }) } render(){ return( <div> <button onclick={this.newform}>addform</button> <educationdetails/> {this.state.anotherform?<educationdetails/>:null} </div> ) } } here component educationdetails rendered whenever addform button clicked.but couldn't figure out. here working jsfiddle lets assume education details component. class educationdetails extends react.component { constructor(props) { super(props); } render() { return (<div> <p>firstname: <input type="text" value={this.props.value || ''} /></p> <p>lastname: ...

javascript - Nav Tabs with js and handlebars -

so i'm using handlebars view engine. bootstrap version 4.0. have default layout called layout. i've been using render navbar , within layout put {{{body}}} , have page.handlebars view every page have far. on 1 page, i'd have dynamic nav-tab. i'm looking @ https://v4-alpha.getbootstrap.com/components/navs/ , can render html final within purchase.handlebars page. it's when need select tab display content. i'm not sure how make work handlebars. here's html: <div id="table-nav-tabs"> <ul class="nav nav-tabs" id="mytab" role="tablist"> <li class="nav-item"> <a class="nav-link active" data-toggle="tab" href="#home" role="tab" aria-controls="home">home</a> </li> <li class="nav-item"> <a class="nav-link" data-toggle="tab" href="#profile" role="tab" a...

How to get information from a customized ListView in Android -

i have listview have customized display information gathered sqlite database. each item represented using cardview widget containing textviews. have set listview property in .xml file to: android:choicemode="singlechoice" allowing user make selection list. when user clicks floating action button, want able take information displayed in 1 of textviews of cardview selected in listview. i have looked @ other questions on topic , suggest using onclick method, not understand how work because not want retrieve information when user makes selection list. rather, want information when have selected floating action button. here part of activity code: public class setvieweractivity extends appcompatactivity { private static final string tag = "setvieweractivity"; private boolean fabstate; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // set contents of activity setcontentview(r.layout.activ...

ios - WKWebView load HTML string with local resources -

wkwebview not displaying html string local resources ( file:// scheme ) using loadhtmlstring:baseurl: method. however, html string displayed correctly when tried uiwebview . how can make wkwebview render correctly? here example of html string: <html> <body> <iframe src=file:///var/mobile/containers/data/application/6bfc9180-2561-4482-9b88-90f23742361b/library/caches/myapp/iframe.html frameborder=0/> </body> </html>

How to use bootstrap datepicker - jquery plugin in AngularJS -

i want use plugin in angularjs in export table filters. possible use ng-model , other uses the plugin : https://uxsolutions.github.io/bootstrap-datepicker/?markup=input&format=&weekstart=&startdate=&enddate=&startview=0&minviewmode=0&maxviewmode=4&todaybtn=false&clearbtn=false&language=en&orientation=auto&multidate=&multidateseparator=&keyboardnavigation=on&forceparse=on#sandbox especially need "range" -from/to . option to use uxsolutions bootstrap-datepicker in angularjs, create custom directive this: app.directive("datepicker", function() { return { restrict: "a", require: "ngmodel", link: function(scope, elem, attrs, ngmodelctrl) { elem.on("changedate", updatemodel); elem.datepicker({}); function updatemodel(event) { ngmodelctrl.$setviewvalue(event.date); } } } }) u...

java - How is String in switch statement more efficient than corresponding if-else statement? -

java documentation says the java compiler generates more efficient bytecode switch statements use string objects chained if-then-else statements. afaik string in switch uses .equals() internally in case sensitive manner. efficiency mean in context. faster compilation? less bytecodes ? better performance? using switch statement faster equals (but noticeably when there more few strings) because first uses hashcode of string switch on determine subset of strings possibly match. if more 1 string in case labels has same hashcode, jvm perform sequential calls equals , if there 1 string in case labels hashcode, jvm needs call equals confirm string in case label equal 1 in switch expression. the runtime performance of switch on string objects comparable lookup in hashmap . this piece of code: public static void main(string[] args) { string s = "bar"; switch (s) { case "foo": system.out.println("foo match"); ...

ios - Check if an element is present in 3D array Swift -

i have array gets instantiated in viewdidload var bookingsarray : [[string]] = [] i adding elements in way: var configuration: [string] = [] configuration.append(textfieldfacility.text!) configuration.append((pickslottf.text?.components(separatedby: " ")[0])!) configuration.append((pickslottf.text?.components(separatedby: " ")[1])!) bookingsarray.append(configuration [string]) bookingsarray looks : [["a", "20-08-2017", "14:00"], ["b", "20-08-2017", "14:00"]] while adding new elements bookingsarray , want check if new element present in array. how do in case of multi-dimensional array? first of all, if want unique objects use set . if not possible highly recommend use custom struct can conform equatable rather nested array , example struct booking : equatable { let facilty : string let date : string let time : string ...

android - Multiple html files in fragment using webView via ListView -

i created webview application listview in fragment. followed link: opening multiple local html files using webview via listview when click on item should redirect me detail of webview item. trying implement in fragment 1 item successful while other items not point me webview detail should be. i've been looking solution still no luck. here code mainactivity: package com.listviewfragment.withsublist; import android.support.v4.app.fragmenttransaction; import android.support.v7.app.appcompatactivity; import android.os.bundle; public class mainactivity extends appcompatactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); main_listfragment main_listfragment = new main_listfragment(); fragmenttransaction fragmenttransaction = getsupportfragmentmanager().begintransaction(); fragmenttransaction.replace(r.id.content, main_listfragment); fragmenttransaction...

google maps api 3 - javascript - How to calculate the time of the closest point of approach? -

i working on program can calculate closest point of approach of storm city using javascript , google map api. found this method , , although not understand how scripts work, can still calculate closest distance, verified this website . code follow: var maproute; var rtpoints; var centermap = new google.maps.latlng(22.3, 114.2); function routemap() { maproute = new google.maps.map(document.getelementbyid('maproute'), { center: centermap, zoom: 5, maptypeid: google.maps.maptypeid.satellite }); var rtpoints = [ new google.maps.latlng(20.3, 118.9), // new google.maps.latlng(21.4, 114.6), // +24hr new google.maps.latlng(22.5, 110.4), // +48hr ]; var rtpoly = new google.maps.polyline({ path: rtpoints, strokecolor: "#0000ff", strokeweight: 3, map: maproute }); var container = document.createelement("div"); container.style.fontfamily = 'arial'; co...

Combo Box Selection Changed Event fires before Selection Changes when using Selected Value (C# WPF) -

i have combo box , button. when click button, it's supposed change selected value , fire code when item changed. unfortunately, selection changed event fires before set selected value of combo box. my combo box's code on initialize: listcb.selectedvaluepath = "key"; listcb.displaymemberpath = "value"; listcb.items.add(new keyvaluepair<int, string>(1, "one")); listcb.selectedvaluepath = "key"; listcb.displaymemberpath = "value"; listcb.items.add(new keyvaluepair<int, string>(2, "two")); listcb.selectedvaluepath = "key"; listcb.displaymemberpath = "value"; listcb.items.add(new keyvaluepair<int, string>(3, "three")); my button's code: listcb.selectedvalue = 3; my selection changed event: private void listcb_change(object sender, selectionchangedeventargs e) { messagebox.show("value now: " + listcb.selectedvalue); } what happens if exampl...

Php - convert string to array -

i have array in string : "[14,16,18]" i want remove double quotation , result : [14,16,18] i've tried : $restaurantids =request::all(); dd(trim(array_values($restaurantids)[0], '"'),array_values($restaurantids)[0] , $restaurantids) ; and result : "[14,16,18]" "[14,16,18]" array:1 [ "restaurant" => "[14,16,18]" ] any suggestion? you can below:- <?php $string = "[14,16,18]"; $array = json_decode($string, true); print_r($array); output:- https://eval.in/847737 another solution:- <?php $string = "[14,16,18]"; $array = explode(',',str_replace(array('[',']'),array('',''),$string)); print_r($array); output:- https://eval.in/847734

Laravel Routing and PHP Dev Server -

i'm having laravel route can take infinite number of paths. route::get('test/{path?}', calback)->where('path', '.*'); everything works ok when use php artisan serve . but when cd public , start php dev server php -s localhost:8002 i'm having issue paths request file. route works still: /test/something/here but not this: /test/something/here.dd it seems php dev server right away looks static file in public when there dot in uri , laravel routes not parsed. i haven't tested assume apache, ngix, iis, lighttpd , others behave same. is there i'm missing here or kind of laravel workaround not require editing servers config files? want in laravel routes first in cases. for reasons not right editing server config files not option.

python - Putting CSV data into a table in PyQt4 -

this question has answer here: pyqt - populating qtablewidget csv data 2 answers currently have csv file with open('my csv file ', 'r') csv: line = csv.reader(csvf, delimiter=' ', quotechar='|') row in line: print ",".join(row) #if print(account) print accounts shell, how each line table in pyqt4? using pyqt.qlabel somehow? documentation on creating tables isn't clear me. use pyqt table widget. can specify column in table widget , after can set value cell of table widget. can use .setitem function set value item = qtablewidgetitem() item.settext("blah blah") self.tablewidget.setitem(n, 0, item) where n row , 0 column , item value.

ios - EKEventViewController doesn't show event details -

i'm working in ios11b6 , section of code open event in ekeventviewcontroller doesn't show event details - shows 'new event', 'january 1, 2001', 'untitled calendar'. the section of code display event below (works fine in ios10) func openevent() { eventidentifier = eventclipboardidentifier let eventviewcontroller = ekeventviewcontroller.init() eventviewcontroller.event = self.geteventfromeventclipboard() print(eventviewcontroller.event.title) eventviewcontroller.delegate = self eventviewcontroller.allowscalendarpreview = false eventviewcontroller.allowsediting = true let navbar = uinavigationcontroller(rootviewcontroller: eventviewcontroller) print(eventviewcontroller.event.title) present(navbar, animated: true, completion: nil) } the error getting in xcode debugger below. 2017-08-20 20:25:48.001329+1000 calendarapp[1113:281191] *** -[__nscfcalendar components:fromdate:]: date cannot nil future excep...

javascript - Let Scope output -

can explain why first console in test function gives value 99. let l = 99; function test(){ console.log(l); if(true){ let l = 7; console.log(l); } } test(); console.log(l); added comments explanation // global scope let l = 99; function test(){ // console.log(r); can't accessed here // can see global scope console.log(l); if(true){ // limited scope let l = 7, r=0; // l overides global scope console.log(l); } // console.log(r); can't accessed here } test(); // can see l in global scope console.log(l); to learn scope of let please refer mdn blog

algorithm - Is Quicksort "adaptive" and "online"? -

that say, quicksort perform better when given sorted list? don't see why case, perhaps don't understand algorithm. also, can quicksort "keep going" whilst add new data list while sorting? seems me algorithm needs full set of data @ beginning "work". does quicksort perform better when given sorted list? no, in fact way it's taught (use first element pivot) sorted (or sorted) list worst-case. using middle or random element pivot can mitigate this, however. can quicksort "keep going" whilst add new data list while sorting? no, intuition correct, need entire data set start.

javascript - whats the error? Expected !untrusted = true, and got false -

why !untrusted false?. thanks var trusted="true" var untrusted="false" console.log(trusted,!trusted) //true,false console.log(untrusted,!untrusted) //false,false the reason seeing ouput because non-empty string true. using string value, should boolean, var trusted=true; var untrusted=false; demo var trusted=true; var untrusted=false; console.log(trusted,!trusted); console.log(untrusted,!untrusted);

java - org.postgresql.util.PSQLException: FATAL: database "postgres>" does not exist -

Image
i'm working on first hibernate project jax-rs jersey web service hibernate + postgres backend running on tomcat 8.5. when start tomcat , try access users resource going http://localhost:8080/myapp/webapi/users , following error: severe: connection error: org.postgresql.util.psqlexception: fatal: database "postgres>" not exist @ org.postgresql.core.v3.queryexecutorimpl.receiveerrorresponse(queryexecutorimpl.java:2477) @ org.postgresql.core.v3.queryexecutorimpl.readstartupmessages(queryexecutorimpl.java:2603) @ org.postgresql.core.v3.queryexecutorimpl.<init>(queryexecutorimpl.java:125) @ org.postgresql.core.v3.connectionfactoryimpl.openconnectionimpl(connectionfactoryimpl.java:227) @ org.postgresql.core.connectionfactory.openconnection(connectionfactory.java:49) @ org.postgresql.jdbc.pgconnection.<init>(pgconnection.java:194) @ org.postgresql.driver.makeconnection(driver.java:450) @ org.postgresql.driver.connect(driver.j...

django - I'm trying to integrate disqus in my project but ended with error -

the error i've got : runtimeerror: model class django.contrib.sites.models.site doesn't declare explicit app_label , isn't in application in installed_apps. my setting file this: installed_apps = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.sites', 'disqus', ] site_id = 1 disqus_api_key = 'kla0jwwljfwkthvsym2osrilbsdczzmreyx9neizpz48rtws6ew2vvewmzgupsea' disqus_website_shortname = 'foobar'

mysql - Empty DataBase when i use JPA2 with Hibernate -

i have easy console application jpa. package com.concretepage.entity; import javax.persistence.*; @entity @table(name="farmer") @namedquery(name = "farmer.getall", query = "select farmer a") public class farmer { @id @column(name="id") private int id; @column(name="name") private string name; @column(name="village") private string village; public int getid() { return id; } public void setid(int id) { this.id = id; } public string getname() { return name; } public void setname(string name) { this.name = name; } public string getvillage() { return village; } public void setvillage(string village) { this.village = village; } } package com.concretepage; import com.concretepage.entity.farmer; import javax.persistence.entitymanager; import javax.persistence.entitymanagerfactory; import javax.persis...

python- split() doesn't work inside __init__ -

i writing code serve html file using wsgi.when write straight forward function no error : from wsgiref.simple_server import make_server import os ... ... def app(environ, start_response): path_info = environ["path_info"] resource = path_info.split("/")[1] #i no error here split works totally fine. now when try put code inside class error nonetype has no attribute split. perhaps environ inside __init__ doesn't initialised , that's why split returns nothing. following file in class candy resides : import os class candy: def __init__(self): #self.environ = environ #self.start = start_response self.status = "200 ok" self.headers = [] def __call__(self , environ , start_response): self.environ = environ self.start = start_response #headers = [] def content_type(path): if path.endswith(".css"): return "text/css...

How to include non executable stm32 library in IAR? -

i've compiled project library stm32 using iar, after adding .a file linker gives warning used functions declared implicity. function accepts pointer input buffer , return pointer output buffer, when assiging pointer save return address complier gives error value of intcan't assigned pointer. what error, or. there missing in way of adding lib you need .h file data structures & function prototypes.

jquery - javascript create a video element on element not working in state blob url -

i cloning element in developing chrome extension video. setting src attribute url of video element not working. i using xhr in javascript file in browser. var copycustomeplayer = function (video, element) { var videohtml = "<video id=\"extensionvideo" + 1 + "\" class=\"extension-video-player\" controls></video>"; var videoelement = $.parsehtml(videohtml)[0]; videoelement.currentsrc = video.currentsrc; videoelement.src = video.src; videoelement.currenttime = video.currenttime; element.appendchild(videoelement); body.appendchild(element); }

javascript - Div with background, image not clickable -

trying make div both background image , color clickable, reason image not clickable, background color. css .arrow2 { display:inline-block; background: url('toggle2.png') no-repeat center; width: 30px; height: 100%; } #toggle2 { display: none; background: rgba(40, 40, 40, 0.7); position: absolute; top:10px; width: 30px; height: 50px; background-color: rgba(40, 40, 40, 0.7); cursor: pointer; border-radius: 0px 10px 10px 0px; justify-content:center; align-content:center; flex-direction:column; /* column | row */ } html <div id="toggle2"><span class="arrow2"></span></div> javascript (jquery) $('.arrow2').click(function() { $('#navigation').toggle('slow'); $('#toggle').toggle('show'); $('#toggle2').toggle('hide'); }); i have tried both using .arrow , #toggle2 onclick trigger, same result. ...

authentication - c# webapi refresh_token don't delete when authenticating -

i have been following article, explaining how add token authentication application . have 3rd party wishes connect me , have set refresh tokens, etc. problem is, when authenticate token have given them, new refresh_token generated. i know design, wish turn off. currently, recieve method looks this: public async task receiveasync(authenticationtokenreceivecontext context) { // our allowed origin var allowedorigin = context.owincontext.get<string>("as:clientallowedorigin"); // add our allowed origin our headers context.owincontext.response.headers.add("access-control-allow-origin", new[] { allowedorigin }); // our hashed token var hashedtokenid = _helper.encrypt(context.token); // our refresh token var refreshtoken = await _service.getasync(hashedtokenid); // if have refresh token if (refreshtoken != null) { // ticket context.deserializeticket(refreshtoken.protectedticket); // ...