Posts

Showing posts from May, 2012

osx - Swift: Want to add value to NSTableView(1st ViewController) from secondViewController -

so have been able use delegates , protocols pass data secondviewcontroller firstviewcontroller. till have been showing data label in 1stvc. want add nstableview. i finding bit hard hang of tableview. using variable (data) stores values/string inserted in secondviewcontroller. imagine, use data variable show on tableview? i want delete button on firstviewcontroller, can delete value firstviewcontroller can insert secondvc. anyone here can me code both tableview & adding data row!

java - Why this converter needs casting? -

i need implement enum enum converter in java: enum_2 > enum_1 , i'd in generic way. so defined interface: interface labelaware<t extends enum> { string getlabel(); t getobject(); } and enum_1 : enum enum_1 { a, b; string getvalue() { return "whatever"; } } and enum_2 implements labelaware , need converted enum_1 : enum enum_2 implements labelaware<enum_1> { c("c", enum_1.a), d("d", enum_1.b); private final string label; private final enum_1 object; enum_2(string label, enum_1 object) { this.label = label; this.object = object; } public string getlabel() { return label; } public enum_1 getobject() { return object; } } finally, here's generic converter ( list.ofall() comes javaslang ): class converter<s extends labelaware, d extends enum> { private s[] values; converter(s[] values) { thi...

c++ - Undo/Redo with linked lists -

i have written program many different things linked list. asks user enter different lines of text linked list. can either enter line @ end of list of @ random line number. or can delete line. need write function or 2 when called upon undo or redo last command , can undo or redo 10 commands in row. ideas best way go undoing commands involving linked lists? you need store history of commands in list. undo, @ recent command , reverse action.

messagebox - How to display message box when starting up an Inno Setup installer -

Image
how display message box information, when starting installer made in inno setup? like setup of reloaded games does: call msgbox function initializesetup event function : function initializesetup(): boolean; begin msgbox('some message.', mbinformation, mb_ok); result := true; end;

python - Scraping SVG charts -

i trying scrape following svg's following link: https://finance.yahoo.com/quote/aapl/analysts?p=aapl the portion trying scrape follows: images here i not need words of chart (just graphs themselves). however, have never scraped svg image before , i'm not sure if possible. looked around not find useful python packages directly this. i know can take screenshot of image python using selenium , use pil crop , save svg, wondering if there more direct way grab these charts off page. useful packages or implementations helpful. thank you. edit: got down votes not sure why here how implement in way.. import sys import time pyqt4.qtcore import * pyqt4.qtgui import * pyqt4.qtwebkit import * class screenshot(qwebview): def __init__(self): self.app = qapplication(sys.argv) qwebview.__init__(self) self._loaded = false self.loadfinished.connect(self._loadfinished) def capture(self, url, output_file): self.load(qurl(url)) self.wait_load() # set ...

angular - In angular2 I'm using canActivate but when it returns false it still goes to the route -

in angular2 i'm using canactivate when returns false still goes route. here code below: canactivate(route: activatedroutesnapshot, state: routerstatesnapshot): boolean { this.isauthrequired = route.data.isauthrequired; this.iscompanyview = route.data.iscompanyview; return this.init(); } this code returns true or false depending on routes data e.g. isauthrequired etc. is still meant go route? because , shows blue screen no console errors i'm wanting redirect homepage or atleast stay on previous page. how feature mean't work , have suggestions. make sure returning boolean or promise or observar init() method. returning true init() navigate selected routing. returning false prevent page navigation current screen. something below :- init(): boolean{ /* application logic */ return true; } canactivate(route: activatedroutesnapshot, state: routerstatesnapshot): boolean { this.isauthrequired = route.data.isa...

ios - swift 3 push notifications on parse -

i using bitnami parse server on aws run social media app. having trouble push notifications. i arranged certificate, domain id, push notification enable options etc. i foun code below on eladnava . worked on js , 1 has manually run code send manual push notification. however want execute push notification system within app automate notification process. like, if gets message inside of app, have push notification. do have idea how can that? bear in mind i'm using parse. var apn = require('apn'); // set apn apns auth key var apnprovider = new apn.provider({ token: { key: '', // path key p8 file keyid: '', // key id of p8 file teamid: '', // team id of apple developer account (available @ https://developer.apple.com/account/#/membership/) }, production: false // set true if sending notification production ios app }); // enter device token xcode console var devicetoken = ''; // prepare new not...

vb.net - Creating a WPF control that uses datatemplates -

i'm trying build control display items in sort of scheduling grid, placed horizontally depending on category in, , vertically depending on time scheduled , how time item take complete. inheriting system.windows.controls.control , default style , template shown below: <style targettype="khs:timegrid"> <setter property="template"> <setter.value> <controltemplate targettype="khs:timegrid"> <border background="{templatebinding background}" borderbrush="{templatebinding borderbrush}" borderthickness="{templatebinding borderthickness}"> <scrollviewer horizontalscrollbarvisibility="auto" verticalscrollbarvisibility="disabled"> <dockpanel> <grid name="part_hea...

c# - Why doesn't IGrouping inherit IEnumerable<KeyValuePair> like IDictionary? -

igrouping: public interface igrouping<out tkey, out telement> : ienumerable<telement>, ienumerable idictionary: public interface idictionary<tkey, tvalue> : icollection<keyvaluepair<tkey, tvalue>>, ienumerable<keyvaluepair<tkey, tvalue>>, ienumerable so, idictionary implements ienumerable<keyvaluepair<tkey, tvalue>> while igrouping implements ienumerable<telement> . if elements of igrouping contain keys, why interface not use keyvaluepair ? seems methods implemented in idictionary useful igrouping such idictionary.containskey unavailable in igrouping , meaning attempt find key on group (in o(1) time) like: list<int> mylist = new list<int>{ 1, 2, 3, 1}; var grp = mylist.groupby(x => x).todictionary(x => x.key, x => x.count()); if (grp.containskey(somevalue)){...} am using igrouping wrong? missing? to find if particular igrouping<tkey, tvalue> contains particular tke...

css - Css3 div layout with column count -

i layout divs in columns of 3. using column count this. have set wrapper size 1000x300px, should fit 3x5 divs. div spread out of wrapper , not fit inside? <div id="wrapper"> <div class="box">0</div> <div class="box">1</div> <div class="box">2</div> ... </div> https://jsfiddle.net/nhmu3ws0/ edit: i want achieve layout divs: 1 4 7 ... 2 5 8 3 6 9 answer: i needed this: display: flex; flex-direction: column; flex-wrap: wrap; edit so, achieve layout have described in updated question, need remove column-count properties, restrict columns three. to have unlimited number of columns 3 100px high divs in each one, constrain height of parent 3 × 100px i.e. 300px , define column-width property. example: https://jsfiddle.net/nhmu3ws0/2/ because columns repeat beyond containing parent element if not fit within bounds of parent. in fiddle, have defined height ...

javascript - Lightify-Rest API with JS - CORS Error -

i'd use osram-lightify rest-api ( https://eu.lightify-api.org/ ), everytime post initial token error (invalid credentials) have used these credentials in node js example. guess related fact api doesn't allow cross origin request, have found service works. my code (without cors related, yes have inserted real credentials): $.post("https://eu.lightify-api.org/lightify/services/session", {"username" : "username", "password" : "password", "serialnumber" : "sn"}, function(data,error){ console.log(data); console.warn(error); });

arrays - Excel INDEX MATCH retrieves information randomly -

i'm have issue excel index (with double match) funtion retrieves data seems randomly. have following data set (imgur). what needs do: display pax count on schedule @ correct position if match between gatenumber (columa) , time (row1) found in data list. i used: {=iferror(index($i$54:$i$91,match($a2&i$1,$h$54:$h$91&$g$54:$g$91,0)),"")} the issue: values retrieved, not (marked in gray) without differences in function/data. remarks: all cell formats same. all cells set array {}. increasing index array 3 columns data , adding [column_num] 3 not help. if change values time in list move correct new position, not. software version (excel) professional plus 2013. any on cause of problem be, solution or alternative method appreciated!

javascript - Trouble declaring and linking a controller together in my app -

link github so have 3 files. there source folder contains app.js file , contains folder called sheets_api_quickstart, contains quickstart.js, , folder called project, contains waiting_list.html i attempted set controller call function test() waiting_list.html using button. unfortunately app won't start after trying implement this. gives console error failed load resource: net::err_connection_refused is there obvious i'm missing or doing wrong? app.js var express = require('express'); var app = express(); var fs = require('fs'); var myapp = angular.module('myapp.controllers', []); //var file = "daycaredb.db"; //var exists = fs.existssync(file); //var db = opendatabase(file); app.use(express.static(__dirname + '/project')); app.use(express.static(__dirname + '/')); app.get('/', function (req, res) { res.sendfile('project/home.html', {root: __dirname }); }); app.listen(3000); console.log(...

How to interact between Front End (HTML/CSS and JavaScript) and Back End(MySQL)? -

i creating college project using html/css , javascript create front end , use mysql end. problem encountering know how work on front end , end separately, not how them working together. figured out node.js can used interact mysql database. but, how pass data entered web page mysql server query or store. get data mysql server , show on front end. i did search everywhere, included php not supposed use @ all. have looked everywhere answer. not asking question in right way. any advice or useful api useful. thanks.

Java Banking program -

Image
this question has answer here: how compare strings in java? 23 answers i ask following issue. im trying build simple banking system in java. idea create new customer current account. after opening customer possible create saving accounts well. customer has provide passport id. passport id program checks if customer exist in database or not. so far have 2 classes bank , customer , 2 forms main , newcustomerform. the problem when customer created , added database(arraylist) if create new customer , type passport id exists program still comes false value. if passport value in database , new passport value same. here codes: bank.java import java.util.arraylist; public class bank { //variables private arraylist<customer> customers = new arraylist<customer>(); //holds customers of bank private double interestrate=2.5; private double c...

php - I can not access the url from my own server -

the url of web example is: http://myweb.com/ script hosted on dedicated. not work same url of server. <?php $url = 'http://myweb.com/myfbprofilpic.jpg'; header('content-type: image/jpeg'); imagejpeg(imagecreatefromjpeg($url)); ?> php warning: imagecreatefromjpeg(): gd-jpeg: jpeg library reports unrecoverable error: in php warning: imagecreatefromjpeg(): ' http://myweb.com/myfbprofilpic.jpg ' not valid jpeg file in php warning: imagejpeg() expects parameter 1 resource, boolean given in with url of different host if works <?php $url = 'http://www.google.com.do/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png'; header('content-type: image/jpeg'); imagejpeg(imagecreatefromjpeg($url)); ?>

machine learning - is this tomek link implementation faulty? -

the algorithm definition tomek links states: " suppose {e1,…,en}⊂rk dataset, each ei having 1 of 2 labels + or −. pair (ei,ej) called tomek link if ei , ej have different labels, , there not el such d(ei,el)< d(ei,ej) or d(ej,el)< d(ei,ej) ", d(x,y) distance between x , y. i created "toy" data set understand tomek links better (code attached). used package "unbalanced" function ubtomek. function implementation (it's on github) looks nearest neighbor of minority class points, , if belong majority class - couple declared tomek link. think missing something, because checking d(ei,ej) , should check d(ej,ei). opinions on this? if right - i'll drop developers message bug, if i'm wrong - i'll understand tomek links better.

.NET application keeps crashing on Windows (clr.dll) -

this windows crash report .net-based exe file generates. problem related clr.dll would updating .net help? should use windows "hotfix"? help appreciated. source spit1.exe summary stopped working date ‎05/‎11/‎2016 14:34 status not reported description faulting application path: c:\users\administrator\desktop\investors\spit1.exe problem signature problem event name: appcrash application name: spit1.exe application version: 4.0.0.0 application timestamp: 51f67134 fault module name: clr.dll fault module version: 4.0.30319.34209 fault module timestamp: 5348a1ef exception code: c00000fd exception offset: 0000000000009257 os version: 6.3.9600.2.0.0.272.7 locale id: 2057 additional information 1: 67f4 additional information 2: 67f446138f435d3b51a74bd9fb86b17d additional information 3: e3b7 additional information 4: e3b7b975b457d4dc9338dfb3498c6eae 0xc00000fd means stack overflow (how apt). there bug in code, go find it.

username, password program in bash -

i have program asks input user on username , password stores in text file column 1 usernames , column 2 passwords, need command replaces password when user inputs username , new password, heres have #!/bin/bash #admin menu #register user echo enter username of user want register. read reguser echo enter password of user want register. read regpass user_pass="username_pass.txt" if [ ! -e "$user_pass" ]; echo "creating username , passwords file" touch $user_pass fi echo "$reguser $regpass" | cat >> $user_pass echo user succesfully registered. #change password echo "enter username want change password for" read change1 change2=$(grep -q $change1 username_pass.txt) if [ $change2=0 ]; echo enter new password read newpass awk -v newpass="$newpass" -v change1="$change1" '$1 ~ change1 {$2 = newpass}' username_pass.txt #i tried didnt work echo "password changed!" else echo...

ios - Pass UISwitch State from One View Controller to Another ViewController -

i have uiswith in viewcontroller a. want pass state of uiswitch viewcontroller b. using objective c. code i'm using in viewcontroller a: if (![switchview ison]) { nslog(@"off"); } else { nslog(@"on"); [comment setobject:@"yes" forkey:kesactivityprivatekey]; } i need save value of uiswitch in viewcontroller b. any appreciated. don't try access view controller's view hierarchy directly. should treat view controllers views (and switch kind of view) private. set ibaction on switch points owning view controller. in action save sate of switch property of view controller. you can access property other view controller.

java - Read in 5 numbers from a user and compute the frequency of positive numbers entered -

having difficulty trying write code problem above. please find code below. have read in 5 numbers , compute frequency of positive numbers entered. import java.util.scanner; public class lab02ex2partb { public static void main (string [] args){ scanner input = new scanner(system.in); system.out.println("please enter positive integer"); int number = input.nextint(); for(int = -2 ; < 4 ; i++) system.out.println("positive count is: " + i); } } your problem have task needs repeated (about user entering value); loop (the perfect mean things repeatedly) ... doesn't cover part! for(int i=-2 ; i<4 ; i++) system.out.println("positive count is: " +i); instead, like: for (int loops = 0; loops < 5; loops++) { int number = input.nextint(); then of course, need remember 5 values, easiest way there: use array; turning code into: int loopcount = 5; int numbe...

java - Mocking an injected field in unit tests -

i have presenter class uses field injected through dagger, looks this: public class rsslistpresenter { @inject rssservice rssservice; // <-- injected field public rsslistpresenter() { setupdi(); } private void setupdi() { daggernetworkcomponent.builder() .networkmodule(new networkmodule()) .build() .inject(this); } public void loaditems() { rss rss = rssservice.getrssfeed() // .... } } everything works fine. now, unit test rsslistpresenter class. question how provide mock rssservice presenter? ofcourse can add new method setrssservice(rssservice rssservice) presenter , use provide mock unit tests, adding method unit tests not feel right. correct way handle this? for completeness here module , component declarations: @singleton @component(modules = networkmodule.class) public interface networkcomponent { void inject(rsslistpresenter presenter); } ...

json - HowTo enforce Play framework 2.4.x to serialize field with empty list -

i'm using scala play! 2.4.x , trying searialize case class: case class myevent( id: string, parentid: option[parentref] = none, stepstatus: string = "undefined", artifacts:seq[string] = seq.empty, events:seq[string] = seq.empty ) the problem serialized json doesn't contain fields artifacts , events since default values empty sequences. receiver expects field names if empty. have force json serializer add "artifacts": [], "events":[] what right way without writing whole formatter manually? have dozens fields. so, 2.4.x works way: case class myevent( id: string, parentid: option[parentref] = none, stepstatus: string = "undefined", artifacts:seq[string] = seq(), events:seq[string] = seq() ) seq() forces play json generate "events": [] fine me. find play-json stuff bit on engineered. :( miss google gson java past :) dead simple , works.

How to plot Community-based graph using igraph for python -

Image
i have graph extract communities using louvain-algorithm implementation: clusters = g.community_multilevel( weights=none, return_levels=false) i apply different colouring each community: new_cmap = ['#'+''.join([random.choice('0123456789abcdef') x in range(6)]) z in range(len(clusters))] colors = {v: new_cmap[i] i, c in enumerate(clusters) v in c} g.vs["color"] = [colors[e] e in g.vs.indices] finally plot graph: visual_style["layout"] = g.layout_fruchterman_reingold(weights=g.es["weight"], maxiter=1000, area=n ** 3, repulserad=n ** 3) igraph.plot(g, **visual_style) i bellow result: my question : instead of mixed-up graph, there way using specific layout, plot every of 4 community grouped itself? separate every community in different area of graph increasing visibility of inner structure few edges higher betweenness-centrality connecting communities? i have used contract-vertices function helped me visualise, ...

C++ destructor crashing program -

Image
i've spent couple hours trying figure out why program misbehaving , haven't been able figure out yet. the copy constructor , assignment operator never called. either means isn't rule of 3 problem, or declared them incorrectly defaults being called. error mentions valid heap pointer block, maybe using 'new' keyword incorrectly? let me know if more infmoratoin required me out, thanks. main: #include "ring.h" #include <iostream> int main() { ring<int> int_ring(3); int_ring.add(1); int_ring.add(2); int_ring.add(3); int_ring.add(4); // overwirte 1 (int = 0; < int_ring.size(); i++) { std::cout << int_ring.get(i) << '\n'; } return 0; } ring template class: #include <iostream> #include <string> template<class t> class ring { public: ring(int size); ring(const ring &other); ~ring(); t* begin(); t* end(); ring& op...

Init script for Cassandra with docker-compose -

i create keyspaces , column-families @ start of cassandra container. i tried following in docker-compose.yml file: # shortened clarity cassandra: hostname: my-cassandra image: my/cassandra:latest command: "cqlsh -f init-database.cql" the image my/cassandra:latest contains init-database.cql in / . not seem work. is there way make happen ? we tried solve similar problem in killrvideo , reference application cassandra. using docker compose spin environment needed application includes datastax enterprise (i.e. cassandra) node. wanted node bootstrapping first time started install cql schema (using cqlsh run statements in .cql file you're trying do). approach took write shell script our docker entrypoint that: starts node in background . waits until port 9042 available (this clients connect run cql statements). uses cqlsh -f run cql statements , init schema. stops node that's running in background. continues on usual entrypoint ...

SSL Errors on Python packages -

i programming novice, , i'm trying learn python. when attempt install packages on windows 10 (example: pip install -u xxx) keep getting following error: could not fetch url https://pypi.python.org/simple/xxx/ : there problem confirming ssl certificate: [ssl: certificate_verify_failed] certificate verify failed (_ssl.c:645) - skipping not find version satisfies requirement xxx (from versions: ) no matching distribution found xxx does have idea how fix this? i've gathered problem related internet configuration, far i've been unable find specific instructions on how fix this. again, i'm beginner, please no advanced jargon. in advance! my first guess installation or setup. besides, new version of pip came out couple of days ago , should upgrade. try getting get-pip.py script this page , follow instructions run it. try using new pip (9.0) xxx package above.

r - How to get value of selectinput and show a variable data in another selectinput with shiny -

i want retrieve selected value user, put code in server.r inside finction selected_value <- input$valtext <-filter (catalog, gene_name == selected_value) b <-select (a,snp) valtext : id of selectizeinput then want show snp correspondent of selected_value user (b) in selectizeinput in "choices", need retrieve variable b : selectizeinput( 'snpvalue', 'choisir le snp visualiser :', choices = "" , multiple = true, options = list(maxitems = 2) ) my problem can not see b in data, seems nothing change !nothing execute, because if have variable b, can easly show in selectizeinput regards. in ui.r , replace second selectizeinput uioutput('snpselect') in server.r , add output$snpselect <- renderui({ selected_value <- input$valtext <- filter (catalog, gene_name == selected_value) b <- select (a,snp) selectizeinput( 'snpvalue', 'choisir le snp visualiser :...

How to remove backslash escaping from a javascript var? -

i have var var x = "<div class=\\\"abcdef\\\">"; which is <div class=\"abcdef\"> but need <div class="abcdef"> how can "unescape" var remove escaping characters? you can replace backslash followed quote quote via regular expression , string#replace function: var x = "<div class=\\\"abcdef\\\">"; x = x.replace(/\\"/g, '"'); document.body.appendchild( document.createtextnode("after: " + x) ); note regex looks 1 backslash; there 2 in literal because have escape backslashes in regular expression literals backslash (just in string literal). the g @ end of regex tells replace work throughout string ("global"); otherwise, replace first match.

matlab - Is there a version of bsxfun that works on structure arrays? -

why can this: a = [1 2]; b = [3 4]; bsxfun(@(ai,bj) ai + bj, a, b') % 4 5 % 5 6 but not this: a = struct('x', {1 2}); b = struct('x', {3 4}); bsxfun(@(ai,bj) ai.x + bj.x, a, b'); % error using bsxfun % operands must numeric arrays. and replacement function exist works in both cases? this may not general solution * particular example easy convert structure array numerical array inside bsxfun, using comma-separated-list generator syntax , , using original anonymous function, i.e. >> bsxfun(@(ai, bj) ai+bj, [a.x], [b.x]') ans = 4 5 5 6 and should still leverage computational efficiency conferred bsxfun (as opposed slower " repmat + arrayfun " approach, instance). * e.g. might not work intended if field contains array instead of scalar, since expansion comma-separated-list different

mpi - mpd_uncaught_except_tb while starting mpd deamon -

Image
i'm getting error while starting mpd deamon below full stack trace ip-172-31-25-209_53762: mpd_uncaught_except_tb handling: <class 'socket.error'>: [errno 2] no such file or directory <string> 1 bind none /usr/bin/mpdlib.py 691 __init__ self.sock.bind(filename) /usr/bin/mpdlib.py 1175 __init__ filename=self.confilename,listen=1,name=name) /usr/bin/mpd 248 run self.conlistensock = mpdconlistensock(secretword=self.parmdb['mpd_secretword']) /usr/bin/mpd 1643 <module> mpd.run() [1]+ exit 1 mpd how fix ? i'm staring mpd deamon because error when run mpiexec mpdroot: cannot connect local mpd at: /tmp/mpd2.console_root probable cause: no mpd daemon on machine possible cause: unix socket /tmp/mpd2.console_root has been removed mpiexec_ip-172-31-25-209 (__init__ 1208): forked process failed; status=255

javascript - how to get the map bounds? -

i'm migrating leaflet , if needed map bound used following code: var b = map.getbounds(); $scope.filtromapa.lat1 = b.getsouth(); $scope.filtromapa.lat2 = b.getnorth(); $scope.filtromapa.lng1 = b.getwest(); $scope.filtromapa.lng2 = b.geteast(); those values valid latitude/longitude positions therefore send backend , query position inside area. how can using openlayers? for have is: var b = map.getview().calculateextent(map.getsize()); however positions aren't valid latitude/longitude positions. i'm using openlayers 3.19.1 following answer @ https://gis.stackexchange.com/questions/122250/how-to-get-the-feature-location-in-openlayers-v3 ( and assumptions ) var currentextent = map.getview().calculateextent(map.getsize()), tlpoint = ol.extent.gettopleft( currentextent ), brpoint = ol.extent.getbottomright( currentextent ), tlcoords = ol.proj.transform( tlpoint, 'epsg:3857', 'epsg:4326' ), brcoords = ol.proj.transform(...

driver - Writing Applications with C -

i took lot of time learn c, , pointers , arrays , strings. want know how apply this. title says applications, want know how write firmware, , device drivers , kernels. if point me books,on line resources, , things of nature. the best way learn write c program find project work on. however, need enough knowledge in order achieve this. according understanding, of c language beginners learned c , have numbers printed in console (black box). c low-level language, annoying. think way programming language need cultivate interest, black box not way. so, suggest in process of learning c language, combine api. teaching people write program interface better people day long face black box. here books recommend: 1. c programming language 2. c primer plus

How to used linspace matlab function to get the and the y of all pixels in image? -

i have image of 200x200 * 3, , should find x , y of each pixel of image using linspace matlab function. have used mesh grid function following code: ny=200; % # pixels in y direction nx=200; % # pixels in x direction resolution=1; % size of pixel img=rand(ny,nx,3); % random image y=(img(1:ny))*resolution-resolution/2; x=(img(1:nx))*resolution-resolution/2; [x,y]=meshgrid(x,y); but supervisor told me use function linspace , cannot understand how.can me please the reason can think of supervisor wants use linspace creating x , y vector inputs meshgrid . linspace alone not sufficient generate of pixel coordinates, you'll have use meshgrid , ndgrid , repelem or repmat . the 1 advantage linspace has on doing 1:resolution:ny linspace ensures endpoints appear in range. example, if do >> 1:.37:4 ans = 1.0000 1.3700 1.7400 2.1100 2.4800 2.8500 3.2200 3.5900 3.9600 you don't 4 last point. however, if use linspace : ...

python - nested loop in list comprehension -

i have list of words in l if of exists in first index of each tuple in l2, remove entire tuple. my code: l = ['hi', 'thanks', 'thank', 'bye', 'ok', 'yes', 'okay'] l2 = [('hi how u', 'doing great'), ('looking me', 'please hold')] l3 = [k k in l2 if not any(i in k[0] in l) ] somehow code not work , empty list l3. i want l3 = [('looking me', 'please hold')] split k[0] list of words: [k k in l2 if not any(i in k[0].split() in l)] this way checks if i matches word exactly. it interpreted if k[0] not starts of l , can this: [k k in l2 if not k[0].startswith(tuple(l))]

java - Difference between Producer/Consumer pattern and Observer Pattern -

i understand difference between observer pattern , common problem of producer/consumer , since both require synchronization changes available , , how go implement both ( if different ) the difference between them nature of synchronization required. in case of observer pattern whenever change of interest made in observed object observers notified immediately. immediate per change synchronization required pattern. in fact observer patterns doesn't require different thread. thread changing observed object can notify registered observers. however, in case of producer-consumer required synchronization consumer must wait when there no element , producer must wait when buffer full. per object synchronization not required. producer can produce multiple objects before consumer consume of them , consumer can consume multiple objects in 1 go. immediate notification observer not needed here. as far implementation, can have @ wikipedia articles them: observer pattern , produ...

Inconsistent Accessibility in Lists c# -

i'm following rpg c# tutorial, , have come across error. not explained in tutorial, , i'm unsure did wrong. here class: using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace engine { public class monster : livingcreature { public int id { get; set; } public string name { get; set; } public int maximumdamage { get; set; } public int rewardexperiencepoints { get; set; } public int rewardgold { get; set; } public list<lootitem> loottable { get; set; } public monster(int id, string name, int maximumdamage, int rewardexperiencepoints, int rewardgold, int currenthitpoints, int maximumhitpoints) : base (currenthitpoints, maximumhitpoints) { id = id; name = name; maximumdamage = maximumdamage; rewardexperiencepoints = rewardexperiencepoints; rewardgold = rewardgold; loottable = new list<lootitem>(); } }...

java - Why is my withdraw method allowing me to take out more then has been deposited? -

i have write atm program computer science class. works part, apart couple logic problems within programs itself. far, can tell, atm deposit correct amount of money tell however, when withdraw money, not withdraw correct amount if purposefully make error (such trying take out amount not multiple of 20). running issue if try take out more money in account, become negative value, not want allowed. want not subtract value causes become negative , prompt user until value less or equivalent balance able taken out. rather new coding please excuse rather messy code. error around else if statement option == 3. here code: import java.io.*; import java.util.*; public class atmlauncher { public static int options=0; public static void main(string [] args) { scanner input = new scanner(system.in); atmtester atm = new atmtester(); system.out.println("login: \n(case sensitive)"); system.out.print("username > "); string...

eclipse - a fatal error in compiling a c++ program -

i using eclipse kepler c++, in compiling simple hello world program saw error. c:\mingw\include\_mingw.h:73:20: fatal error: w32api.h: no such file or directory while whole windows bellow. 09:15:59 **** incremental build of configuration debug project project1 **** info: internal builder used build g++ "-ic:\\mingw\\lib\\gcc\\mingw32\\5.3.0\\include\\c++" "-ic:\\mingw\\lib\\gcc\\mingw32\\5.3.0\\include\\c++\\backward" "-ic:\\mingw\\lib\\gcc\\mingw32\\5.3.0\\include" "-ic:\\mingw\\lib\\gcc\\mingw32\\5.3.0\\include-fixed" "-ic:\\mingw\\lib\\gcc\\mingw32\\5.3.0\\include\\c++\\mingw32" "-ic:\\mingw\\include" -o0 -g3 -wall -c -fmessage-length=0 -o "src\\project1.o" "..\\src\\project1.cpp" in file included c:\mingw\include\wchar.h:53:0, c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:44, c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\postypes.h:40, ...

C# Winform – Extending solution working for single DataSet to Multiple DataSets for ReportViewer Reports with the help of RDL file -

Image
i had code taken reza aghaei’s solution , had helped me solve problem single dataset using microsofts reportviewer control on winforms. working part: calling form: string sql = "select bk_book_details.id, bk_book_details.book_id, bk_book_details.book_no, bk_book_details.book_name, bk_book_details.edition_id, bk_book_details.condition_id, bk_book_details.publication_year, bk_book_details.price, bk_book_details.purchase_price, bk_book_details.reference_no, bk_book_details.book_status, bk_book_details.purchase_id, bk_book_details.purchase_date bk_book_details"; string reportlocation = path.getdirectoryname(assembly.getexecutingassembly().location) + @"\reports\lms_book_price_invoice.rdl"; var f = new reportform(); f.reportpath = reportlocation; datatable dt = (datatable)dataadapter.current.loaddata(sql, "loaddatatable"); list<datatable> ldt = new list<datatable>(); ldt.add(dt); f.reportdata = new list<datatable>(ldt); f.showdialog(...

find the year when an event occurred of a panel data in R -

have question when dealing data frame constructed panel data, firm<-c("1","1","1","1","1","2","2","2","3","3","3","3") year<-c("2001","2002","2003","2004","2005","1998","1999","2000","2004","2005","2006","2007") event<-c("yes","yes","yes","no","no","yes","yes","no","yes","no","no","no") df<-data.frame("firm"= firm,"year"= year, "event" = event) what want : firm<-c("1","1","1","1","1","2","2","2","3","3","3","3") year<-c("2001","2002",...

HTML5 Form Validation Multiple checkboxes allow multiple not all -

i using html5 form validation, need either fieldset or @ least 1 box checked form validate. when use following code: <input type="checkbox" id="category" required name="category" value="singer" class="smoothborder"> singer (solo) <input type="checkbox" id="category" required name="category" value="singerduo" class="smoothborder"> singer (duo) <input type="checkbox" id="category" required name="category" value="band" class="smoothborder"> band it forces user select checkboxes validate form, when may need check 1 or 2. if change 'required name' 'name' user not forced check box, , need @ least 1 info required. is there workaround without using javascript?

Why does my Android Application crash after I add a listView to it? -

it ran correctly before added new code program. wanted add listview show message, doesn't work. when app gets activity, program crashes... added : string[] studentlist = {"zhangsan","lisi"}; listview stdlistview = (listview)findviewbyid(r.id.studentlistview); arrayadapter<string> arrayadapter; arrayadapter = new arrayadapter<string>(this,android.r.layout.simple_list_item_2,studentlist); stdlistview.setadapter(arrayadapter); stdlistview.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { string result = parent.getitematposition(position).tostring(); alertdialog.builder choice = new alertdialog.builder(editactivity.this); choice.settitle(result); } }); to: protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestat...

django - pip install pyscopg2 error: cdefs.h not found -

on debian 8, i'm trying setup django 1.10 project. installing requirements have problem. $ pip install psycopg2 /usr/include/features.h:374:25: fatal error: sys/cdefs.h: file or directory not found i search in package cdefs.h is: $ dpkg -s cdefs.h libc6-dev:amd64 : /usr/include/x86_64-linux-gnu/sys/cdefs.h i checked if have installed , yes, it's installed. what strange in same server have django project , it's working! what i'm forgetting??

java - Show a 'Please wait' alert on JSP when button is clicked. when the processing is complete on servlet, remove the alert -

my jsp page ondownload function calls servlet function below.i show alert 'please wait' when download button clicked.. when processing complete on servlet, close alert. jsp code: function ondownload(){ var dtype = 'download'; var url = "<%=strdownloadurltest%>"+"/downloadservlet?downloadtype="+dtype+"&pnumber="+'<%=custpno%>'; document.getelementbyid('downloadp').href = url; document.getelementbyid('downloadp').target='_blank'; } processing @ servlet side, code: byte content[]=null; try { getpdao getpdao= new getpdao(); for(int i=0;i<5;i++) { content=getpdao.getpfromeb( strpn); dateformat df = new simpledateformat("dd/mm/yy hh:mm:ss"); date dateobj = new date(); content=null; if(content==null) { ...

Reconstructing image by inverse filter issue in MATLAB -

i used transfer function 'motion' imnoise in spatial domain. try deconvolve in frequency domain not working!! codes here: clc close clear display('welcome wiener , invert reconstruction image ...'); path = input('enter pictures path:','s'); info=imfinfo(path); resolution=info.width*info.height; i=imread(path); if strcmpi(info.colortype,'truecolor') i=rgb2gray(i); end psf=fspecial('motion',70,45); f=imfilter(single(i),psf); %f=imnoise(f,'gaussian',0,0.001); %invert filtering pq=paddingsize([info.height info.width],'pwr'); f=fft2( single(f) ,pq(1),pq(2) ); psf=fft2( psf ,pq(1),pq(2) ); fhat=f./psf; fhat=ifft2(fhat); imshow(fhat(1:info.height,1:info.width)); the codes correct there noise amplification . more detail at: http://blogs.mathworks.com/steve/2007/08/13/image-deblurring-introduction/

SQL Azure backup failed - all logins used and now cant connect to the db -

the automated backup failed leaving dead database backup process , production database no 1 can connect reports logins in use (120) i cant connect kill connections either on azure sql paas dont access master. can help? how kill connections azure sql database if can't access it? the above link should , result of having similar issue you. check out dac admin connection link within it.