This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select repository_url, repository_language, repository_created_at, repository_description, MAX(repository_watchers) as watches | |
from [githubarchive:github.timeline] | |
where repository_watchers > 20 | |
group each by repository_url, repository_language, repository_created_at, repository_description | |
order by watches desc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def initialize(args = {}) | |
defaults = { | |
:file_list_cache_dir => 'cache/filelists/', | |
:img_root => 'cache/img/', | |
:sensor_res_img_root => 'cache/srimg/' | |
} | |
defaults.merge(args).each do |attr, val| | |
instance_variable_set("@#{attr}", val) if defaults.has_key?(attr) && (not val.nil?) | |
end if args | |
setup |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// nY(dst_r_from + (0:rows-1), dst_c_from + (0:cols-1), :) = YY(src_r_from + (0:rows-1), src_c_from + (0:cols-1), :); | |
void copy_patch(Mat& nY, const Mat& YY, int dst_r_from, int dst_c_from, int src_r_from, int src_c_from, int rows, int cols) { | |
int row_bytes = cols * YY.channels() * YY.elemSize1(); | |
const uchar* pYY = (const uchar*)YY.data + YY.step[0] * src_r_from + YY.step[1] * src_c_from; | |
uchar* pnY = (uchar*)nY.data + nY.step[0] * dst_r_from + nY.step[1] * dst_c_from; | |
for (int i = 0; i < rows; i++, pnY += nY.step[0], pYY += YY.step[0]) { | |
memcpy(pnY, pYY, row_bytes); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mex.h" | |
// undef needed for LCC compiler | |
#undef EXTERN_C | |
// mex mex_show_sparse.cpp -O -largeArrayDims | |
// a = sparse(rand(10)<0.1) | |
// mex_show_sparse(a); | |
// b = a .* rand(10) | |
// mex_show_sparse(b); | |
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# given a directory or a set of files | |
# concatenate the binary files | |
# output a single binary file | |
# usage: | |
# ruby concatenate_binary_files "/xxx/xx/*.bin" "/xxx/xx.bin" | |
infiles = ARGV[0] | |
outpath = ARGV[1] | |
File.open(outpath, 'wb') do |outfile| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int nextpow2 (int x) { | |
if (x < 0) | |
return 0; | |
--x; | |
x |= x >> 1; | |
x |= x >> 2; | |
x |= x >> 4; | |
x |= x >> 8; | |
x |= x >> 16; | |
return x+1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [I, J, xvals] = get_local_maxima(imcor, radius) | |
% a = rand(10); | |
% [I, J, xvals] = get_local_maxima(a, 3); | |
% figure, imagesc(a); hold on; scatter(J, I); | |
[m, n] = size(imcor); | |
nim = ones(m + radius * 2, n + radius * 2) * 1e-10; | |
nim(radius + (1:m), radius + (1:n)) = imcor; | |
cols = im2col(nim, [2*radius + 1, 2 * radius + 1], 'sliding'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function val = init_option(options, name, default_val) | |
% usage lamda = init_option(options, 'lamda', 0.01); | |
if isfield(options, name), val = options.(name); else val = default_val; end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function t = get_threshold(v) | |
% pitch the lowest 20% | |
[m, inds] = sort(v); | |
P = fix(0.2 * length(v)); | |
nt = m(P); | |
P = fix(0.8 * length(v)); | |
nt2 = m(P); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [ao, bo, offset, y] = align(a, b) | |
% align two signals a and b | |
% ao and bo are aligned ones with same length | |
% y is the correlation xcorr(a, b) | |
% a_ind + offset -> b_ind | |
% if offset >= 0, cut a, else cut b | |
an = length(a); bn = length(b); | |
N = max(an, bn); |