Posts

racket - Rotate a List of Lists -

i want take arbitrary list of lists , "rotate" it. is, list of lists of size 3x3: #lang racket (require rackunit) (define (rotate-lol lol) (append (list (map first lol)) (list (map second lol)) (list (map third lol)))) (check-equal? (rotate-lol (list (list 'a 'b 'c) (list 'd 'e 'f) (list 'g 'h 'i))) (list (list 'a 'd 'g) (list 'b 'e 'h) (list 'c 'f 'i))) i'm thinking list-ref replace first / second / third can't quite figure out concise way this. i know there has got elegant way this. i've done inelegant solutions problem in past more domain specific, i'd solve general case, stash in personal library, , done problem. tips or solutions? it's pretty zip , don't have make since it's in srfi-1 list library : (require srfi/1) (zip '(a b c) ...

Rails Grape API versioning -

i trying create skeleton rest api using rails 4.0.4 , grape 0.7.0 behave this: calling api specific version: $ curl -h accept=application/vnd.acme-v1+json http://localhost:3000/api/a “a-v1” $ curl -h accept=application/vnd.acme-v1+json http://localhost:3000/api/b “b-v1” calling api default: $ curl http://localhost:3000/api/a “a-v2” $ curl http://localhost:3000/api/b “b-v1” $ curl http://localhost:3000/api/c “c-v2” i have been trying couldn't desired behavior. ended following files in rails app: app/api/api.rb require 'grape' require 'api_v1.rb' require 'api_v2.rb' module api class base < grape::api mount api::v2 mount api::v1 end end app/api/api_v1.rb require 'grape' module api class v1 < grape::api version 'v1', using: :header, vendor: 'acme', format: :json prefix 'api' format :json :a "a-v1" end :b "b-v1" end end end a...

file - I need to write a Python script to sort pictures, how would I do this? -

what i'm looking script can go through huge list of pictures , sort them folders. so take pictures of dogs @ shows, lets take several pictures of dog1, dogs picture automatically named in serial number format (dog1-1, dog1-2, dog1-3, etc). dog2 follow same format. i'd script can take dog1-1-10 , move them folder named dog 1. dog2-1-10 folder named dog 2, etc. how can done in python? so basically, want is: find every file in given folder take first part of each filename , use folder name if folder doesn't exist, create it move file folder repeat well, nifty! figuring out want half battle -- now, it's matter of googling , turning code. first, need folder check in: folder_path = "myfolder" now, want find every file inside folder. quick googling session turns this : import os import os.path images = [f f in os.listdir(folder_path) if os.path.isfile(os.path.join(folder_path, f))] as aside, i'm going using os.path.join fa...

javascript - How to check client perfomance for webgl(three.js) -

i have graphic project using three.js , want check client gpu performance automatically , compute how many elements can load in application. think gpu benchmark. take @ stats.js , this threex plugin , webgl inspector .

matlab - Query for SVM classifier : svmtrain function -

i want use svmstruct = svmtrain(training,group) 2 classes ( noraml , abnormal ) images classification purpose,and size of training matrix 1*40 cells ,and each cell 75 rows * 10 columns want give training matrix svmtrain function after calling svmtrain function got error : error using svmtrain (line 241) training must numeric matrix could guide how correct error, because stuck in error, thank you. the following code lines tried : clc clear all; close all; %% after creating them in section of code section loading 2 training matrices load('norglobal_matrix_train_variablek10bin25md.mat') load('abglobal_matrix_train_variablek10bin25md.mat') counter_im=1; [row ,col]=size(norglobal_matrix_train_variablek10bin25md); i=1:10:row temp=norglobal_matrix_train_variablek10bin25md(i:i+9,1:end); trasposed_temp=temp'; normal_features {counter_im} =trasposed_temp; traininglabel{counter_im}=1 ; counter_im=counter_im+1; end svm=svmtrain(...

javascript - EmberJS multiple controllers on one page -

is possible have multiple controllers on 1 route / page. want show 2 features of application on 1 page. not directly related each need it's own controller, model , (partial) view. but can't seem figure out how this. it seems must use {{render}} option here. is possible have subdirectory structure here? when have {{render "dashboard.users"}} template in template/dashboard/users.hbs controller can't seem find looks , naming conventions should be. e.g. should app.dashboarduserscontroller = ... ? edit: looks should be, shouldn't place in subfolder of controllers name dashboard_users_controller.js you effect rendering templates multiple outlets of parent template: guide , api docs here running jsbin demonstrating it

c - What does clear_page_c do? -

during profiling, see of time spent in clear_page_c , followed memset . however, not know sure clear_page_c is. i assume clear_page_c sets data in page 0 haven't found documentation. best thing found far, quote this link : the clear_page_c function more worrying, kernel function related control of memory. web search did not reveal more information. you can read source find out does, though it's written in assembly, not c. short answer is, yes, fills page zero. http://code.woboq.org/linux/linux/arch/x86/lib/clear_page_64.s.html