Skip to content

Instantly share code, notes, and snippets.

@tetsuyainfra
tetsuyainfra / gist:7976d723c42a0f56f31f
Last active August 29, 2015 14:00
ERB-TEMPLATEを便利に書くためのクラス
# ERB-TEMPLATEを便利に書くためのクラス
#
# 使い方
# module TEST_CONST
# extends TemplateGenerater
# TEST = "test_string-<%= id %>"
# end
#
# TEST_CONST::test(id: 1) #=> "test_string-1"
# TEST_CONST::test(id: 2) #=> "test_string-2"
@tetsuyainfra
tetsuyainfra / gist:85e25c4f44722bfb2e55
Created February 28, 2015 15:33
c++ 仮想関数呼び出しの影響回避方法 と 回避しなくてもええんじゃね? 覚え書き
// VSで確認するには C/C++ -> Assemby Outputの項目をAssembly-Only Listing (/FA)に設定
class base
{
public:
virtual fn() = 0;
};
Class A
{
public:
fn() override { something; }
@tetsuyainfra
tetsuyainfra / dlls.rb
Created December 10, 2015 12:42
Windows の Ruby が開いてる dll の一覧を見る@fiddle版
require "fiddle/import"
require 'fiddle/types'
# オリジナル(Win32APIライブラリを使う版)はこちら
# https://rubyist.g.hatena.ne.jp/edvakf/20110405/1301973681
module WIN32API
extend Fiddle::Importer
dlload 'C:\\Windows\\System32\\kernel32.dll'
include Fiddle::Win32Types
extern 'DWORD GetCurrentProcessId()'
@tetsuyainfra
tetsuyainfra / shitaraba_write_test.sh
Created December 29, 2015 07:21
したらば書き込みメモ
COMMAND=echo
#COMMAND=curl
echo MESSAGE=あいうえお&submit=書き込む | iconv -t euc-jp > data.message
$COMMAND -v -d 'DIR=game' -d 'BBS=12345' -d 'KEY=1234567890' \?
-d "TIME=$(date +%s)" -d 'NAME="" \
-d "MAIL=sage" -d @data.message \
-e http://jbbs.shitaraba.net/bbs/read.cgi/game/12345/1234567890/ \
http://jbbs.shitaraba.net/bbs/write.cgi/game/12345/1234567890/
@tetsuyainfra
tetsuyainfra / build_nginx.sh
Created March 7, 2016 05:03 — forked from Belphemur/build_nginx.sh
Compiling Nginx with LibreSSL (and http2) & RTMP module & PageSpeed (optional)
#!/usr/bin/env bash
# names of latest versions of each package
export NGINX_VERSION=1.9.12
export VERSION_PCRE=pcre-8.38
export VERSION_LIBRESSL=libressl-2.3.2
export VERSION_NGINX=nginx-$NGINX_VERSION
#export NPS_VERSION=1.9.32.10
#export VERSION_PAGESPEED=v${NPS_VERSION}-beta
@tetsuyainfra
tetsuyainfra / create-ssh-host-keys.service
Last active January 18, 2017 09:29
ssh_hosts_keyをチェックするsystemdサービス(修正4回目:外部シェルスクリプトにお願いする)
#########################
# debian jessie on vagrant/VM
# sudoedit /etc/systemd/system/create-ssh-host-keys.service
# CHECK:
# systemctl list-unit-files --type=service | grep create
# ENABLE:
# systemctl enable create-ssh-host-keys
# systemctl start create-ssh-host-keys
[Unit]
Description=Create SSH host keys
@tetsuyainfra
tetsuyainfra / gist:11283a86ef08adee0dbb1981beea7cc6
Created January 5, 2017 09:49
docker コンテナからファイルをコピーしてくるコマンドサンプル
docker run --rm -u $(id -u):$(id -g) -v $(pwd):/srv --entrypoint /bin/cp svendowideit/samba -r /usr/share/doc/samba/examples/LDAP /srv
@tetsuyainfra
tetsuyainfra / gist:dedf986e25a34f97a839b23c977414b1
Created January 5, 2017 09:55
apt-get&dpkg-deb でdebを解凍する
apt-get download samba
dpkg-deb -x samba*.deb extract_here
@tetsuyainfra
tetsuyainfra / gist:eec2781b8236bffd5e7258801a899234
Created February 12, 2017 05:46
rails serverのオプションを変更する方法 ※rails restartでも止まらない
#config/boot.rb
# ~
require 'rails/commands/server'
module DefaultOptions
def default_options
super.merge!(Host:'0.0.0.0', Port: 3000)
end
end
Rails::Server.send(:prepend, DefaultOptions)
@tetsuyainfra
tetsuyainfra / hello_react.js
Last active February 13, 2017 13:00
turbolinks + react bootstrapはたぶんこんなかんじ
// ページ読み込みが完了した時に実行
document.addEventListener("DOMContentLoaded", e => {
console.log('fired ->', e.type, e.timeStamp)
// turbolinksを有効にしている時
document.addEventListener('turbolinks:load', (evt)=>{
console.log('will render ->', evt.type, evt.timeStamp)
let elm = document.getElementById('padapp')
if (!elm) { return ; }