Skip to content

Instantly share code, notes, and snippets.

View gogotanaka's full-sized avatar

Kazuki Tanaka gogotanaka

View GitHub Profile
@gogotanaka
gogotanaka / 0_reuse_code.js
Created November 28, 2016 01:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@gogotanaka
gogotanaka / libvips-installer.sh
Last active June 6, 2016 13:32 — forked from h2non/libvips-installer.sh
libvips 7.42.x cross-platform simple installer script (supports OSX, Debian, Ubuntu, CentOS, Fedora, Amazon Linux)
#!/bin/sh
#
# Orinally made by Lovell Fuller for sharp
# https://github.com/lovell/sharp
#
# Usage:
# curl -s https://gist.githubusercontent.com/h2non/89bb2f87c6499d0b25f1/raw/bf3d0743107f02f5db2b93c53f7f0e07a1c33112/libvips-installer.sh | sudo bash -
#
function x = conjgrad(A,b,tol)
% CONJGRAD  Conjugate Gradient Method.
%   X = CONJGRAD(A,B) attemps to solve the system of linear equations A*X=B
%   for X. The N-by-N coefficient matrix A must be symmetric and the right
%   hand side column vector B must have length N.
%
%   X = CONJGRAD(A,B,TOL) specifies the tolerance of the method. The
%   default is 1e-10.
%
@gogotanaka
gogotanaka / ludecomp.c
Last active January 18, 2016 15:55
ludecomp.c
#include<stdio.h>
main(){
long i,j,N=4,NRHS=1,IPIV[N],LDA=N,LDB=N,INFO;
double A[N*N],b[N];
/* 変数の説明 N:変数の数 NRHS:右辺の列数 IPIV[N]:Pivot選択の情報
LDA:左辺の行数 LDB:右辺の行数 INFO:ルーチンが成功したかどうかを返す */
/* 配列の引数は列に対して連続になるようにする(例:1行1列の次は2行1列) */
@gogotanaka
gogotanaka / tridiag.c
Created January 18, 2016 15:55
tridiag.c
/* 三重対角行列を係数行列に持つ連立一次方程式の数値解法(掃き出し法) */
/* 係数行列A=(a_{i,j})はa_{i,j}=2(if i==j),-1(if |i-j|==1),0(otherwise)である。*/
/* これは1次元微分方程式の離散化ではよく見かける形式である */
#include<stdio.h>
main(){
int i,j;
long N=10,NRHS=1,IPIV[N],LDA=N,LDB=N,INFO;
double DL[N-1],D[N],DU[N-1],b[N],h=1./N,hs=h*h;
(defun _null (x)
(eq x NIL))
(defun _or (x y)
(if x t (if y t NIL)))
(defun _not (x)
(if x NIL t))
(defun _and (x y)
(load "blockdata.lsp")
(load "helper.lsp")
(defun match-element (x y)
(or (equal x y) (equal y '?)))
(defun match-triple (x pat)
(every #'match-element x pat))
(load "blockdata.lsp")
(defun match-element (x y)
(or (eq x y) (eq y '?)))
(match-element 1 1)
(match-element 1 2)
(match-element 1 '?)
(defun match-triple (x pat)
@gogotanaka
gogotanaka / gist:8b3c3317b5be971dc755
Last active August 29, 2015 14:14
Add lat and lng to venue
Venue.where("latitude IS NULL").map{|v| v.latitude = v.location.lat; v.longitude = v.location.lng;v.save }
Venue.where("latitude IS NULL").
Venue.where("dbapp_id IS NULL").each do |v|
lat_lng = GogoMaps.get_latlng(v.location.to_pretty_full) rescue next
v.latitude = lat_lng[:lat]
v.longitude = lat_lng[:lng]
v.save
end
@gogotanaka
gogotanaka / gist:379b00397d494a2b22d2
Last active August 29, 2015 14:14
CRuby, Feature#10785

Ruby, math.c with Fixnum, after r49449

require 'benchmark'

print 'cos   '; puts Benchmark.realtime { 10_000_000.times { Math.cos    1    }}
print 'sin   '; puts Benchmark.realtime { 10_000_000.times { Math.sin    1    }}
print 'tan   '; puts Benchmark.realtime { 10_000_000.times { Math.tan    1    }}
print 'acos  '; puts Benchmark.realtime { 10_000_000.times { Math.acos   1    }}
print 'asin  '; puts Benchmark.realtime { 10_000_000.times { Math.asin   1    }}
print 'atan  '; puts Benchmark.realtime { 10_000_000.times { Math.atan   1    }}