Skip to content

Instantly share code, notes, and snippets.

View kayhide's full-sized avatar

Hideaki Kawai kayhide

View GitHub Profile
@kayhide
kayhide / gist:ff702ea46a6ffe058c1776a0201122d4
Created April 29, 2018 14:44
Crash report `accelerate-mandelbrot`
Process: accelerate-mandelbrot [51388]
Path: /Users/USER/*/accelerate-mandelbrot
Identifier: accelerate-mandelbrot
Version: 0
Code Type: X86-64 (Native)
Parent Process: zsh [45240]
Responsible: accelerate-mandelbrot [51388]
User ID: 501
Date/Time: 2018-04-29 23:23:46.143 +0900
@kayhide
kayhide / dump_sample_weight.py
Created February 13, 2017 12:08
Dump yaml from python pickle file
import pickle
import numpy
import yaml
network_file = 'sample_weight.pkl'
print("read: %(network_file)s" % locals())
with open(network_file, 'rb') as f:
network = pickle.load(f)
for key in network.keys():
import Control.Monad
import Control.Monad.State
type CounterState = State Int
fivesWithCounter :: CounterState [Int]
fivesWithCounter = do
modify (+1)
fives <- fivesWithCounter
i <- get
@kayhide
kayhide / setup_coq_for_spacemacs.sh
Last active September 27, 2016 02:27
mac で coq を spacemacs する。
#!/usr/bin/env sh
brew install coq proof-general
ghq get https://github.com/olivierverdier/spacemacs-coq
ln -s $(ghq root)/github.com/olivierverdier/spacemacs-coq ~/.emacs.d/private/coq
echo "Coq and Proof General are installed."
echo "Add `coq' to `dotspacemacs-configuration-layers'. "
@kayhide
kayhide / database_url.rb
Last active August 9, 2016 10:38
Generate database url with random username, pasword and dbname
$chars = [*(0..9).to_a, *('a'..'z').to_a, *('A'..'Z').to_a]
$lengths = {
username: 14,
password: 26,
db_name: 14
}
def random_chars length
length.times.map do
$chars.sample
@kayhide
kayhide / setup-ec2-for-middleman.sh
Created July 4, 2016 07:33
Setup script of AWS EC2 for Middleman
sudo yum install -y gcc gcc-c++ git ruby23 ruby23-devel httpd
sudo yum install -y nodejs --enablerepo=epel
sudo chkconfig httpd on
sudo service httpd start
sudo chown -R ec2-user:ec2-user /var/www/
sudo alternatives --set ruby /usr/bin/ruby2.3
gem install rake bundler --no-doc
@kayhide
kayhide / expires.conf
Last active August 16, 2016 14:03
Apache config for expires
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/png "access plus 1 months"
ExpiresByType image/jpeg "access plus 1 months"
ExpiresByType image/gif "access plus 1 months"
ExpiresByType text/css "access plus 1 months"
</IfModule>
@kayhide
kayhide / deflate.conf
Created July 4, 2016 07:28
Apache config for deflate
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|ico)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI _\.utxt$ no-gzip
@kayhide
kayhide / eb.rake
Last active February 3, 2017 21:21
Rails tasks to dump / import Postgres DB which is running on AWS Elastic Beanstalk
namespace :eb do
desc 'Dump sql data, through host from eb status or SSH_HOST'
task :dump do
unless host = ENV['SSH_HOST']
status = `eb status`
cname = status.lines.grep(/CNAME:/).first.gsub(/.*CNAME:/, '').strip
puts 'host: ' + cname.blue
ip = `host #{cname}`.gsub(/.*has address */, '').strip
puts 'ip: ' + ip.blue
user = 'ec2-user'
sudo yum install -y gcc gcc-c++ git ruby23 ruby23-devel httpd
sudo yum install -y nodejs --enablerepo=epel
sudo chkconfig httpd on
sudo service httpd start
sudo chown -R ec2-user:ec2-user /var/www/
sudo alternatives --set ruby /usr/bin/ruby2.3
gem install rake bundler --no-doc