View httpd.conf
<VirtualHost *>
ServerName blog.riywo.com
ProxyPreserveHost On
ProxyRequests off
<Proxy balancer://blog>
BalancerMember http://localhost:1313
BalancerMember http://blog.riywo.com.s3-website-us-west-2.amazonaws.com status=+H
</Proxy>
ProxyPass / balancer://blog/
</VirtualHost>
View gist:9976219fd5fd7fb22ea6
aws_s3_sync = "aws --region us-west-2 s3 sync public s3://blog.riywo.com --delete --storage-class=REDUCED_REDUNDANCY"
task :default => :server
task :server do
sh 'rm -fr public'
exec 'hugo server -b http://blog.riywo.com --appendPort=false -w --disableLiveReload'
end
task :test do
sh %Q{#{aws_s3_sync} --dryrun --size-only}
View gist:d77903a393e2f8df1580
<main class="content" role="main">
<article class="post post-section {{ .Section }}">
{{ range .Data.Pages.GroupByDate "Jan 2006" }}
<h3>{{ .Key }}</h3>
<ul>
{{ range .Pages }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
</li>
{{ end }}
View gist:0aee4f20f6f8a2a35242
classification=spark-defaults,properties=[spark.dynamicAllocation.enabled=true,spark.executor.memory=2G,spark.executor.cores=2]
View c.coffee
coffee> i*i for i in [1..9] when i % 2 == 0
[ 4, 16, 36, 64 ]
# https://github.com/jashkenas/coffee-script/issues/2030
# http://brehaut.net/blog/2011/coffeescript_comprehensions
coffee> [i,j] for j in [1..3] for i in [1..3]
[ [ [ 1, 1 ],
[ 1, 2 ],
[ 1, 3 ] ],
[ [ 2, 1 ],
View test.tsv
We can make this file beautiful and searchable if this error is corrected: No tabs found in this TSV file
aaaa bbb
ccc ddd
View gist:6790103
class String
def to_bin
bytes = self.size/2
self.unpack('a2'*bytes).map{|x| x.hex}.pack('C'*bytes)
end
end
"20814804c1767293b99f1d9cab3bc3e7".to_bin #=> " \x81H\x04\xC1vr\x93\xB9\x9F\x1D\x9C\xAB;\xC3\xE7"
View p.py
from subprocess import Popen, PIPE
p = Popen(["cat"], stdin=PIPE, stdout=PIPE)
print "stdin.write"
p.stdin.write("aaa")
p.stdin.flush()
print "stdout.read"
print p.stdout.readlines()
p.stdin.close()
p.wait()
View config.ru
require "anypow"
extend Anypow
run_pow "erb ./conf/nginx.conf.erb > ./conf/nginx.conf && ./sbin/nginx"
View gist:5937400
class Array
def cross(array)
product(array).map { |e| e.flatten }
end
end
p [1,2].cross([3,4])
#=> [[1, 3], [1, 4], [2, 3], [2, 4]]
p [1,2].cross([3,4]).cross([5,6])
#=> [[1, 3, 5], [1, 3, 6], [1, 4, 5], [1, 4, 6], [2, 3, 5], [2, 3, 6], [2, 4, 5], [2, 4, 6]]