Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View kentaro's full-sized avatar

Kentaro Kuribayashi kentaro

View GitHub Profile
@kentaro
kentaro / attre_accessor.ex
Last active January 31, 2022 23:47
Generate accessors for module attributes in Elixir
defmodule AttrAccessor do
defmacro __using__(opts) do
quote do
unquote(opts[:attrs])
|> Enum.each(fn attr ->
Module.register_attribute(unquote(opts[:target]), attr, persist: true)
end)
def method_missing(func, _args) do
if value = __MODULE__.__info__(:attributes)[func] do
// Amazonの注文履歴をCSV形式にして出力するスクリプト
//
// 以下のスクリプトを参考に作成されました。
// http://moroya.hatenablog.jp/entry/2013/06/03/225935
//
// CSVに成型しているのは14行目から定義されているformatEntryという関数なので、これを書き換えれば自由な書式で出力できます。
(function(){
// 各注文履歴をCSVフォーマットにして返す
var datePattern = new RegExp("(\\d{4})年(\\d{1,2})月(\\d{1,2})日");
@kentaro
kentaro / cf.rb
Last active March 20, 2016 16:23
mruby-changefinderを試すよ
cf = ChangeFinder.new(5, 0.01, 10, 0.01, 5)
File.open('result.tsv', 'w') do |f|
File.open('go.tsv').each do |line|
date, trend = line.chomp.split("\t")
score = cf.score(trend.to_f)
f.puts("#{date}\t#{trend}\t#{score}")
end
end
@kentaro
kentaro / idea.yml
Last active January 20, 2016 08:05
---
service: minne
enable:
- h2
- mruby
mrbgems:
- mruby-foo
- mruby-bar
@kentaro
kentaro / gist:e215a01425d857c3448f
Last active August 29, 2015 14:13
Karabinerの設定
<?xml version="1.0"?>
<root>
<list>
<item>
<name>LeaveInsMode with EISUU(Terminal)</name>
<identifier>private.app_terminal_esc_with_eisuu</identifier>
<only>TERMINAL</only>
<autogen>--KeyToKey-- KeyCode::BRACKET_LEFT, VK_CONTROL, KeyCode::JIS_EISUU, KeyCode::BRACKET_LEFT, VK_CONTROL</autogen>
</item>
</list>
package main
@kentaro
kentaro / gist:c76cdf6b99203620a3a0
Created June 12, 2014 02:29
percolで使ってたキーバインドとあわせる
{
"Keymap": {
"C-p": "peco.SelectPrevious",
"C-n": "peco.SelectNext",
"C-g": "peco.Finish",
"C-g": "peco.Cancel"
}
}
source percol/src.zsh
bindkey '^S' percol-src
#!/usr/bin/env ruby -w
def foo
puts "foo"
end
def foo
puts "redefined"
end