Skip to content

Instantly share code, notes, and snippets.

yum update -y
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel openssl-devel make bzip2 autoconf automake libtool bison git
MY_GROUP="rbenv"
if [ "$MY_GROUP" = "" ] ; then
echo '!!! undefined variable MY_GROUP.'
echo '!!!'
echo '!!! ex.) MY_GROUP=staff'
echo '!!!'
exit 1
@shim0mura
shim0mura / aws_switcher.sh
Last active January 3, 2016 23:19
awsのインスタンスをONにしたりOFFにしたりする奴、stopするとElasticIPが外されちゃうのでstartするときにassociateもする 事前にaws-cliのインストール(sudo pip install awscli)とjqコマンドのパス内への設置、 アクセスキーなどの取得(https://portal.aws.amazon.com/gp/aws/securityCredentials)とElasticIP取得が必要
#!/bin/bash
INSTANCE_ID=xxxxx
ELASTIC_IP=xxxxx
RUNNING_STATUS=1
NOT_RUNNING_STATUS=0
function is_not_instance_running() {
status=$(aws ec2 describe-instance-status --instance-ids $INSTANCE_ID | ~/jq '.InstanceStatuses[].InstanceState.Name')
if [ "${status}" = '"running"' ]; then
@shim0mura
shim0mura / templ.sh
Created September 6, 2013 07:24
jpmobile使った時にfp用とsp用のテンプレートを作成するやつ
#!/bin/bash
EX=".html.erb"
SP="_smart_phone"
FP="_mobile"
for dir in `ls`; do
if [ -d $dir ]; then
for file in `ls $dir`; do
if [ `echo $file | egrep '\.html\.erb$'` ]; then
@shim0mura
shim0mura / gist:5141609
Last active December 14, 2015 20:08
バージョン違いで重複したrpmパッケージを削除するスクリプト バージョンが新しいものを残す。バージョン同じならビルド日時が新しいものを残す
#!/bin/sh
OLD_PACKAGES=removed/
IS_UPDATE=1
replace_package(){
mv $1 $ORIG_PACKAGES
mv $2 $OLD_PACKAGES
IS_UPDATE=0
}
@shim0mura
shim0mura / create_new_form_helper.rb
Created December 4, 2012 05:46
FormHelperとFormBuilderを拡張してForm部品を自作する
#coding: utf-8
module ActionView
module Helpers
module FormHelper
def text_field_tag_for_date(object_name, method, options ={})
# インスタンスの取得
object = options[:object]
original_value = object.send(method)
@shim0mura
shim0mura / ab.rb
Created August 2, 2012 09:16
7巻はよ
# -*- coding: utf-8 -*-
# ncursesw(とその後にruby入れ直し)が必要
# sudo apt-get install libncursesw5-dev
require "curses"
include Curses
def set_red
init_pair 1, COLOR_RED, COLOR_BLACK
@shim0mura
shim0mura / caesar.rb
Created May 19, 2012 09:25
rubyでシーザー暗号解読
#http://vipprog.net/wiki/exercise.html#h54a0395
class Caesar
def initialize(str, hint)
@key = nil
@str = str
@base = "abcdefghijklmnopqrstuvwxyz .,-"
@hint = hint
end
@shim0mura
shim0mura / gist:2657255
Created May 11, 2012 03:07
rubyでhit&blowゲーム
#!/usr/bin/env ruby
class Hit
def initialize
loop do
generate_answer
valid_answer? && break
end
puts "game start\n"
end
@shim0mura
shim0mura / app.js
Created December 26, 2011 17:56
node.jsでhello world
var express = require("express"),
app = express.createServer(),
port = process.env.PORT || 3000;
app.configure(function(){
app.use(app.router);
});
app.get("/", function(req, res){
function append(arg){
if(typeof arg === "string"){
this.innerHTML = arg;
}else{
var df = document.createDocumentFragment();
for(var i=0, l=arguments.length; i<l; i++){
if(arguments[i].nodeType == 1){
alert(111);
df.appendChild(arguments[i]);
}