Skip to content

Instantly share code, notes, and snippets.

View amano41's full-sized avatar

Amano, Yoichi amano41

View GitHub Profile
@amano41
amano41 / Rprofile.R
Last active October 5, 2018 06:51
.Rprofile
## CRAN ミラーを指定
options(repos=list(CRAN="https://cran.rstudio.com/"));
## 起動時にロードするパッケージを追加
local({
pkgs <- getOption("defaultPackages");
options(defaultPackages=c(pkgs, "lattice", "car"));
});
## 零和対比をデフォルトに設定
@amano41
amano41 / qsort.py
Created January 26, 2013 01:48
Python の練習でクイックソートを書いてみました。
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import random
def qsort(ls):
if len(ls) <= 1: return ls
p = ls[0]
return qsort([x for x in ls if x < p]) + \
[p] + \
@amano41
amano41 / afterimage.pde
Last active December 17, 2015 16:49
Processing で補色残像のデモプログラムを作ってみました。 http://amano41.hateblo.jp/entry/2013/05/24/173703
/* ====================================================================== *
* 補色残像のデモプログラム
*
* 参考)
* http://www.johnsadowski.com/color_illusion_tutorial.html
* http://www.adobe.com/jp/devnet/pdf/pdf_reference_archive.html
* ====================================================================== */
static final String STIMULUS = "stimulus.jpg"; // 使用する画像
static final int DURATION = 30; // 呈示時間(秒)
@amano41
amano41 / colorball.pde
Last active December 21, 2015 01:38
ボールが色を変えながら回転するサンプル http://amano41.hateblo.jp/entry/2013/08/14/170508
int fps = 15;
int radius = 50;
int cycle = 5; // 回転周期
int speed = 5; // 拡散速度
int degree = 360 / (cycle * fps);
void setup() {
size(200, 200);
frameRate(fps);
@amano41
amano41 / SaveAsCSV.bas
Created April 21, 2014 05:52
Excel VBA で UTF-8 エンコーディングの CSV ファイルを出力するサンプル
Option Explicit
Sub SaveAsCSV()
'==============================
' 使用しているデータ範囲の取得
'==============================
Dim maxRow As Long
Dim maxCol As Long
@amano41
amano41 / WidthConverter.java
Created May 7, 2014 04:08
全角⇔半角の変換
/**
* 半角 ⇒ 全角
*/
String halfToFull(String value) {
StringBuilder sb = new StringBuilder(value);
for (int i = 0; i < sb.length(); i++) {
int c = (int) sb.charAt(i);
if ((c >= 0x30 && c <= 0x39) || (c >= 0x41 && c <= 0x5A) || (c >= 0x61 && c <= 0x7A)) {
@amano41
amano41 / Singleton.java
Created May 7, 2014 04:49
Singleton 遅延初期化ホルダー イディオム
public class Singleton {
private Singleton(){}
public static Singleton getInstance() {
return SingletonHolder.instance;
}
private static class SingletonHolder {
static final Singleton instance = new Singleton();
@amano41
amano41 / convert.sh
Created July 2, 2014 05:35
タイムスタンプを変更せずに画像を変換する。
#!/bin/sh
for file in *.jpg
do
out=${file%.*}.png
convert $file -rotate 90 $out
touch -r $file $out
done
@amano41
amano41 / read_csv.py
Last active October 29, 2015 08:29
Python で CSV ファイルの読み書き
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import csv
with open("sample.csv", "r") as f:
reader = csv.reader(f)
header = next(reader) # ヘッダを読み飛ばす
for row in reader: # 1 行ずつ文字列のリストとして読み込む
print(",".join(row))
@amano41
amano41 / rename-photo.sh
Created July 6, 2016 06:27
Exif の撮影日時をもとに JPEG ファイルをリネームする
#!/bin/bash
# -*- coding: utf-8 -*-
SRC="$1"
DIR=$(dirname "$SRC")
BASE=$(basename "$SRC")
EXT=$(echo "${BASE##*.}" | tr A-Z a-z)
## 撮影日時を取得