This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Document | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def key(name, type) | |
puts "a new key `#{name}` in `#{type}` is declared." | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
line_tracer = TracePoint.new(:line) do |tp| | |
p [tp.path, tp.lineno] | |
end | |
RSpec.configure do |config| | |
# enable for each test case | |
config.around do |example| | |
line_tracer.enable do | |
example.run | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s3sync = { | |
maxProcesses = 1, | |
onStartup = "aws s3 sync ^source ^target", | |
onCreate = "[ -f ^source^pathname ] && aws s3 cp ^source^pathname ^target^pathname || true", | |
onModify = "[ -f ^source^pathname ] && aws s3 cp ^source^pathname ^target^pathname || true", | |
onDelete = "[ -f ^source^pathname ] && aws s3 rm ^target^pathname || true", | |
onMove = "aws s3 mv ^target^o.pathname ^target^d.pathname", | |
} | |
sync { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(int argc, char **argv) { | |
for (int i = 0; i < 4; i++) { | |
int j = i; | |
printf("&i = %p, &j = %p\n", &i, &j); | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
for i := 0; i < 4; i++ { | |
j := i | |
fmt.Printf("&i = %p, &j = %p\n", &i, &j) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Place your key bindings in this file to override the defaults | |
[ | |
// cycle tabs in the current group with ctrl+tab and ctrl+shift+tab | |
{ | |
"key": "ctrl+tab", | |
"command": "workbench.action.nextEditorInGroup" | |
}, | |
{ | |
"key": "ctrl+shift+tab", | |
"command": "workbench.action.previousEditorInGroup" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveRecord::Tasks::DatabaseTasks | |
class <<self | |
prepend Module.new { | |
def migrate(environment = env) | |
each_current_configuration(environment) { |configuration| | |
begin | |
ActiveRecord::Base.establish_connection(configuration) | |
super() | |
ensure | |
ActiveRecord::Base.establish_connection(environment.to_sym) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source "https://rubygems.org" | |
gem "sinatra" | |
gem "tilt-jbuilder", ">= 0.4.0", :require => "sinatra/jbuilder" | |
gem "hashie" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
# byte単位で計算されたインデックスを文字単位に変換する。 | |
# 文字の途中や、範囲外の値が渡されたらnilを返す。 | |
# | |
def byteindex2charindex(byteindex) | |
return 0 if byteindex == 0 | |
cur = 0 | |
codepoints.each.with_index(1) do |codepoint, index| | |
cur += codepoint.chr(Encoding::UTF_8).bytesize |