Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View masuidrive's full-sized avatar

Yuichiro MASUI masuidrive

View GitHub Profile
@masuidrive
masuidrive / gist:ae2a00080f377fb50577
Last active August 29, 2015 14:03
toreta-webdev

トレタ Web テンプレート

目的

  • 多くのデバイスで正しく見えるページを提供する
  • 誰でもメンテナンスできるコードを提供する
  • ヘッダやフッタなどの共通部品は1カ所にまとめる
  • 静的なファイルとしてアップロードが可能
  • ページ読み込み速度の軽減
  • 変更履歴を管理
  • ステージング環境の構築
@masuidrive
masuidrive / 000_Install.md
Last active August 29, 2015 14:03
Google認証用のRails project template

Install

mkdir foo
cd foo

curl -o "Vagrantfile" "https://gist.githubusercontent.com/masuidrive/20049711692b5f5885c8/raw/171c5027732476f433b6cb97963382e3896fada0/Vagrantfile"
vagrant up && vagrant ssh
# 以下、vagrant内
cd /vagrant
@masuidrive
masuidrive / .git_hooks_pre-push
Created December 24, 2014 07:23
developへpushする場合には警告するスクリプト
#!/bin/bash
protected_branch='develop'
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
if [ $protected_branch = $current_branch ]
then
read -p "You're about to push $protected_branch, is that what you intended? [y/N] " -n 1 -r < /dev/tty
echo
if echo $REPLY | grep -E '^[Yy]$' > /dev/null
/*
http://la.ma.la/blog/diary_200601201204.htm
*/
if(location.search=="?autoreload") {
var __autoreload_last_contents = new Array();
setInterval(function(){
var check = function(path) {
var onload = function() {
(__autoreload_last_contents[path] && req.responseText != __autoreload_last_contents[path]) && location.reload(true);
#!/usr/bin/env ruby
require 'rubygems'
require 'eventmachine'
module Log2IRC
include EventMachine::Protocols::LineText2
attr_reader :channels
class Message
attr_reader :line, :pattern, :match
# Rails on GitHub
export APP=hogehoge
mkdir $APP
cd $APP
git init
rails $APP
git add log tmp
touch tmp/.gitignore log/.gitignore
echo "log/*.log" > .gitignore
require 'kconv'
require 'iconv'
require 'nkf'
require 'test/unit'
class GuessEncoding < Test::Unit::TestCase
def setup
@euc = "うまく表示してね!".kconv(Kconv::EUC, Kconv::SJIS)
end
require 'kconv'
require 'iconv'
require 'nkf'
require 'test/unit'
class GuessEncoding < Test::Unit::TestCase
def setup
# EUC-JP encoded うまく表示してね!
@euc = "¥345¥341¥254¥345¥242¥300¥345¥341¥276¥352¥241¥243¥245¥243¥356¥246¥245¥263¥345¥341¥316¥345¥242¥250¥345¥341¥245¥345¥376¥276"
end
#!/bin/sh
# /etc/pm/sleep.d/00zbright
COMMAND=/usr/local/bin/zbright
SAVED_FILE=/tmp/zbright.tmp
case "${1}" in
suspend|hibernate)
$COMMAND | /usr/bin/gawk '{print $2}' > $SAVED_FILE
;;
#!/usr/bin/env bash
#
# syntax:
# 'sudo zbright +N' increments screen brightness by N percent (N=0-100)
# 'sudo zbright -N' decrements screen brightness by N percent
# 'sudo zbright N' sets screen brightness to N percent
# 'sudo zbright' w/o any args reports current brightness
#
# note: must be run as sudo
#