Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
#
# ip_conntrack: Plugin to monitor the number of tracked connection
if [ "$1" = "config" ]; then
echo "graph_title Number of tracked connections"
echo "graph_args --base 1000"
echo "graph_vlabel connections"
echo "graph_category network"
echo "connection.label connections"
#!/bin/bash
if [ x"" == x"$1" ]; then
echo "Usage: $0 PROJECT_NAME"
exit
fi
rails $1
cd $1
for d in $(find -type d -empty); do touch $d/.git_placeholder; done
(function(){
cnt=prompt("へぇの数");
CookieHeCnt=(int)(cnt)-1;
HeClick();
})();
@mitsuru
mitsuru / 3gokushi-beyond.user.js
Created March 5, 2011 09:22
ブラ三beyond 非公式修正版
// ==UserScript==
// @name 3gokushi-Beyond
// @namespace 3gokushi-hatt
// @description ブラウザ三国志用便利機能色々ごった煮 by hatt+ろむ+α
// @include http://*.3gokushi.jp/*
// @author hatt,romer,etc...
// @version 1.27.2.6
// ==/UserScript==
//
// FireFox / Google Chrome対応です。
// ==UserScript==
// @name bro3_auto_phantom
// @version 0.1
// @description enter something useful
// @match http://m17.3gokushi.jp/card/event_battle_top.php?scope=4*
// @match http://m17.3gokushi.jp/card/event_battle_result.php*
// @match http://m17.3gokushi.jp/card/event_battle_attack.php*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
// @copyright 2012+, You
// ==/UserScript==
try {
// $pdo は接続オブジェクト
$pdo = new PDO("mysql:host=localhost; dbname=pdotest",
"root", "pass");
$stmt = $pdo->query("SELECT * FROM CD");
while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
echo implode(", ", $row) . PHP_EOL;
}
} catch (PDOException $e){
@mitsuru
mitsuru / gist:386c974c934026faa57b
Last active August 29, 2015 14:23
paper_trailでCarrierWaveのフィールドのファイル名のみを保存する
module PaperTrail
module Model
module InstanceMethods
private
def item_before_change
attributes.tap do |prev|
enums = self.respond_to?(:defined_enums) ? self.defined_enums : {}
changed_attributes.select { |k,v| self.class.column_names.include?(k) }.each do |attr, before|
before = enums[attr][before] if enums[attr]
if defined?(CarrierWave::Uploader::Base) && before.is_a?(CarrierWave::Uploader::Base)
module Devise
module Encryptable
module Encryptors
class MessageEncryptor < Base
class << self
def digest(password, stretches, salt, papper)
encryptor = ::ActiveSupport::MessageEncryptor.new(papper)
encryptor.encrypt_and_sign(password)
end
alias :encrypt :digest
@mitsuru
mitsuru / aasmviz_controller.rb
Created November 23, 2017 06:54
Visualize aasm state diagram
class AasmvizController < ApplicationController
before_action :authenticate_account!
before_action :require_admin!
def index
Rails.application.eager_load!
@models = ActiveRecord::Base.descendants.select { |c| c.respond_to? :aasm }
end
def show