Posts

Showing posts from January, 2014

wxpython - wx.GridBagSizer + wx.StaticBoxSizer: How to automate span calculation -

Image
i have following following window generated using function called createstaticboxsizer staticbox3 contains empty spaces @ end of dont want to. i contain no empty space. noticed if put span staticbox3 7 gives result want automate process of generating span opposed hard-coding it: the code uses span based on number of items creates, if creates 8 items within boxsizer, uses span of 8. i can't understand why wrong can please clarify? should span corresponding to? also staticbox::4 intruding on row of staticbox::1 why doesn't expand staticbox::3 does? the code generate follows: import wx import wx.lib.inspection class myregion(wx.frame): = 0 def __init__(self, parent): wx.frame.__init__(self, parent, title="my region") gridsizer = wx.gridbagsizer() gridsizer.add(self.createstaticboxsizer(4), pos=(0,0), span=(4,1), flag=wx.expand) gridsizer.add(self.createstaticboxsizer(4), pos=(4,0), span=(4,1), flag=wx.expand)

sql server - php sql odbc_execute() with LIKE not working -

so have piece of code not returning (the echo returns nothing , should returning 2 rows): <?php include "connection.php"; $cliente = $_post["cliente"]; $select = "select cliente, nomcli clix1 nomcli ? order nomcli"; $stmt = odbc_prepare($con, $select); //preparing array parameter $prep_array = array(); $prep_array[] = "'%$cliente%'"; $rs = odbc_execute($stmt, $prep_array); $nombres = array(); $clienteids = array(); //if prepare statement successful if($rs) { $i = 0; while($row=odbc_fetch_array($stmt)) { $cliente_id = trim($row["cliente"]); $nombre = utf8_encode(trim($row["nomcli"])); $nombres[$i] = $nombre; $clienteids[$i] = $cliente_id; $i++; } echo json_encode($nombres) . "|" . json_encode($clienteids); } else { echo "error"; } odbc_close($con); ?> i know problem not parameter pass on odbc_execute()

Validate a string with a regex -

i need write regular expression handle below constraints: names can contain letters, numbers, hyphens (-), dollar signs, brackets ([ , ]), , underscores (_). single periods (.) allowed inside of internal name (abc.de), not @ beginning or end of internal name (.abc or def.). spaces , other special characters not listed here not supported. i wrote this: (^[^\.])([a-za-z0-9\.\$\[\]\_\-])*[^.] but still can put 1 sign like: ! or @ or % ^(?!\.)([a-za-z0-9\.\$\[\]\_\-])+(?<!\.)$ you need anchors .also [^\.] can accept other . .so lookaheads , lookbehinds advised. see demo. https://regex101.com/r/sj9gm7/78

javascript - Change size of an image loaded from URL -

how modify size of image here?: var image = new image(); image.src = 'http://www.ziiweb.com/images/logo.png'; image.width = 200; //this not modifying width of image $('canvas').css({ background: 'url(' + image.src + ')' }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <canvas id="mycanvas" width="200" height="100" style="border:1px solid #000000;"> </canvas> you inserting image background, use background-size. var image = new image(); image.src = 'http://www.ziiweb.com/images/logo.png'; $('canvas').css({ backgroundimage: 'url(' + image.src + ')', backgroundsize: "100%" }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <canvas id="mycanvas" width="200&

string - Trying to count letter frequency in text file in Python -

i have program count letters in specific text file, (in example, "words.txt"). however, when try change code accept user input instead of looking specific file, following:- 'str' object has no attribute 'readlines' i sure sill doing, cannot see why. code below: import string #fname=raw_input("enter file name: ") fname=open('words.txt', 'r') #if len(fname) < 1 : fname = "words.txt" file_list = fname.readlines() freqs = dict() line in file_list: line = filter(lambda x: x in string.letters, line.lower()) char in line: if char in freqs: freqs[char] += 1 else: freqs[char] = 1 lst = list() key, val in freqs.items(): lst.append( (val, key) ) lst.sort(reverse=true) key, val in lst[:] : print key, val what raw_input string holding name of file. still have open actual file handle. filename = raw_input("enter file name: ") fname = open(filename, 'r') also, m

ios - UIView subview clips during UIView transition animation -

i have created uiview subclass contains uiimageview subview. uiimageview subview may typically lie outside bounds of superview (my uiview subclass). not problem, no clipping occurs subview not 'clipstobounds'. until subview performs transition animation. [uiview transitionwithview:self duration:0.7 options:uiviewanimationoptiontransitionflipfromleft | uiviewanimationoptionallowanimatedcontent animations:^{ self.bodyview.transform = cgaffinetransformmakescale(-1.0, 1.0); } completion:^(bool fin){ }]; in example 'bodyview' uiimageview subview of uiview subclass. during transition bodyview clips. have tried setting 'maskstobounds' property of superview's layer 'no' has not solved problem. my workaround @ present superview larger subview , not allow subview's frame exist outside superview's

statistics - F Distribution in R -

i can't figure out how plot f distribution in r, given 2 degrees of freedom using standard normal variates. suggestions? you can use curve() curve(df(x, df1=1, df2=2), from=0, to=5) here documentation of curve()

python - why loop did not execute else -

import csv path1=r'/users/desktop/forks.csv' path2=r'/users/desktop/forks1.csv' outdata=[] count=0 i=0 open(path1,'rb') input: reader=csv.reader(input) row in reader: if i==0: i=i+1 outdata.append(row) continue if int(row[5])>0: row.append(1) outdata.append(row) count=count+1 print count else: row.append(0) outdata.append(row) count=count+1 print count open (path2,'wb') output: writer=csv.writer(output,delimiter=',') writer.writerows(outdata) i have large table, want add column boolean value each row. if column 6 lager 0, should 1. if 0, should zero. loop stop @ 58542 58543 58544 58545 58546 58547 58548 traceback (most recent call last): file "/users/documents/workspace/datamining/opensource/label.py", line 18, in <module> if int(row[5])>0: valueerror: invalid literal int() base 10: '' the information in table b

ios - An error occured while processing the http request for the webDAV uploads -

Image
i got error while uploading app appstore. try application loader instead of xcode organizer

Setup DimGrid and DimBlock in CUDA -

i doing matrix multiplication in cuda. following setup works: int tile = 8; dim3 dimgrid((numccolumns - 1)/tile + 1, (numcrows - 1)/tile + 1, 1); dim3 dimblock(tile, tile, 1); but if use 1 block whole image, returns zero. reason that? assume 1 block can contain whole image ( input 64x64). dim3 dimgrid(1,1,1); dim3 dimblock(numccolumns, numcrows, 1); this how call kernel in main function: matrixmultiply<<<dimgrid, dimblock>>>(devicea, deviceb, devicec, numarows, numacolumns, numbrows, numbcolumns, numcrows, numccolumns); and kernel: __global__ void matrixmultiply(float * a, float * b, float * c, int numarows, int numacolumns, int numbrows, int numbcolumns, int numcrows, int numccolumns) { //@@ insert code implement matrix multiplication here int row = blockidx.y * block

Caesar Cipher java my way, doesnt work -

i know there bunch of topics caesar cipher solve things way. , such doesnt work ,but think might work way.i sure know feeling when alone solve problem. so here idea. make array of chars consist alphabet. , string message code. 2 loops. 1 outer set char message, , inner scans thru alphabet array. when letter message meet char in array, replaces him 3rd (key of 3) char down in array. here piece of code written now: char[] alphabet = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'o', 'p','r','s','t','u', 'v', 'z'}; string message = " message coding"; message = message.tolowercase(); string codedmsg = ""; for(int = 0; < message.length(); i++) { for(int j =0; j < alphabet.length; j++) { if(message.charat(i) ==

javascript - Auto-generated username -

i've been trying search find answer question i'm sure it's been asked dozen or more times, life of me can't find answer. i've got basic form 2 text fields...firstname, lastname , username field read-only. i'm looking way populate username dependent on entries in firstname lastname fields. i'm guessing jquery or javascript can done...but said above....having heck of time trying find examples. any appreciated. thanks. concatenate 2 inuput values of firtname , lastname inputs: $('input[name=username]').val($('input[name=firstname]').val()+$('input[name=lastname]').val()).attr('disabled','');

android - Copying records from MS Access database into SQLite database using CSV format. Need an alternative -

i have database on ms access 1 table containing 25 fields. contains 1000 10,000 or more records (the number of records approximation. company i'm working has huge amount of data though). the company wants access data (for read-only purposes) on android phones. require data transferred phone through wired connection (no wifi). here's how solution works: export ms access database table csv file. then, parse csv file using java code, , insert each record sqlite database. as records updated often, we'll have export new csv once every week , refresh sqlite database. here's issue solution: takes twice storage space: understand it, there 2 versions of same table stored on device - one, csv file, , sqlite database. it requires time refresh sqlite database because 10,000 records need deleted , inserted back. someone suggested me convert .mdb file jar file , run select queries on jar instead of using sqlite. don't understand how works. please guide me righ

sql - mysql error: code 1005 cant create table erno 150 -

i have been looking around online, erno 150 seems common problem, struggling code, help? create table players ( email varchar(30) not null, playerpassword varchar(30), screenname varchar (8), primary key (email) ); create table scores ( screenname varchar(8), gameword varchar(30), score long, foreign key (screenname) references players(screenname) ); screenname needs key on players table used foreign key in table. can add key (screenname) table definition players . maybe want unique key .

grid - ExtJS 3: How to define different actions to different rows based on the values in the row? -

in grid panel supports adding,editing , deleting rows, want define different actions different rows based on values in row. like, on add , 1 new row added in grid. have column in grid has combo editor ( can select either yes or no ). if value no , disable next column textfield , column has button hyperlink. , if value yes , want textfield , button enabled. i tried textfield , button using ext.getcmp() , use disable() , happens is, action applied column in rows of grid, whereas want applied particular row have selected value. to more clear, let me explain example.. assuming grid used storing phone number entries has 3 columns, column 1 - has phone number? column 2 - provide phone number column 3 - look user name here, add row 1 grid,choose value no has phone number flag, based on code, use ext.getcmp , textfield , button , invoke disable method, column 2 , 3 disabled. in row 2, choose value yes flag,so ideally should able modify column 2 , 3 of row 2.

excel - Get Folder Names from server directory -

i need folder names path need search directory in server 6000 folders. have following snippet of code run through folder , folder names path. works fine in local directory when run same code on server directory fails after printing 86 folder names. code fails when run on server location more 6000 folders. private sub printfolders() dim objfso object dim objfolder object dim objsubfolder object dim integer application.statusbar = "" 'create instance of filesystemobject set objfso = createobject("scripting.filesystemobject") 'get folder object set objfolder = objfso.getfolder("c:\temp") = 1 'loops through each folder in directory , prints names , path on error goto handlecancel application.enablecancelkey = xlerrorhandler msgbox "this may take long time: press esc cancel" each objsubfolder in objfolder.subfolders application.statusbar = objsubfolder.path & " " & objsubfolder.name 'print folder name ce

HTML5 Video not working in Android -

Image
i building little application display video users , having lot of issues mobile devices. seems work on desktop, , hit , miss on mobile. works on 1 iphone, not , not work on android when navigate directly files. here code. <video id="video1" width="600" controls=""> <source src="~/content/video/mov_bbb.mp4" type="video/mp4"> <source src="/content/video/mov_bbb.ogg" type="video/ogg"> browser not support html5 video. </video> its ripped right example w3schools http://www.w3schools.com/html/html5_video.asp files , everything. when visit site on mobile device, works, when hosted on site doesn't. here screen shot of android device, player shows nothing can play video i running windows server 2012, , android device android 4.4.4; sm-n900v build/ktu84p, chrome 41.0.2272.96. because these files , code ripped directly source seems work thing can think of on server not set correc

php - Search in a multidimensional array and get an index -

i have array that: printr_($photos); ====== array ( [0] => array ( [path] => site:photos/photo-1.jpg [data] => array ( [phototitle] => mega title [photodate] => 2015 [flickrurl] => xxx [portrait] => [slug] => mega-title ) ) [1] => array ( [path] => site:photos/photo-2.jpg [data] => array ( [phototitle] => photo title [photodate] => 2001 [flickrurl] => xxx [portrait] => [slug] => photo-title ) ) ... i array index string (which slug browser current url). tried solution got error (undefined index: data […] on line 95) /* ** search in array */ function arraysearch($array, $field,

java - Joda Time sum various times -

i'm using joda time 2.7 , need add several times in localtime format , ignoring timezone , todatetimetoday ; example: input (string ... times) 01:10 , 01:10 , 01:10 , or 01:10 , 01:10 , 01:10 , 01:10 , 01:10 , 01:10 expected output in ( millis ) 03:30 or expected output in ( millis ) 07:00 my ideia import org.joda.time.datetimezone; import org.joda.time.duration; import org.joda.time.format.datetimeformat; import org.joda.time.format.datetimeformatter; static long sumaccumulatedtimes( long... listtimes ){ duration duration = duration.zero; datetimezone zone = datetimezone.getdefault(); datetimeformatter fmt = datetimeformat.forpattern("hh:mm"); (int = 0; < listtimes.length; i++) { duration = duration.plus( listtimes[i] ); // in iteration three, ocurred problems! } long convertzone = zone.convertutctolocal( duration.getmillis() ); // adjust timezone system.out.println("output: " + fmt.print( con

css - dc.bar-chart margin and axis label size adjustment -

i found yaxis label big shown--it truncated left border. i tried increasing left margin, no success. seems label text left-aligned. increasing margin gets label further away ticks text. please see attached screenshots. 1 wider gap margin.left=70 . other 1 margin.left=40 . no matter case, 'expenditures' seems truncated on left side. is there anywhere in dc.css can change configuration? thank you!! you can adjust axis labels placed relative edge using second parameter when call .xaxislabel() , .yaxislabel() methods. sets "padding" (actually offset left/bottom). coordinategridmixin.xaxislabel docs coordinategridmixin.yaxislabel docs it's confusing text size gets set through stylesheet positioning can't be. i'm not sure if there's way around this, though

How to insert multiple MySQL records in node.js -

i want insert multiple data mysql using node.js, have created code worked single data insert (1 column), code : var data = "how you"; db.query('insert message (message) values (?)', data) then tryed insert multiple records got error code is var senderid='00012'; var message='this node'; db.query('insert message (senderid, message) values (?, ?)', senderid, message) please solve problem var userid=msg.userid; var msg=msg.message; db.query('insert message (senderid, message) ' + 'values ("'+userid+'", "'+msg+'")', function(err) { console.log(err); });

Calculate derivative for provided function, using finite difference, Python -

i should start saying relatively new python, have coded in java , matlab before. in python, code def func(f): return f g = func(cos) print(g(0)) gives result >1.0 as g defined cosine function. i want write function calculates derivative of provided function using finite difference approach. function defined as def derivator(f, h = 1e-8): and achieve follwing: g = derivator(cos) print(g(0)) # should 0 print(g(pi/2)) # should -1 at moment derivator function looks this def derivator(f, h = 1e-8): return (f(x+h/2)-f(x-h/2))/h which wrong, not sure how should fix it. thoughts? your current derivator() function (which should called differentiator() ) uses undefined variable x , return single value, if x defined--the value of f'(x) . want return function takes x value. can define inner function , return it: def fprime(x): return (f(x+h/2)-f(x-h/2))/h return fprime because don't use function anywhere else, though, can use lam

ruby - Rails: belongs_to association through a form not populating -

i'm working on controller class, project . has belongs_to relationship client . i'm not sure why happening, when create new project through form, has name assigned it, no fee , no client_id . here's relevant code: project controller class projectscontroller < applicationcontroller def index end def show end def new @project = project.new end def edit end def create @project = project.new(project_params) if @project.save redirect_to projects_url else render 'new' end end def update end def destroy end private def project_params params.require(:project).permit(:name, :feee, :client_id) end end projects/new view <div id="newproject-form"> <h1>create project</h1> <%= form_for @project |p| %> <div id="newproject-form-input"> <ul> <li><%= p.label :name, "proj

android - Font changes after configuration change -

Image
i have app allows switch between 2 different languages. updating configuration , restarting activity: locale locale = new locale(lang); locale.setdefault(locale); configuration config = new configuration(); config.locale = locale; language = lang; getbasecontext().getresources().updateconfiguration(config, getbasecontext().getresources().getdisplaymetrics()); activity.recreate(); now have problem before switching language font sizes displayed differently after switching. see screenshots. ideas?

cakephp - updating data without model with classRegistry -

i have table called user_tasks. not have model table , in totally unrelated controller have need update single field in user_tasks table. this have tried far $user = classregistry::init('user_tasks'); $conditions = "user_id = ". $user_id; $userrows = $user->find('first', array('conditions'=>$conditions)); $user->set(array( 'task' => $level )); $user->save(); however not $user->save(); , table never gets updated. can make work. thanks update: in try / catch block, this {"errorinfo":["hy000",1364,"field 'user_id' doesn't have default value"],"querystring":"insert `mytable`.`user_tasks` (`subscription`, `modified`, `created`) values ('latest', '2015-04-09 15:08:51', '2015-04-09 15:08:51')"} ok figured out. have send user id so $user = classregistry::init(&

python - How to parse tuple data in one line -

i have take user input in 1 line in form: c = (39.447; 94.657; 11.824) n = (39.292; 95.716; 11.027) ca = (39.462; 97.101; 11.465) and have translate have 3 variables each corresponding appropriate tuple. complicated semi colons , fact has on 1 line. this have far i'm having trouble parsing 1 line, thought eval() might work because input resembles variable assignment "syntaxerror can't assign literal". feel there should simple way this. class tupleclean(str): def clean(self): new_list = [] clean_coord = self.strip("() ") split_coord = clean_coord.split(";") in split_coord: new_list.append(float(i)) tuple_coord = (new_list[0], new_list[1], new_list[2]) return(tuple_coord) coord_1 = input("input coordinates carbon in format (p; q; r): ") coord_2 = input("input coordinates nitrogen in format (p; q; r): ") coord_3 = input("input coordinates calcium in f

recursion - PostgreSQL recursive CTE million size tree select by dynamic rank with paging -

my goal create query can retrieve tree controlling depth , amount of items returned @ each depth sorted rank descending, rank changing. i.e. give me tree starting @ node id 4, maximum depth of 5 (starting @ node) 5 children max @ each level sorted descending rank. so have tree structure: create table thingtree ( id uuid not null, parent_id uuid, text character varying(2048) not null, rank integer not null default 0, constraint thingtree_pkey primary key (id), constraint thingtree_parent_id_fkey foreign key (parent_id) references thingtree (id) match simple on update no action on delete no action ) i want select node id , children, configurable limit of records pulled @ each depth , sorted rank, changing. so decided create data: create extension "uuid-ossp"; create function build_tree (parent_id uuid,max_depth integer,current_depth integer,max_direct_children integer) returns boolean $$ declare new_id uuid := uuid_generate_v4();

sql - Python, SQlite 3 insert super slow -

for reason insert instruction painfully slow. by painfully slow, mean go 400 updates second 5. this method in question: @app.route('/senddata/<path:data>', methods=['post']) def receivedata(data): #data = '0,2c7,2c6,1c8,2c2,1' always. def h(point): cur.execute("insert points (x, y) values({},{});".format(*point.split(","))) g.db.commit() cur = g.db.cursor() #list(map(h, data.split("c"))) enables slow. return "done" when uncomment map, goes painfully slow. tried other method, same thing. def receivedata(data): #data = '0,2c7,2c6,1c8,2c2,1' always. cur = g.db.cursor() cur.execute("insert points (x, y) values({}, {});".format(*data.split("c",1)[0].split(","))) g.db.commit() if data.count("c") == 0: return "done" else: return receivedata(data.split("c",1)[1]) i don't

c# - Xamarin.Android-The call is ambiguous between the following methods or properties -

i above error while building project.the context methods referring different,so don't know what's causing error.i have file browsing feature in app.so depending on activity called browser,the user can select folder or file , it's path returned. public class filelistadapter : arrayadapter<filesysteminfo> { private readonly context _context; public filelistadapter(context context, ilist<filesysteminfo> fsi) : base(context, resource.layout.file_picker_list_item, android.resource.id.text1, fsi) { _context = context; } public override view getview(int position, view convertview, viewgroup parent) { var filesystementry = getitem(position); filelistrowviewholder viewholder; view row; if (convertview == null) { row = _context.getlayoutinflater().inflate(resource.layout.file_picker_list_item, parent, false); viewholder = new filelistrowviewholder(row.findviewby

javascript - How to make http request in my case -

i trying prevent multiple http requests being fired in codes. i have like in controller //if use click, fire method var getitems = function() { factory.makerequest.then(function(data){ //do stuff data... }) } in factory var factory = {}; factory.makerequest = function(){ if($http.pendingrequests.length===0) { return getdata() .then(function(data) { //do stuff here return data; }) } } factory.getdata = function() { return $http.get('/project/item'); } return factory; the above code prevent request being fired multiple time if process on going. however, cannot read property of .then of 'undefined' if click button again before promise resolved. know it's because $http request doesn't return have $http.pendingrequests.length===0 condition. above codes give me need don't know how prevent error in console log. can me out? lot! the

how to create SIP uri using java.net.URI class? -

the server or can voip provider ekiga.net . want call contact sip:500@ekiga.net . have created sip headers defined in rfc3261 , want create sip uri using uri class. need with. the purpose creating uri send udp packet contains sip headers , messages server. don't know address use because datagram class needs destination ip , port. know port 5060 don't know url use. thanks java don't have built-in support sip, don't need java sip uri. optionally first might perform dns lookup this: inetaddress inetaddress = inetaddress.getbyname("ekiga.net"); (this lookup record only. voip should use srv dns records, requires seprate lib , record fine) then create udp socket this: datagramsocket socket = new datagramsocket(); then send message (buff must hold valid sip message): socket.send(new datagrampacket(buf, buf.length, inetaddress.getbyname("ekigaaddresshere"), 5060)); then read answer(s) , send other requests.

How to parse output from sse.client in Python? -

i new python , trying ahead around parsing sse client code. using sse client library . code basic , follows sample exactly. here is: from sseclient import sseclient devid = "xxx" atoken = "xxx" sparkurl = 'https://api.spark.io/v1/devices/' + devid + '/events/?access_token=' + atoken messages = sseclient(sparkurl) msg in messages: print(msg) print(type(msg)) the code runs without problem , see blank lines , sse data coming through. here sample output: <class 'sseclient.event'> {"data":"0 days, 0:54:43","ttl":"60","published_at":"2015-04-09t22:43:52.084z","coreid":"xxxx"} <class 'sseclient.event'> <class 'sseclient.event'> {"data":"0 days, 0:55:3","ttl":"60","published_at":"2015-04-09t22:44:12.092z","coreid":"xxx"} <class &

javascript - Uncaught Error:cannot call methods prior to initialization; -

i m calling form in popup using bootbox bootbox.alert(myform, function () { }).find("div.modal-dialog").addclass("largewidth"); in form there pallete collor picker(evol colorpicker) $(document).ready(function () { $("#cd_bundle_entitiesbundle_call_color").colorpicker(); }); the first time form popup opens pallete color pick displays ok 1 time. after if close popup , open again when pressing color pick pallete getting error uncaught error: cannot call methods on colorpicker prior initialization; attempted call method 'hidepalette' reading similar questions think ve destroy bootbox popup in callback of bootbox tried $(this).empty or $(this).remove() didnt work this form in html file js <div class="col-lg-6"> {{ form_start(form, {'action': path('calls_edit_exec'),'attr': {'class': 'callform'} } ) }} <fieldset> {{ form_errors(form)

wordpress - Php - get_option - Search for specific Options -

i trying search specific options (my_option_…) , print them in rows. i have been testing things while , cannot find solution. using (search_terms=my_option_) seems not work. is there easy way implement this? <?php add_option('my_option_1', 'option 1'); add_option('my_option_2', 'option 2'); add_option('my_option_3', 'option 3'); ?> <?php $option1 = get_option('my_option_1'); $option2 = get_option('my_option_2'); $option3 = get_option('my_option_3'); if ( get_option('search_terms=my_option_')){ //??? echo "multiple found!!"; while(get_option('search_terms=my_option_')) { echo "options"; //??? } } if ( get_option('my_option_2')){ echo "my_option_2 found!!"; } ?> $query

python - How to add features to scikit-learn DictVectorizer? -

i'm training spam detector using multinomialnb model in scikit-learn. use dictvectorizer class transform tokens word counts (i.e. features). able train model on time using new data arrives (in case in form of chat messages incoming our app server). this, looks partial_fit function useful. however can't seem figure out how enlarge size of dictvectorizer after has been "trained". if new features/words arrive have never been seen, ignored. pickle current version of model , dictvectorizer , update them each time new training session. possible? in documentation , use dictionary learning phase of dictvectorizer. add new feature original dictionary , fit_transform . way add value dictvectoriser. be careful partial_fit method kind of heavy treatment . told on method documentation, there treatment overhead. from sklearn.feature_extraction import dictvectorizer v = dictvectorizer(sparse=false) d = [{'foo': 1, 'bar': 2}, {'foo': 3, '

python - Algorithm to group sets of points together that follow a direction -

Image
note: placing question in both matlab , python tags proficient in these languages. however, welcome solutions in language. question preamble i have taken image fisheye lens. image consists of pattern bunch of square objects. want image detect centroid of each of these squares, use these points perform undistortion of image - specifically, seeking right distortion model parameters. should noted not of squares need detected. long majority of them are, that's totally fine.... isn't point of post. parameter estimation algorithm have written, problem requires points appear collinear in image. the base question want ask given these points, best way group them each group consists of horizontal line or vertical line? background problem this isn't important regards question i'm asking, if you'd know got data , further understand question i'm asking, please read. if you're not interested, can skip right problem setup section below. an exam

javascript - Drop down menu is Glitchy at the edge of menu button -

i have odd issue. created standard dropdown menu having issue menu dissapearing when right between menu , drop down. cant find css stop hover state maybe eyes better mine. here gif of happening: http://imgur.com/axf6skk my js code: //------- nav menu --------// $('nav li').hover( function () { $('ul', this).stop(true,true).fadein({ duration: 300, queue: false }).slidedown(300); }, function () { $('ul', this).stop(true,true).fadeout({ duration: 300, queue: false }).slideup(300); }); relevant html: <nav> <ul class="center"> <li class="menu"> <a href="#home">home</a> </li> <li class="menu"> <a class="inactive">get started</a> <ul class="dropdown hidden" id="drop1"> <li class="dropitem"><a href="#start">start making ccr</a></li>

c - Data Being Requested from Tor Socks Server -

i doing playing around tor project code , wanted see if possible append string data being sent or log data console before gets encrypted. doing privately inside own network btw. i still unfamiliar code have been looking in connection_edge.c find socks server receives data having hard time pinpointing it. if familiar point me in right direction grateful.

How to parse unnamed JSON Array in Android app -

i have json array sent sql server via php in following format finding difficult parse without encountering errors. [ { "placename": "place1", "latitude": "50", "longitude": "-0.5", "question": "place1 existed when?", "answer1": "1800", "answer2": "1900", "answer3": "1950", "answer4": "2000", "correctanswer": "1900" }, { "placename": "place2", "latitude": "51", "longitude": "-0.5", "question": "place2 existed when?", "answer1": "800", "answer2": "1000", "answer3": "1200", "answer4": "1400", "correctanswer": "800" }, { "placename": "place3

java - Accessing an array in another method -

i trying access array in separate method initialized in. public void initializearray() { string sentences[] = new string[5]; for(int i=0; i<5; i++) { sentences[i] = i+1; } } public void printarray() { for(int i=0; i<5; i++) { system.out.println(sentences[i]); } } i know in 1 loop, can explain how print array way? need access sentences array in separate method initialized in. tried make instance of array @ top of program gives me error saying "local variable hides field". i tried make instance of array @ top of program gives me error saying "local variable hides field". you have instance variable, remove local variable within method: public void initializearray() { //string sentences[] = new string[5]; ... } also don't use magic numbers did in for-loop: for(int i=0; i<5; i++)//use `sentences.length` instead of `5`

In Android, what's better for performance: setting a transparency on a view, or adding an overlay view over it? -

i've developed messaging app that's using recyclerview contact image every "row". new messages, want contact icon full color, old messages, want have icon faded. so, can either setting alpha on icon 0.5, or can have overlay image (that's semi-transparent png) on top of icon achieve pretty same effect. way more efficient , lead smoother scrolling through list? i should mention app runs on api 14+, i'll need make sure whatever choose doesn't work worse on older apis compared lollipop (or vice versa). or, if there significant difference in way works better on different apis, i'll design layouts work differently each api. thanks try both , measure using systrace see how long frames take draw. http://developer.android.com/tools/help/systrace.html a 3rd option might cache version .5 alpha, blended background (so final bitmap not need alpha). assuming people in conversation not many, may give best of both. again, measure , see yourself.

ios - How can I get my UICollectionView to be the same width as my device when using Auto Layout? -

Image
i created uicollectionview in storyboard editor , added (custom) viewcontroller . every view controller in storyboard, says size 600x600 , uicollectionview , takes whole view, 600x600. this not correct though, writing iphone app , real dimensions should 320x568! because of this, when add items collection, placed off right side of screen. example, first add cell image in of size 160x213. left justified , takes left half of screen. when add next image, there huge gap , appears on left side, partly cut off. third image expect appear below first, doesn't appear @ all. believe off right side of screen. implies size of uicollectionview 600x600 , not 320x568. i should mention i've tried think of fix this. example: i tried adjusting size of collection view: self.photocollection.frame = cgrectmake(0, 0, 320, 568); i tried unchecking "use size classes" in storyboard editor. it seems work if uncheck "use auto layout" use auto layout. how work?