Skip to content

Instantly share code, notes, and snippets.

@3100
3100 / keymap.cson
Last active Jun 27, 2018
keymap.cson
View keymap.cson
'.CodeMirror.vim-mode:not(.insert-mode):not(.key-buffering) textarea':
'0': 'vim-mode:move-to-beginning-of-line'
@3100
3100 / integral.ml
Last active Jan 8, 2018
台形近似で定積分を求める関数 (『プログラミング in OCaml』 練習問題 3.14 )
View integral.ml
(* @param f float -> float
* @param a, b a < b
* @return result
* @example
* let pi = 3.1415926535;;
* integral sin 0.0 pi;;
*)
let integral f a b =
let n = 1e5 in
let delta = (b -. a) /. n in
@3100
3100 / .cvimrc
Last active Nov 26, 2015
.cvimrc
View .cvimrc
let scrollstep = 200
let hintcharacters = 'fjdksla;gh'
" Mapping
map ; openCommandBar
map gr previousTab
map d x
@3100
3100 / mackerel.service
Created Aug 10, 2015
mackerelの自動起動(systemd@arch)
View mackerel.service
[Unit]
Description=Run mackerel agent
[Service]
Type=simple
ExecStart=/opt/mackerel-agent/mackerel-agent --conf=/etc/mackerel-agent/mackerel-agent.conf
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
View gist:f5aa6bbd879f65185627
function hoge() {
var a;
return "hello";
}
@3100
3100 / pca.py
Last active Aug 29, 2015
主成分分析でn次元に縮小させた結果から画像を復元してみる
View pca.py
from sklearn.decomposition import PCA
from PIL import Image
import numpy as np
import scipy as sp
if __name__ == '__main__':
# 画像ファイル名に変えてください
filePath = 'gs.jpg'
# 試行するnの組(画像ピクセルサイズの最大数を超えないこと)
ns = [1,2,5,10,50,100,250]
View gist:feda22d6bd5ea565aea2
Step 12 : RUN /etc/init.d/sshd start;/etc/init.d/sshd stop
---> Running in 88e8c405c1eb
/bin/sh: /etc/init.d/sshd: No such file or directory
/bin/sh: /etc/init.d/sshd: No such file or directory
INFO[0001] The command [/bin/sh -c /etc/init.d/sshd start;/etc/init.d/sshd stop] returned a non-zero code: 127
@3100
3100 / run_test.R
Created Aug 28, 2014
run test of R code for dir
View run_test.R
library(testthat)
(function(){
dir <- dirname(sys.frame(1)$ofile)
Test <- function(src.name) {
message(src.name)
source(paste(dir, '/', src.name, sep = ''))
test_file(paste(dir, '/test_', src.name, sep = ''))
}
# HACK
src.names <- grep('^(?!test|run_test).+$',
@3100
3100 / install_packages.R
Last active Aug 29, 2015
Install all needed packages and load all in R
View install_packages.R
InstallPackages <- function(packages, repos) {
# インストールされていないパッケージをインストールします。
#
# Args:
# packages: 必要パッケージ一覧
new.packages <- packages[!(packages %in% installed.packages()[, "Package"])]
if(length(new.packages)) install.packages(new.packages, repos = repos)
for(package in packages) {
do.call("library", list(package = package))
}
@3100
3100 / sample.R
Created Aug 21, 2014
how to test a R script
View sample.R
Combine <- function(df1, df2, fmt) {
# 同じサイズの2つの行列を用いて、各セル値を合成します。
#
# Args:
# df1: 行列1
# df2: 行列2
# fmt: 表示書式(sprintf)
#
# Returns:
# 合成した行列
You can’t perform that action at this time.