Skip to content

Instantly share code, notes, and snippets.

@shenqi
shenqi / risona.R
Created August 13, 2014 09:22
りそなダイレクトからダウンロードできる入出金明細データとVISAデビットデータを組み合わせて見やすいCSVファイルを出力する
library(stringr)
# 出入金レコード
b <- read.csv('bank statement.csv', fileEncoding='cp932')
b$date <- paste0(b$取扱日付.年,'/',b$取扱日付.月,'/',b$取扱日付.日)
b$amount <- ifelse(b$取引名 == '入金', b$金額, -b$金額)
b$detail <- ifelse(str_detect(b$摘要, 'VISA'), str_sub(b$摘要, 11, 16), as.character(b$摘要))
b$payee <- ifelse(str_detect(b$摘要, 'VISA'), '', as.character(b$摘要))
# b[,22:25]
@shenqi
shenqi / tidy_plot.R
Last active August 29, 2015 14:01
Tidy and combine ggplot
library(gtable)
require(gtable)
library(foreach)
require(foreach)
unit.def <- 'inches'
plot.length.def <- 6
legend.length.def <- 1.5
as.unit <- function(n){return(unit(n, unit.def))}
@shenqi
shenqi / draw_ggplot.R
Last active August 29, 2015 14:01
Pre-defined formats for ggplot
library(ggplot2)
require(ggplot2)
# also require ggplot_lm.R on https://gist.github.com/shenqi/29b42a6be83ec9e0517d
ggplot0 <- function(x, y, data, label, shape, ...){
return(ggplot(data, aes_string(x = x, y = y, label = label, shape = shape, ...)))
}
draw_ggplot <- function(x, y, data, point.size, label, label.hjust, shape, shape.solid, lm_formula, r2.adjusted, r2.pos_x, r2.pos_y, r2.digits, r2.color, legend.position, ...) {
g0 <- ggplot0(x, y, data, label, shape, ...) + geom_point(size = I(point.size)) + theme_classic()
@shenqi
shenqi / ggplot2_lm.R
Last active August 29, 2015 14:01
Extension of ggplot2 to work friendly with lm object
library(ggplot2)
require(ggplot2)
# usage
#
# stat_r2(lm_obj, x, y, adjusted = FALSE, digits=NULL, ...)
# lm_obj lm object given by lm()
# x, y positional coordinate of r2 value
# adjusted use adjusted R2 instead
# digits see format()
#!/usr/bin/env zsh
if ! test -e /Applications/Xcode.app/; then
echo -e "\e[33;1mNeeds Xcode installed. Aborting...\e[m";
open 'macappstore://itunes.apple.com/jp/app/xcode/id497799835?mt=12' && exit 1
fi
function check_n_install(){
local com2 com3
if ! test -x $(/usr/bin/which $1); then
echo -e "\e[36mInstalling $1...\e[m"
@shenqi
shenqi / using clang
Created August 1, 2012 04:06
config.log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by configure, which was
generated by GNU Autoconf 2.57. Invocation command line was
$ ./configure --prefix=/usr/local/Cellar/screen/4.00.03 --mandir=/usr/local/Cellar/screen/4.00.03/share/man --infodir=/usr/local/Cellar/screen/4.00.03/share/info --enable-colors256
## --------- ##
## Platform. ##
@shenqi
shenqi / using llvm
Created August 1, 2012 04:03
config.log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by configure, which was
generated by GNU Autoconf 2.57. Invocation command line was
$ ./configure --prefix=/usr/local/Cellar/screen/4.00.03 --mandir=/usr/local/Cellar/screen/4.00.03/share/man --infodir=/usr/local/Cellar/screen/4.00.03/share/info --enable-colors256
## --------- ##
## Platform. ##
/*
* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
*
* Uses the built in easing capabilities added In jQuery 1.1
* to offer multiple easing options
*
* TERMS OF USE - jQuery Easing
*
* Open source under the BSD License.
*
@shenqi
shenqi / skel.html
Created May 10, 2012 17:16
Skel for HTML5
<!DOCTYPE HTML>
<html lang="ja">
<head>
<meta charset="UTF-8" />
<title>tarorow-shenqi.com</title>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link rel="stylesheet" href="http://yui.yahooapis.com/3.5.0/build/cssreset/cssreset-min.css" />
@shenqi
shenqi / exifinfo.sh
Created March 8, 2012 17:37
Change Exif Info for films scanned
function exif_film_lx(){
foreach _file ($@)
echo 'Processing '${_file}
local _date
_date="$(exiftool -s3 -IPTC:DateCreated ${_file}) 00:00:00"
exiftool -q -overwrite_original -Make='Pentax' -Model='LX' -XMP-photoshop:DateCreated=${_date} -
IPTC:TimeCreated='00:00:00+00:00' -Exif:DateTimeOriginal=${_date} ${_file}
end
growlnotify -s -a /Applications/iTerm.app "iTerm" -m "Finished rewriting tags"
}