Posts

Showing posts from June, 2010

xcode - Manually Compile Metal Shaders -

i'm interested in moving away xcode , manually compiling metal shaders in project mixed-language application. i have no idea how this, though. xcode hides details of shader compilation , subsequent loading application @ runtime (you call device.newdefaultlibrary() ). possible, or have use runtime shader compilation purposes? generally, have 3 ways load shader library in metal: use runtime shader compilation shader source code via mtldevice newlibrarywithsource:options:error: or newlibrarywithsource:options:completionhandler: methods. although purists may shy away runtime compilation, option has minimal practical overhead, , viable. primary practical reason avoiding option might avoid making shader source code available part of application, protect ip. load compiled binary libraries using mtllibrary newlibrarywithfile:error: or newlibrarywithdata:error: methods. follow instructions in using command line utilities build library create these individual binary l

D3.js Stacked Bar Chart, from vertical to horizontal -

i make vertical bar chart ( http://bl.ocks.org/mbostock/3886208 ) horizontal bar chart. thanks help! code examples nice. it's matter of reversing domains, axis , rect calculations: var y = d3.scale.ordinal() .rangeroundbands([height, 0], .1); // y becomes ordinal var x = d3.scale.linear() .rangeround([0, width]); // x becomes linear // change state group positioned in y instead of x var state = svg.selectall(".state") .data(data) .enter().append("g") .attr("class", "g") .attr("transform", function(d) { return "translate(0," + y(d.state) + ")"; }); // rect calculations become state.selectall("rect") .data(function(d) { return d.ages; }) .enter().append("rect") .attr("height", y.rangeband()) // height in rangeband .attr("x", function(d) { return x(d.y0); }) // horizontal position in stack .attr("w

matlab - How to remove that digit/non character which is at farthest distance from remaining characters in binary image -

Image
i want remove digit/non character @ farthest distance remaining characters in binary image. renaming characters , digits have fixed distance. in image: i want remove "5" , in image: i want remove non-characters. i want when image have 2 rows (like image1 , image2). in single row image don't want anything. couldn't quite figure out mark doing, decided create own method. if have statistics toolbox, i'd apply kmeans clustering of centroids of characters , remove centroid has least amount of characters - namely isolated island 1 character. given first image, had pre-processing remove green bounding box surrounded each character. when read in image stackoverflow, had associated colour map , read in indexed image. had convert indexed image colour image, extracted out green channel light green bounding box removed. [x,map] = imread('http://s17.postimg.org/5quw8e6m7/plate2.png'); out = ind2rgb(x,map); im = out(:,:,2); i invert im

actionscript 3 - Is there a difference between MovieClip(X) and X as Movieclip? -

this question has answer here: as3: cast or “as”? 8 answers maybe in performance. i'm using movieclip(getchildbyname("x")).stop(); better (getchildbyname("x") movieclip).stop(); ? results: (ui.getchildat(0) spectrumanalyzer) = 174 ms spectrumanalyzer(ui.getchildat(0)) = 200 ms for programmer it's same - don't know if code doing same thing in 2 different ways. anyways difference 26 ms 1 mio iterations. var sa:spectrumanalyzer = new spectrumanalyzer() var ui:uicomponent = new uicomponent() ui.addchild(sa) addelement(ui) var start:number = new date().gettime() for(var i:int=0; i<1000000; i++){ (ui.getchildat(0) spectrumanalyzer) } var end:number = new date().gettime() trace(end-start) start = new date().gettime() for(var i:int=0; i<1000000; i++){ spectruma

javascript - why do my onClick functions take two clicks -

i've noticed few different projects of mine whenever click add onclick function to, takes 2 clicks them going when page freshly loaded. general structure use them is: function pagechange(){ var welc_p = document.getelementbyid("welcome");/**gathers page divs**/ var page01 = document.getelementbyid("page01"); var page02 = document.getelementbyid("page02"); var start = document.getelementbyid("start_btn");/**gathers buttons**/ var p1_back = document.getelementbyid("p1_back"); var p1_next = document.getelementbyid("p1_back"); var p2_back = document.getelementbyid("p2_back"); var p2_next = document.getelementbyid("p2_back"); start.onclick=function(){ page01.style.display="block"; welc_p.style.display="none"; window.location="#page01"; }; }/**function**/ then way call in html is <div class

javascript - Jquery Jtable listAction not working -

i have jtable this: $("#encuestastablacontenidos").jtable({ title: "tabla de encuestas", paging: true, pagesize: 10, actions: { listaction: '../../srvencuestas?paraction=listarencuestas', updateaction: '../../srvencuestas?paraccion=editarencuestas' }, fields: { numeroencuesta: { title: 'numero de pregunta', width: '5%' }, preguntaencuesta: { title: 'pregunta', edit: true } } }); my problem listaction not being put in servlet. tested url it's not that. think it's jtable plugin, need help. comment nice. i can not add comment, did add load function call after jtable conf

javascript - Make a draggable rectangle appear with click of a button on google maps API -

i playing google maps api , trying make rectangle pop when user clicks button. working through examples given of api in use , came jsfiddle . not rectangle appear when button clicked. wanted appear @ center of users screen when click select region button. here poorly patched together: #map { width: 500px; height: 500px; center: true; } <!doctype html> <html> <head> <title>user-editable shapes</title> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> <meta charset="utf-8"> </head> <body> <div id="map"></div> <script> var map; var rectangle; var infowindow; var selectregion = null; var penang = {lat: 5.466277, lng: 100.289981}; /** * centercontrol adds control map recenters map on chicago. * constructor takes control div argument. * @constructor */ fun

Spring Integration with IBM MQ Series -

am novice when comes spring integration , had questions around it. trying integrate spring integration mq series , believe ibm mq(q connection factory , queue) entries should going inside applicationcontext.xml file. have applicationcontext file activemq implementation , wanted know ibm mq specific entries in app contest file like. questions - do need have mq series installed on same machine running spring application. i presume not, should entries queueconnectionfactory , destination attributes in applicationcontext file. providing sample poc's me lot. thanks in advance. you can create beans this jms.transporttype=1 jms.queuemanager=your_queue_manager jms.hostname=your_hostname jms.port=1321 jms.channel=your_channel jms.receiver.queue.name=your_queue jms.username= jms.alias= jms.mq.connection.factory=jmsconnectionfactory jms.mq.receiver.queue=receiverqueue <bean id="jmsconnectionfactory" class="com.ibm.mq.jms.mqqueueconnectionfactory

php - Registration form update to MySQL PDO -

i'm new php , mysql. have following registration form asks user put in name, password , email. validation works , i'm able connect database cannot insert table because i'm having hard time updating code old mysql mysql pdo. here code: form: <form name="registration" method="post" action="registration.php"> <table width="400" border="5" align="center"> <tr> <td colspan="5"><h1>registration form</h1></td> </tr> <tr> <td>user name:</td> <td><input type="text" name="name" /></td> </tr> <tr> <td>user password:</td> <td><input type="password" name="pass" /></td> </tr> <tr> <td>user email:</td> <td><input type="text" name=&quo

curl - Proxying PUT HTTP requests to AWS S3 fails -

i working on creating proxy relay http requests amazon s3. proxy uses nginx right ngx_aws_auth module adds necessary headers http requests client not need to. nginx configuration: http { include mime.types; default_type application/octet-stream; sendfile on; client_body_in_file_only clean; client_body_buffer_size 32k; client_max_body_size 300m; send_timeout 300s; keepalive_timeout 65; gzip on; server { listen 8000; location / { proxy_pass https://test-bucket.s3.amazonaws.com; aws_access_key xxxxx; aws_secret_key yyyyyy; s3_bucket test-bucket; proxy_set_header authorization $s3_auth_token; proxy_set_header x-amz-date $aws_date; } } } almost except when trying upload larger file. get: $ curl -vx http://192.168.99.131:8000/a.txt ; echo * connect() 192.168.99.131 port 8000 (#0) * trying 192.168.99.131... * connected 192.168.99.131 (192.168.99.131) port 8000 (#0

dictionary - markov first order text processing in python -

i wrote codes text generating given text file. use markov first order model. first create dictionary text file. in case of punctuation ('.','?','!') key '$'. after creating dictionary generate text randomly created dictionary. when detect '$' start new sentence. code given below: import random def createdictionary(filename): '''creates dictionary following words word using text input''' file = open(filename, "r") text = file.read() file.close() low = text.split() low = ["$"] + low wd = {} index = 0 while index < len(low): ##make dictionary entries word = low[index] if word not in wd: if word[-1] == "?" or word[-1] =="." or word[-1] =="!": word = "$" wd[word] = [] index += 1 index = 0 while index < (len(low) - 1): #make list each of entr

excel vba - Function to get Usedrange gets error 91 -

trying write union of ranges function i `object variable or block not set" i not getting right (i think): rng unionrange = intersect(ws.usedrange, rng.entirecolumn) end sub iunionrange() dim r range 'check see if function working set r = unionrange("elements", range("a1:d1, g1:g1, i1:k1")) r.select end sub the function function unionrange(shtname string, rng range) range set ws = thisworkbook.sheets(shtname) if rng nothing exit function ws.rng unionrange = intersect(ws.usedrange, .entirecolumn) end end function first of all, use set keyword assign object variable, unionrange = should set unionrange = . specify sheet object when retrieving range, doing it's not necessary pass sheet name function since rng.parent returns sheet object. there example below: sub test() dim q range dim r range set q = sheets("elements").range("a1:d1, g1:g1, i1:k1") q.select set r = u

ios - didReceiveRemoteNotification presentViewController from anywhere when running -

i'm trying present uiviewcontroller when remote notification received. my code works point, when app running , user on other first screen/navigation stack, uiviewcontroller isn't presented. can please? note want keep navigation bar when uiviewcontroller presented i warning when try present 'uiviewcontroller' elsewhere warning: attempt present on view not in window hierarchy! thanks in advance here code didreceiveremotenotification: func application(application: uiapplication, didreceiveremotenotification userinfo: [nsobject : anyobject]) { var payload = userinfo let requestid = payload["requestid"] as! string let rootviewcontroller = self.window!.rootviewcontroller as! uinavigationcontroller let storyboard : uistoryboard = uistoryboard(name: "main", bundle: nil) let vc : requestviewcontroller = storyboard.instantiateviewcontrollerwithidentifier("requestviewcontroller") as! requestviewcontroller vc.r

Swift write/save/move a document file to iCloud drive -

i've been trying on 2 days write file icloud drive. have tried writing simple text file directly, locally moving it, using uidocumentmenuviewcontroller, etc. i'm not getting errors code , stepping through debugger, looks successful, when check see if file exists or @ least icloud directory, there nothing there. tried on both simulator , iphone, triggering icloud synching, , else can think of. my main goal write text file icloud drive, later "numbers" file i have set plist file , entitlements: <key>nsubiquitouscontainers</key> <dict> <key>icloud.com.paul.c.$(product_name:rfc1034identifier)</key> <dict> <key>nsubiquitouscontainerisdocumentscopepublic</key> <true/> <key>nsubiquitouscontainername</key> <string>mycloudtest</string> <key>nsubiquitouscontainersupportedfolderlevels</key> <string>any</string>

gcc - Do C++ compilers perform compile-time optimizations on lambda closures? -

suppose have following (nonsensical) code: const int = 0; int c = 0; for(int b = 0; b < 10000000; b++) { if(a) c++; c += 7; } variable 'a' equals zero, compiler can deduce on compile time, instruction 'if(a) c++;' never executed , optimize away. my question: does same happen lambda closures? check out piece of code: const int = 0; function<int()> lambda = [a]() { int c = 0; for(int b = 0; b < 10000000; b++) { if(a) c++; c += 7; } return c; } will compiler know 'a' 0 , optimize lambda? even more sophisticated example: function<int()> generate_lambda(const int a) { return [a]() { int c = 0; for(int b = 0; b < 10000000; b++) { if(a) c++; c += 7; } return c; }; } function<int()> a_is_zero = generate_lambda(0); function<int()> a_is_one = generate_lambda(1); will compiler smart enough optimize f

string - Inserting carriage returns when sending text to the iOS Calendar -

Image
i'm sending text ios calendar using following code. event.title = " \(jobtitle) \r\n" + "\(jobdescription)" this not work. don't carriage return. know of work around job titles , job descriptions display on multiline when sending event.title? event.title = "\(jobtitle)\n\(jobdescription)" should works. note: not every view in ios calendar application correctly display multi-line title event. for example: ev.title = "testjobtitle\ntest job description" list view: detail view: grid view:

jta - I want to use Spring,Bitronix,Infinispan And Oracle,but An error event occur -

i want use bitronix, infinispan , oracle after programe call cache#put for while ,an error event occur java.lang.illegalargumentexception: tmnoflags flag must used when no other flags specified. received 0 @ org.infinispan.transaction.xa.transactionxaadapter.recover(transactionxaadapter.java:139) @ bitronix.tm.recovery.recoveryhelper.recover(recoveryhelper.java:103) @ bitronix.tm.recovery.recoveryhelper.recover(recoveryhelper.java:74) @ bitronix.tm.recovery.recoverer.recover(recoverer.java:259) @ bitronix.tm.recovery.recoverer.recoverallresources(recoverer.java:226) @ bitronix.tm.recovery.recoverer.run(recoverer.java:142) @ java.lang.thread.run(thread.java:745) these following versions: bitronix 2.1.3 spring 4.1 infinispan 9.0.1 oracle 11g tomcat 8.5 btm-infinispan ( because code dependented on old infinispan,i modify new version code) https://github.com/pkelchner/btm-infinispan please tell me how handle correctly

vector - C++ - Optimal way to use multiple values as a key in unordered_map -

i'm programming class working state-spaces. problem is, don't know, what's ideal way use multiple values key in unordered_map . it's supposed work way: i create state object values <1;0;8>, it'll inserted hashmap <1;0;8>:pointer_to_object . want hashmap because need find objects fast possible. i thought using vector or tuple . is possible use 1 of them key unordered_map without specifying size in advance? edit: i've tried use code recommended @the_mandrill this: template <class t> typedef std::unordered_map<std::vector<t>, state<t>*, boost::hash<std::vector<t>> map; template <class t> size_t hash_value(const std::vector<t>& vec) { std::size_t seed = 0; (const auto& val : vec) { boost::hash_combine(seed, val); } return seed; } but i'm getting error: statespacelib.cpp:79:83: error: template argument 3 invalid typedef std::unordered_map<std:

css - Why isnt my HTML code rendering? -

i'm using notepad ++ , when try open code in chrome shows literal css code. <!doctype html> <html> <head> <link rel="stylesheet" type="text/css" href="test.css" </head> <title>test<title> <body> <p>red</p> <div class="test1"> </body> </html> <!doctype html> <html> <head> <link rel="stylesheet" type="text/css" href="test.css"> <title>test<title> </head> <body> <p>red</p> <div class="test1"></div> </body> </html> you need close div, close stylesheet reference, , move title header.

java - Set label layout in panels -

in frame, i'm adding labels for, in panel. problem can't solve is adding label on same line whereas want add \n between 1 , generate column! i've no idea how it. help? thank you! the key believe layout of container holding jlabels. if give container proper layout such boxlayout oriented along page_axis, or gridlayout(0, 1) 1 column variable number of rows, jlabels stack 1 on top of other. e.g., import java.awt.gridlayout; import javax.swing.*; public class stackinglabels extends jpanel { public static final string[] texts = { "sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday" }; public stackinglabels() { setlayout(new gridlayout(0, 1)); (string text : texts) { add(new jlabel(text)); } } private static void createandshowgui() { stackinglabels mainpanel = new stackinglabels(); jfra

r - decision tree - customize plot title when using Rattle and rpart.plot -

Image
i created decision tree using rattle , rpart.plot package . package supposed make output more "pretty" regular rattle output. here's output looks like. my question: don't how default title (top legend) looks. how may customize (change wording or font size)? update: rattle gui. didn't use code create decision tree (i still learning code in r). however, went , posted following pastebin: http://pastebin.com/ntfpsyfx , rattle log (this may contain code used generate rpart.plot ). http://pastebin.com/lmjs9z5b , text output rattle.

javascript - Meteor templates not recognized in server code -

i building app in meteor , trying send email server-side method. email's template exists in client/views folder. when try send email server-side code, error 'template not defined'. here's code: /server/methods/sendemail.js var html = blaze.tohtmlwithdata(template.emailtocustomer, datacontext); meteor.call('sendemail', thisuser.emails[0].address, 'mine@mine.org', 'yours@gmail.com', 'email subject', html ); my email template simple html page. note code works fine if exists in client/views/mytemplate.js. however, technical reasons, need email sent server-side code. i have tried placing mytemplate.html , mytemplate.js files in app/both , app/server folders, still template not defined error. anyone have ideas might going on? thanks! your templates defined under client directory it's normal not available in server con

shell - pushd not working in makefile -

i have following rule in makefile: ninja: git clone git://github.com/martine/ninja.git pushd ninja pwd git checkout release ./configure.py --bootstrap popd the idea download , build ninja automatically project dependency. notice pwd command there make sure directory pushed. here's output generates: git clone git://github.com/martine/ninja.git cloning 'ninja'... remote: counting objects: 8646, done. remote: compressing objects: 100% (4/4), done. remote: total 8646 (delta 0), reused 0 (delta 0), pack-reused 8642 receiving objects: 100% (8646/8646), 1.88 mib | 427.00 kib/s, done. resolving deltas: 100% (6114/6114), done. checking connectivity... done. pushd ninja ~/desktop/core/ninja ~/desktop/core pwd /users/fratelli/desktop/core git checkout release error: pathspec 'release' did not match file(s) known git. make: *** [ninja] error 1 as can see directory pushed stack, pwd not return correct directory. that's why checkout fai

collections - How to easily convert IndexedSeq[Array[Int]] to Seq[Seq[Int]] in Scala? -

i have function takes list of lists of integer, seq[seq[int]] . produce data reading text file , using split , , produces list of array . not recognized scala, raises match error. either indexedseq or array alone ok seq[int] function, apparently nested collection issue. how can convert implicitly indexedseq[array[int]] seq[seq[int]] , or how else other using tolist demonstrated below? iterable[iterable[int]] seems fine, instance, can't use this. scala> def g(x:seq[int]) = x.sum g: (x: seq[int])int scala> g("1 2 3".split(" ").map(_.toint)) res6: int = 6 scala> def f(x:seq[seq[int]]) = x.map(_.sum).sum f: (x: seq[seq[int]])int scala> f(list("1 2 3", "3 4 5").map(_.split(" ").map(_.toint))) <console>:9: error: type mismatch; found : list[array[int]] required: seq[seq[int]] f(list("1 2 3", "3 4 5").map(_.split(" ").map(_.toint)))

android - Knowing when a person has moved to the left (right) relative to last known position -

is there way in android programming know when person carrying android device has moved left/right [more shifting right/left] in reference last known position? for example: if held android device left of me, moving right, app should tell me relative last position of device, has moved right. there 2 different ways of doing this, maybe more. you use compass find direction phone pointing @ start , end, , accelerometer tell way moved. similarly use gps coordinates in lieu of accelerometer. both of these methods might give false positives or might not pick up- first 1 you'd have false positives dues jerky movement (you'd have employ filtering or data useless) while second have issues there resolution of gps not tight enough (say within 10 feet of starting point). gps doesn't work indoors. some devices won't have combination of sensors need. if more specific conditions , environment might able edit give better answer.

Excel columns to multiple rows -

Image
i have set of data consists of product sku, , sizes multiple columns. need transpose data list sizes in 1 column (which can do) but, each size needs list sku can't seem achieve transpose. see images example. follow these steps... 1 click on cell right of data. on keyboard press alt , while holding alt down, press d , let go. now press p on keyboard. the ancient pivottable wizard should displayed. 2 select multiple consolidation ranges . click on next button. 3 select i create page fields . click on next button. 4 for range field @ top of dialog, select range a1:j6. (this sample data.) click on finish button. 5 you see pivottable. going double-click 1 particular cell... , create new worksheet data transposed , normalized. cell bottom-right cell of pivottable (at intersection of grand total , grand total). double-click it. 6 on new sheet displayed, delete column b , click on little arrow in cell b1. uncheck (blanks) , click ok. that'

javascript - Counting number of occurrences recursively -

why recursive countoccurence function not working? has subroutine. there way without subroutine? seems in javascript have have closure (subroutine function) counter variable, otherwise gets rewritten every time! function numoccurencesrecursive(arr, val) { //base case. check if has length of 1 var count = 0; function docount(arr, val) { if (arr[0] === val) { count++; } else { count += docount(arr.slice(1), val) } return count; } return docount(arr, val); } console.log(numoccurencesrecursive([2, 7, 4, 4, 1, 4], 4)); // should return 3 returns 1 i think problem thinking iteratively used recursive approach. the iterative approach has global variable may updated @ each step: function numoccurencesiterative(arr, val) { var count = 0; for(var i=0; i<arr.length; ++i) if(arr[i] === val) ++count; return count; } however, when using recursive approaches, better avoid global variables. function numoccurencesrecursive(arr, val

scala - How to join two RDDs by key to get RDD of (String, String)? -

i have 2 paired rdds in form rdd [(string, mutable.hashset[string]): for example: rdd1: 332101231222, "320758, 320762, 320760, 320759, 320757, 320761" rdd2: 332101231222, "220758, 220762, 220760, 220759, 220757, 220761" i want combine rdd1 , rdd2 based on common keys, o/p should like: 332101231222 320758, 320762, 320760, 320759, 320757, 320761 220758, 220762, 220760, 220759, 220757, 220761 here code: def cogrouptest (rdd1: rdd [(string, mutable.hashset[string])], rdd2: rdd [(string, mutable.hashset[string])] ): unit = { val prods_per_user_co_grouped = (rdd1).cogroup(rdd2) prods_per_user_co_grouped.map { case (key: string, (value1: mutable.hashset[string], value2: mutable.hashset[string])) => { val combinedhs = value1 ++ value2 val sstr = combinedhs.mkstring("\t") val keypadded = key + "\t" s"$keypadded$sstr" } }.saveastextfile("/scratch/rdds_joined/") here error when run program: scala.matcherr

php - Smarty concat/foreach assignment -

i have main array: $occupations = ['hs','uni','parent']; and other multiple array of type $columns_hs;$columns_uni; etc. want foreach through "$occupations" array , foreach through other arrays cant seem right syntax. here code: {foreach from=$occupations item=ov key=ok} {foreach from=$columns_`$ov`} {/foreach} {/foreach} i using smarty 2. you can try create own varible assign

delphi - How do I make my GUI behave well when Windows font scaling is greater than 100% -

Image
when choosing large font sizes in windows control panel (like 125%, or 150%) there problems in vcl application, every time has been set pixelwise. take tstatusbar.panel . have set width contains 1 label, big fonts label "overflows". same problem other components. some new laptops dell ship 125% default setting, while in past problem quite rare important. what can done overcome problem? note: please see other answers contain valuable techniques. answer here provides caveats , cautions against assuming dpi-awareness easy. i avoid dpi-aware scaling tform.scaled = true . dpi awareness important me when becomes important customers call me , willing pay it. technical reason behind point of view dpi-awareness or not, opening window world of hurt. many standard , third party vcl controls not work in high dpi. notable exception vcl parts wrap windows common controls work remarkably @ high dpi. huge number of third party , built-in delphi vcl custom controls no

xml - cvc-elt.1: Cannot find the declaration of element 'Root' -

xsd sample <?xml version="1.0" encoding="utf-8" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema"> <xs:element name="shiporder"> <xs:complextype> <xs:sequence> <xs:element name="orderperson" type="xs:string" /> <xs:element name="name" type="xs:string" /> <xs:element name="address" type="xs:string" /> </xs:sequence> <xs:attribute name="orderid" type="xs:string" /> </xs:complextype> </xs:element> </xs:schema> xml response sample <?xml version="1.0" encoding="utf-8"?> <shiporder orderid="str1234"> <orderperson>str1234</orderperson> <name>str1234</name> <address>str1234</address> </shiporder> schema validate dom source http://hostcode.sourceforge.net

python - Single quotes around list elements that should be floats -

i asked "return list of tuples containing subset name (as string) , list of floating point data values". my code is: def load_data(filename): fileopen = open(filename) result_open=[] line in fileopen: answer = (line.strip().split(",")) result_open.append((answer[0],(answer[1:]))) return result_open however, when run code, following appears: [('slow loris', [' 21.72', ' 29.3', ' 20.08', ' 29.98', ' 29.85', ' 26.22', ' 19......)] is there anyway change tuple appear without apostrophes? want like: [('slow loris', [21.72, 29.3, 20.08, 29.98, 29.85, 6.22, 19......)] line string, , line.strip().split(",") list of strings. need convert string values float or decimal values. 1 way be: result_open.append((answer[0], [float(val) val in answer[1:]])) that raise exception on values can't converted float, should think how want handl

python - Reading DateField with specific format from SQL database using peewee -

i read column of date sql database. however, format of date in database 27-jan-13 day-month-year . when read column using peewee datefield read in format cannot compared later using datetime.date . can me solve issue? you need store data in database using format %y-%m-%d. when extract data can present in format like, ensure data sorted correctly (and recognized sqlite date) must use %y-%m-%d format (or unix timestamps if prefer way).

javascript - Unit Testing a function inside a angular directive using jasmine -

i have directive in angular js. adds 'src' attribute image element shown below. myapp.directive('imageonload', ['$q',function($q) { var dpromise; function loadimg(scope,target,url) { var deferred = $q.defer(); dpromise = deferred.promise; var img = new image(); // onload handler (on image, not element) img.onload = function() { img.onload = null; //target.src = url; deferred.resolve(url); }; img.onerror = function() { img.onerror = null; //target.src = url; deferred.resolve(url); }; // set source image initiate load img.src = url; return dpromise; } return { restrict: 'a', link: function(scope, element, attrs) { loadimg(scope,el

python - How to use Pearson Correlation as distance metric in Scikit-learn Agglomerative clustering -

i have following data : state murder assault urbanpop rape alabama 13.200 236 58 21.200 alaska 10.000 263 48 44.500 arizona 8.100 294 80 31.000 arkansas 8.800 190 50 19.500 california 9.000 276 91 40.600 colorado 7.900 204 78 38.700 connecticut 3.300 110 77 11.100 delaware 5.900 238 72 15.800 florida 15.400 335 80 31.900 georgia 17.400 211 60 25.800 hawaii 5.300 46 83 20.200 idaho 2.600 120 54 14.200 illinois 10.400 249 83 24.000 indiana 7.200 113 65 21.000 iowa 2.200 56 57 11.300 kansas 6.000 115 66 18.000 kentucky 9.700 109 52 16.300 louisiana 15.400 249 66 22.200 maine 2.100 83 51 7.800 maryland 11.300 300 67 27.800 massachusetts 4.400 149 85 16.300 michigan 12.100 255 74 35.100 minnesota 2.700 72 66 14.900 mississippi 16.100 259 44 17.100 missouri 9.000 178 70 28.200 montana 6.000 109 53 16.400 nebraska 4.300 102 62 16.500 nevada 12.200 252 81 46.00

javascript - Multer new version, undefined uploaded images file -

when uploaded image multer middle ware, got undefined file image. in other words, cannot name or file extension file uploaded. don't know if error multer. here js file: var express = require('express'); var multer = require('multer'); var upload = multer({dest:'uploads/'}); var router = express.router(); router.post('/register', upload.single('profile'), function(req, res, next){ if(req.file){ console.log("uploading files"); //get properties of files object var profileimageoriginalname = req.file.profile.originalname; var profileimagename = req.file.profile.name; var profileimagemime = req.file.profile.mimetype; var profileimagepath = req.file.profile.path; var profileimageext = req.file.profile.extension; var profileimagesize = req.file.profile.size; } and here html form file in jade format : input.form-control(name = 'profile', type = 'file

matlab - Combine a (m x n x p) matrix (image) of 8 bit numbers to a (m x n) matrix of 24 bit numbers and vice versa -

say there matrix of (m x n x p), esp. color image r g , b channel. each channel information 8-bit integer. but, analysis, 3 8-bit values have combined 24-bit value , analysis done on (m x n) matrix of 24-bit values. after analysis, matrix has decomposed 3 8-bit channels displaying results. what doing right now: iterating through values in matrix convert each decimal value binary (using dec2bin ) combine 3 binary values 24-bit number (using strcat , bin2dec ) code: i=1:m j=1:n new_img(i,j) = bin2dec(strcat(... sprintf('%.8d',str2double(dec2bin(img(i,j,1)))), ... sprintf('%.8d',str2double(dec2bin(img(i,j,2)))), ... sprintf('%.8d',str2double(dec2bin(img(i,j,3)))))); end end for decomposition 3 8-bits after analysis, exact reverse process done, still iterating through (m x n) values. the problem huge computation time. i know not correct way of doing this.

XSLT - Iterate xml and output html li links of child nodes -

i new xslt, me in fixing issue xslt code. trying loop through each xml record , generate li links based on multiple bu , primary metadata of every record xml entry. trying output in html below, document , market bu/primary lines being hyperlinks. required output: title 1 - document bu , primary sample links document primary title 1 document bu title 1 document bu title 2 document bu title 3 document bu title 4 title 2 - market bu , primary sample links market primary title 1 market bu title 1 market bu title 2 market bu title 3 market bu title 4 xslt code: <xsl:template match="r"> <tr> <td> <xsl:choose> <xsl:when test="starts-with(u, 'http://abc.domain.com/') ">