Posts

Showing posts from August, 2010

c - UDP -- Socket - bind error - Address already in use? -

i see address in use on bind() while system starting up. when reload system plenty of times, see once in while 1 out of 100, see following error: bind failed.error: address in use. on every reboot of system - closing socket using close(gtx.i4txsockid) . here code, not sure on how can debug this. i have added netstat -ap find out problem it. on success, see: netstat: /proc/net/tcp6: no such file or directory udp 0 0 0.0.0.0:syslog 0.0.0.0:* 1562/syslog-ng udp 0 0 0.0.0.0:49155 0.0.0.0:* 1817/app.exe on failure, see: netstat: /proc/net/tcp6: no such file or directory udp 0 0 0.0.0.0:45825 0.0.0.0:* 1816/app.exe udp 0 0 0.0.0.0:syslog 0.0.0.0:* 1562/syslog-ng udp 0 0 localhost:49155 0.0.0.0:* 1816/app.exe i have added following

java - How to resize background of imagebutton clickable space -

Image
i have custom imagebutton , want custom imagebutton clickable. of surrounding area of button "clickable" , initiates new activity. want minimize "clickable background" space. how can it? <imagebutton android:id="@+id/start_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_alignparenttop="true" android:background="@null" android:src="@drawable/flashcardbutton" /> well giving shot api found imagebutton has method signature public void oninitializeaccessibilitynodeinfo(accessibilitynodeinfo info) and accessibilitynodeinfo class has method public void setboundsinscreen (rect bounds) so said think should achieve trying do, in adition @sushil answer should make work.

Laravel Eloquent: getDictionary with object value as value of result -

Image
currently, $mymodel->getdictionary(); returns: what looking this: "7gct5yatvuxbmy2" => "leadership", "7nrxzepqczmshqm" => "...", "..." => "...", ... the way have managed is: $construct_obj = organizationalconstruct::where('is_root', 0)->where('organization_id', $this->current_company->company_id)->get(); $constructs = []; $constructs[''] = ''; ($i = 0; $i < count($construct_obj); $i++) { $constructs[$construct_obj[$i]->organizational_construct_id] = $construct_obj[$i]->construct_name; } is there easier way of getting format "key" => "speific-column-value" ? i have tried: keyby lists getdictionary map you should call pluck directly on query, don't pull down attributes models: $dictionary = organizationalconstruct::where('is_root', 0) ->where('organization_id'

C File reading doesn't stop -

i writing simple server allows sending files using http protocol. have function puts file buffer. goes before read . file size printed correctly. on read program waits. char *get_file(char *dir) { fprintf(stderr, "get file\n"); char *buff; int fd; if (fd = open(dir, o_rdonly) == -1) { fprintf(stderr, "no such file: %s\n", dir); exit(6); } size_t size = fsize(dir); fprintf(stderr, "opened file, size: %ld\n", size); buff = malloc(size); read(fd, buff, size); fprintf(stderr, "to downloaded: %s\n", buff); char *response = make_file_response(buff); return response; } you have issue statement if (fd = open(dir, o_rdonly) == -1) according operator precendence == evaluated first , thus, fd being assigned value of comparison , not opened file descriptor. with compiler warnings enabled parentheses suggested, , correted expression be if ((fd = open(dir, o_rdonly))

asp.net - Select web.config or app.config Connection String based on Machine Name -

this question, loosely relates choose settings based on machine name asked previously, have more specific use it, hoping baked .net default. i 1 of several people in small team writing dotnet desktop , web applications. use git source repository, , becomes tiresome have change .config file connection strings each of development environments. i know there several ways overcome problem; range not storing .config files in repo in first place (and using .gitignore), through writing code parse configuration file manually adding prefixes etc suggested in other question. however, seems both overly simplistic , tedious; in production environment there may lots of legitimate reasons store multiple connection strings in config file - such having several servers - makes me think there has easier way it. so question this: is there way in dotnet .config files have multiple connection strings framework 'automatically' knows 1 load based on property, such environment or machine

java - How to show data as progress bar and circle percentage progress wheel? -

Image
i trying in app: but don't know start, should use "progressbar" in "form widgets" or there else? how can such thing done? should bee using? if have examples can link me appreciate it. try progress wheel if configure right, can want.

hibernate - @ManyToMany IllegalArgumentException calling getter id -

i'm having hard time solving exception org.hibernate.propertyaccessexception: illegalargumentexception occurred calling getter of com.mypackage.campaign.domain.promotion.id @ org.hibernate.property.basicpropertyaccessor$basicgetter.get(basicpropertyaccessor.java:187) @ org.hibernate.tuple.entity.abstractentitytuplizer.getidentifier(abstractentitytuplizer.java:341) @ org.hibernate.persister.entity.abstractentitypersister.getidentifier(abstractentitypersister.java:4491) @ org.hibernate.persister.entity.abstractentitypersister.istransient(abstractentitypersister.java:4213) @ org.hibernate.engine.internal.foreignkeys.istransient(foreignkeys.java:209) @ org.hibernate.event.internal.abstractsaveeventlistener.getentitystate(abstractsaveeventlistener.java:495) @ org.hibernate.event.internal.defaultsaveorupdateeventlistener.performsaveorupdate(defaultsaveorupdateeventlistener.java:100) @ org.hibernate.event.internal.defaultsaveorupdateeventlistener.onsaveorupdate(defaultsaveorupdateev

android - Start an Activity with a parameter -

i'm new on android development. i want create , start activity show information game. show information need gameid. how can pass game id activity? game id absolutely necessary don't want create or start activity if doesn't have id. it's activity has got one constructor 1 parameter. how can that? thanks. put int id new intent . intent intent = new intent(firstactivity.this, secondactivity.class); bundle b = new bundle(); b.putint("key", 1); //your id intent.putextras(b); //put id next intent startactivity(intent); finish(); then grab id in new activity : bundle b = getintent().getextras(); int value = -1; // or other values if(b != null) value = b.getint("key");

java - I am trying to look through an array and pick out certain strings -

we have complete task ap computer science class, , figured out base of code, stuck on part. here link complete assignment if try out. link: http://codingbat.com/prob/p254067 here code far: public int numvworthy(string wordslist[]) { int count = 0; string w = "w"; string v = "v"; for(int = 0; < wordslist.length; i++) { if(wordslist[i].contains(v) && wordslist.length - 1 == 0) { count++; } if(wordslist[i].contains(v) && == 0) { if(!wordslist[i + 1].contains(w)) { count++; } } if(wordslist[i].contains(v) && == wordslist.length - 1) { if(!wordslist[i - 1].contains(w)) { count++; } } } return count; } the syntax using incorect it should be if(wordslist[i].contains(v)) {

Request clips from Youtube videos? -

does youtube api (or api, whether free or paid) provide facility request specified chunk of video? example, can request section 4:37 4:39 of video id xch8e2h23nw? alternatively, there youtube-like service can this? i want grab tiny chunks of youtube video programmatically use part of creative video mashup app. this supported as3 video player , controlled "start" , "end" parameters. <object width="560" height="315"> <param name="movie" value="https://youtube.googleapis.com/v/m7lc1uvf-ve?version=3&fs=1&start=10&end=20"</param> <param name="allowfullscreen" value="true"></param> <param name="allowscriptaccess" value="always"></param> <embed src="https://youtube.googleapis.com/v/m7lc1uvf-ve?version=3&fs=1&start=10&end=20" type="application/x-shockwave-flash" allowfullscreen="true

javascript - How to use specific font with highlight.js -

updated proper link example i using hugo theme comes bundled css , uses highlight.js syntax highlighting. web pages have created show plain "courier" based fixed width font in code blocks see here example of site page i use font, sans-mono or more neat looking, shows on highlight.js web page here i'm not super familiar javascript , css, trying use them. there easier way tell highlight.js use specific font? assuming have font files available. thanks zeekay add css: pre > code { font-family: "sans mono", "consolas", "courier", monospace; } this use first font in list available on user’s system. fonts have different spacing real names, example if "sans mono" doesn’t work, try "sansmono" . make sure put monospace last @ least suitable font chosen if user doesn’t have of listed fonts. if doesn’t work, maybe it’s due selector specificity problem, default styles provided highlight.js overriding

r - How can I set a variable to zero when it is numeric(0)? -

data <-data.frame(i.1=c(rep(6,5)),i.2=c(6,7,7,7,8),j.1=c(11,11,11,13,9),j.2=c(11,11,12,13,9),freq=c(0.1,0.2,0.5,0.1,0.1)) i.1 i.2 j.1 j.2 freq 1 6 6 11 11 0.1 2 6 7 11 11 0.2 3 6 7 11 12 0.5 4 6 7 13 13 0.1 5 6 8 9 9 0.1 p1 <- data[data[,1] == 6 & data[,2] == 6 & data[,3] == 7 & data[,4] == 7,]$freq p1 - 5 not equal -5, since p1 not zero, numeric(0). in case, p1 defined? exists("p1") [1] true how can make equal zero? i solved doing if(!length(p1)) {p1 <-0} as suggested ananda mahto , dwin in comments above. thanks!

python - Excel export with Flask server and xlsxwriter -

so i've been using xlsxwriter in past export excel file containing 1 tab filled 2 pandas dataframes. in past i've been exporting file local path on user's computer i'm doing transition web interface. my desired output have same excel file code below, created in memory , sent user him/her download through web interface. i've been seeing lot of django , stringio i'm looking work flask , not find worked. is familiar problem? thanks in advance! xlsx_path = "c:\test.xlsx" writer = pd.excelwriter(xlsx_path, engine='xlsxwriter') df_1.to_excel(writer,startrow = 0, merge_cells = false, sheet_name = "sheet_1") df_2.to_excel(writer,startrow = len(df_1) + 4, merge_cells = false , sheet_name = "sheet_1") workbook = writer.book worksheet = writer.sheets["sheet_1"] format = workbook.add_format() format.set_bg_color('#eeeeee') worksheet.set_column(0,9,28) writer.close()

Program that finds every other character in the first half of a char array in C -

this first part of program , have few questions on how parts of work exactly. keep in mind first c program have written. scanf("%d",&numberoftimes); why need & , do? char input[][200]; array of strings or different? #include <stdio.h> #include <string.h> char outputs[100]; char input[][200]; int numberoftimes; void io(void){ scanf("%d", &numberoftimes); for(int = 0; < numberoftimes; i++){ scanf("%s",input[i]); } } this next part of code attempt @ solving problem suspect screwed use of function don't know 1 or used improperly in order result. (i provided example i/o of me code @ bottom). void stringmanipulation(char string[200]){ int strlength = strlen(string); int number = strlength/2; for(int = 0; <= number; i=i+2){ strcat(outputs,&string[i]); } } int main(void) { io(); for(int = 0; < numberoftimes; i++) { stringmanipulation(input[i]);

javascript - Return number's value from method on Number.prototype? -

Image
before going in details of issue i'm aware of modifying built in's prototypes. code written in typescript. ok i'm running in issue when i'm trying return number's value method on number.prototype. here definition on number.prototype: object.defineproperty(number.prototype, 'tap', { value: function numbertap (fn: (t: number) => void): number { fn.call(null, this.valueof()); return this.valueof(); } }); and test i'm running: describe('number.prototype.tap((value:number) => void): number', () => { it('is defined', function () { expect(number.prototype.tap).to.be.a('function'); }); it('returns same value entry point in method chain', () => { expect((1).tap(n => 5)).to.equal(1); }); }); it doesn't equal 1 [number 1] . if call [number 1].valueof() returns 1 . i'm calling this.valueof() when returning tap. know what's going on here. just tried fol

c - Getting an "implicit declaration of function" error in Code Blocks -

i still quite new c, , keep getting error in code blocks stops me running programs. error "implicit declaration of functions printf_s() , scanf_s(). here code: #define __stdc_want_lib_ext1__ 1 #include <stdio.h> int main(void) { int age = 0; char name[20]; printf_s("enter age: "); scanf_s("%d", &age); print_s("enter name: "); scanf_s("%s", name, sizeof(name)); printf_s("your name %s , %d years old.\n", name, age); return 0; } printf_s , scanf_s available if __stdc_lib_ext1__ defined library implementation. added since c11 standard. first have check __stdc_lib_ext1__ defined or not, should use printf_s or scanf_s . #define __stdc_want_lib_ext1__ 1 #include <stdio.h> int main(void) { int age = 0; char name[20]; #ifdef __stdc_lib_ext1__ printf_s("enter age: "); scanf_s("%d", &age); print_s("enter name: "); scanf

scala - Provide type-class when implementing/override method -

i prefer work more type-classes having issues: given following interface trait processor[a] { def process[b](f: => b): processor[b] } i have implementation needs ordering[a] other reasons. hence method process needs ordering[b] construct processor[b] .the following do, not work: class plant[a, oa <: ordering[a]] extends processor[a] { def process[b:ordering](f: => b): processor[b] = null // plant[b, ob <: ordering[b]] } how can provide ordering[b] implementation of process ? i know reason is, ordering[a] passed implicit second argument. don't know shouldn't there special support type-classes in scala similar haskell recognize want (only allow b s have ordering ) in implementation above without "workaround"? no, , shouldn't work @ all. given defnition of processor , code compile: val processor: processor[int] = foo() // foo() function returns processor processor.process[object](x => new object()) now if foo implem

c++ - printing values vector f[0] -

assuming have fraction class , want keep them in vector did create fraction vector however, don't know how read value inside vector, reading mean printing value out it turns out f[0] print out address of fraction instead of data of fraction void main() { fraction fr(2,5); vector<fraction*> f; f.push_back(&fr); cout<<f[0]<<endl; } you're storing pointers fraction in vector: vector<fraction*> . cout << f[0]->numerator << "/" << f[0]->denominator << endl;

payment gateway - BlueSnap API - metadata per transaction -

i integrating bluesnap gateway using payment api , converting stripe. bluesnap support storing meta data @ transaction level? yes additional information pertaining transaction can send using transaction-meta-data element. can include 20 metadata key-value pairs in transaction-meta-data element. more information how use metadata within bluesnap payment api can found here: http://developers.bluesnap.com/v2.0/docs/auth-capture#section-auth-capture-with-metadata

java - Add external path to JBoss 4 classpath settings -

i've inherited application runs on jboss 4.2.1.ga deployment cluster. application hybrid of technologies, primary view technologies used struts 1 & struts 2 (they co-exist). i struggling understand how application built , deployed. app using i18n front end, , uses standard bean:message tags retrieve translations: ex: <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %> <input type="text" name="searchfilter" id="searchfilterid" value="<bean:message key="ng.searchfor"/>" additionally, app has bunch of application.properties files (for each translation). however, when ear built , deployed, application*.properties files not packaged in war/ear. rather stripped , copied external shared folder on server (one nodes in cluster have access). concept, believe, properties can written central location, , loaded/reloaded on fly application. i don't understand, howeve

How to use session in domain class in grails -

this question has answer here: grails session variable domain validator 1 answer i want store loggedinuser in table. accessing loggedinuser using session.but getting error no such property session class. how use session in domain? class genderaudit { string name user doneby def genderaudit(gender gender,string operation) { this.name=gender.name this.doneby = session.loggedinuser } } domain classes shouldn't know http layer. set value service or controller has access data. also, note defining constructor fine, have define no-arg constructor hibernate since creates new empty instances , calls setters. in general don't use parameterized constructors in grails since map constructor added groovy convenient.

php - Timestamp in html -

Image
i trying store timestamp in database. html code: <form action="insert.php" method="post"/> <style> p{ float:center; } </style> <font color=red > <center>support or analysis tracker (soat) </center></font> </br> </br> <p align="left"> <label for="process"><font color=default>analysis/support</label> &nbsp</t> <select id="process" name="process"> <option value="analysis">analysis</option> <option value="support">support</option> </select> &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <label for="so_number"><font color=default>so_number</label> <input type="text" id="so_number" name="so_number" value ="so_" required/> &nbsp&nbsp&nbsp&nbsp&a

typescript - How can I find child components by type -

i want know call method of child(a) parent(b). using output emit parent(b) child(a). , working. don't want using way. want know how can find child(a) parent(b). a.component.ts @import {component, eventemitter} '@angular/core'; @component({ selector: 'com-a', template: '<button (click)="senddatas()">coma btn</button>', outputs: ['getitems'] }) export class comaclass{ public getitem = new eventemitter<any>(); datas: any[] = ['abc', 'def']; constructor(){ console.log('hello, i'm component a'); } senddatas(){ this.getitem.emit(this.datas); } somemethod(){ console.log('call method of component a'); } } and b.component.ts @import {component, ...} '...'; @import {comaclass} '~~/a.component.ts'; @component({ selector: 'com=b' template: '<com-a name="coma1" (getitem)=&q

javascript - jQuery Validate not firing on submit? -

i running issue jquery validate plugin [ https://jqueryvalidation.org/ ] not firing on form submit. the script checks out no syntax errors in lint. google chrome developer console not reporting issues. yet form submits without validating anything. see code snippet below. $(document).ready(function () { $('input[name=donationtype]:radio').on('change', function () { if ($('#donationtypeindividual').is(':checked')) { $('#companyname').prop( 'disabled', true ); } else { $('#companyname').prop( 'disabled', false ); } }); $('#inhonorof').on('change', function () { if ($('#inhonorof').is(':checked')) { $('#inhonorofname').prop( 'disabled', false ); } else { $('#inhonorofname').prop( 'disabled', true ); } }); $('#inmemoryof').on('change', function () { if ($('#

php - Laravel Form Update can't get the right value -

so make laravel form update index.blade <div class="col-sm-12"> <div class="formrow row"> <div class="form-group"> <div class="divlabel col-sm-2"> <label>kode program studi:</label> <span class="required">*</span> </div> <div class="divinput col-sm-8"> <select id="id" data-plugin-selecttwo class="form-control populate placeholder" title="kode program studi harus diisi" name='id' required data-plugin-selectwo> <option value="">-pilih nama user-</option> @foreach ($users $user) <option class="form-control" value = '{{$user->id}}'>{{$user->id.' | '.$user->name}}</option> @endforeach <label class="error" for="id"></label> </select>

Build a multi node Kafka cluster on docker swarm -

i found docker image kafka https://hub.docker.com/r/spotify/kafka/ and can create docker container using command documented in link docker run -p 2181:2181 -p 9092:9092 --env advertised_host=`boot2docker ip` --env advertised_port=9092 spotify/kafka this good. want configure "multiple" node kafka cluster running on docker swarm. how can that? i have been trying docker 1.12 using docker swarm mode create nodes docker-machine create -d virtualbox master docker-machine create -d virtualbox slave master_config=$(docker-machine config master | tr -d '\"') slave_config=$(docker-machine config slave | tr -d '\"') master_ip=$(docker-machine ip master) docker $master_config swarm init --advertise-addr $master_ip --listen-addr $master_ip:2377 worker_token=$(docker $master_config swarm join-token worker -q) docker $slave_config swarm join --token $worker_token $master_ip:2377 eval $(docker-machine env master) create zookeeper serv

cocoa - What is difference between retain and strong in objective-c? -

this question has answer here: objective-c arc: strong vs retain , weak vs assign 7 answers looking forward response other : - arc , non-arc environment strong , weak retain-release cycles (rrc), form of memory leak. ios uses called automatic reference countin (arc) know when object in use , should kept in memory, or no longer in use , should deleted gain resources. arc works because runtime knows each object, how many objects referencing it. when found reaches 0, object deleted. issues arise when have 2 objects hold references each other. because object holds reference object b, , b a, reference count both , b never 0, , b in memory. it's possible there no other objects holding references or b, we've created memory leak. getting strong , weak, these keywords used "denote ownership", if will. eliminate retain-release cycles limiting obj

Tumblr Callback function in ios -

i beginner in ios. have started integration of tumblr app in ios. need stuck in implementation. want login in tumblr , viewcontroller. this, following this link . i have implemented code , getting webview of tumblr. but, facing issue in returning view controller , getting logged in id i.e. not considering clientid & secret have mentioned. here code. -(void)viewdidload { [super viewdidload]; clientid = @"pld4s********************************"; secret = @"aljie8x********************************"; redirect = @"tumblr://authorized"; [self connecttumblr]; } - (void)viewwillappear:(bool)animated { webview.delegate = self; } - (void)connecttumblr { consumer = [[oaconsumer alloc]initwithkey:clientid secret:secret]; nsurl* requesttokenurl = [nsurl urlwithstring:@"https://www.tumblr.com/oauth/request_token"]; oamutableurlrequest* requesttokenrequest = [[oamutableurlrequest alloc] initwithurl:requesttokenurl consumer:co

ios - NSRecursiveLock Deallocated -

i have ios app multiple view controllers , arc enabled. 1 of view controllers has iboutlet uiscrollview , uipagecontrol . when view controller loaded error printed in console: *** -[nsrecursivelock dealloc]: lock (<nsrecursivelock: 0xcb88cb0> '(null)') deallocated while still in use while trying fix problem, created symbolic breakpoint symbol _nslockerror module set foundation. xcode breaks breakpoint 1.1 on "0x12d2b58: pushl %ebp" , on thread 1. foundation`_nslockerror: ----------------------------------------------------- |> 0x12d2b58: pushl %ebp <|thread 1: breakpoint 1.1| ----------------------------------------------------- 0x12d2b59: movl %esp, %ebp 0x12d2b5b: subl $8, %esp 0x12d2b5e: calll 0x12d2b63 ; _nslockerror + 11 0x12d2b63: popl %eax 0x12d2b64: leal 2118709(%eax), %eax 0x12d2b6a: movl %eax, (%esp) 0x12d2b6d: calll 0x125689d ; nslog 0x12d2b72: addl $8, %esp 0x12d2b75: popl

oauth 2.0 - WindowsForm application with IdentityServer3 -

i have few web applications validating against , identityserver3 implementation. of web applications can sso. unfortunately, still have legacy winforms apps hanging around. i've been tasked getting them integrate sso. understand how authenticate apps against identityserver, how them interact sso if user logged 1 of webapps?

objective c - How to enable the options of "Debug Process As" in Xcode? -

this question has answer here: debugging in xcode root 6 answers the tow optional radio buttons both in disabled state,but want choose "root" debugging root makes sense if targetting osx, not ios, why it's disabled.

javascript - Json Data type without Stringify to MVC Controller -

i have mvc controller have string parameter. [httppost] public string index(string data) { return data.tostring(); } and webhook respond this. {"data":{"estimated_value":hello}} the problem data null when debug on , have no way of controlling response webhook , controlled web app. i try use postman have content-type of application/javascript json now if try post kind of json, data {"data":"mydata"} i return of mydata if parameter (string data) exact data object json, how can entire thing object. [without creating class serialization] need either object or plain string. also if try add more parameters, first parameter getting omitted. might use class creation first have know how data with {"data":{"mydata":23232}} this kind of format. steps have tried far. 1. create class xamasoft json class generator. 2. change parameter object: result {object}; 3. change

defgroup longer than a line + different caracters doxygen VHDL -

i trying document code using doxygen. version running 1.6.1. have documented vhdl file, , when defining new group different encoding. have set encoding iso-8859-1 (i have tried others encodings well, same result. spanish). in file accents wrong follow: contador cíclico result should be: contador cíclico. (accents work fine in rest of files) in addition, when try name new group more characters line cannot see second line. have tried <>, (), , {} neither of work: --! @defgroup registro_doble_puerto_16_bits_lim registro doble puerto de --! 16 bits límite i have looked both of issues did not find answer. thank much, antonio

java - XmlJavaTypeAdapter in MobileFirst 7.1 does not work -

hi using mobile first verison 7.1. have simple adapter returns json response. response contains date , using localdatetime that. not supported jax-rs, use xmljavatypeadapter. i've created adapter localdatetime , annotated getter (also tried annotating field itself) @xmljavatypeadapter annotation: @xmljavatypeadapter(localdatetimeadapter.class) public localdatetime getdate() { return date; } for reason annotation ignored. found solution, using jackson. i've created jackson serializer , annotated type this: @jsonserialize(using = localdatetimeserializer.class) private localdatetime date;

java - Drawing drawable in canvas doesn't work -

i want draw drawable on canvas code doesn't work , don't know why getresources().getdrawable(r.drawable.allergist).draw(canvas); i set custom views heigh , width match parent whole screen white , there no drawable on screen you need load image bitmap : resources res = getresources(); bitmap bitmap = bitmapfactory.decoderesource(res, r.drawable.allergist); then make bitmap mutable , create canvas on it: canvas canvas = new canvas(bitmap.copy(bitmap.config.argb_8888, true)); after can draw on canvas. edit 1 set bounds drawable . drawable d = getresources().getdrawable(r.drawable.allergist); d.setbounds(left, top, right, bottom); d.draw(canvas);

Plotting a decision boundary python ( give a good idea of how contourf matplotlib function works ) -

Image
this can considered duplicate of thread, it's meant granular level explanation intended question. in machine learning algorithms (let's consider perceptron), having set of data points, spans 2 features. input features of form ## assume classifier has been trained simplicity x = [[a1,b1] , [a2,b2] , .... , [an,bn]] x1_min, x1_max = x[:, 0].min() - 1, x[:, 0].max() + 1 x2_min, x2_max = x[:, 1].min() - 1, x[:, 1].max() + 1 xx1, xx2 = np.meshgrid(np.arange(x1_min, x1_max, resolution), np.arange(x2_min, x2_max, resolution)) z = classifier.net_input(np.array([xx1.ravel(), xx2.ravel()]).t) ### here z set of prediction has values +1 or -1 , data points in x z = z.reshape(xx1.shape). # plot class samples idx, cl in enumerate(np.unique(y)): plt.scatter(x=x[y == cl, 0], y=x[y == cl, 1], alpha=0.8, c=cmap(idx), marker=markers[idx], label=cl) plt.show() as of fine. real problem following function or how works, when passing data