Skip to content

Instantly share code, notes, and snippets.

View windy's full-sized avatar
😃
Running ShowMeBug

yafei lee windy

😃
Running ShowMeBug
View GitHub Profile
@huobazi
huobazi / 1
Created July 22, 2011 04:22
添加 删除ubuntu自启动服务 init.d
1. 装个 sysv-conf-rc
2. sudo update-rc.d -f mysql remove 删除mysql随机器启动的服务
sudo update-rc.d -f apache2 remove 删除apache2随机器启动的服务
3. 查看/etc/rc2.d/里面的apache和mysql启动脚本,通常都是两个阿拉伯数字后再接一个英文字母,再加脚本名称。英文字母 是S的都是会自动启动的,K则相反。所以只要找到apache和mysql的启动脚本,把S改成K就可以了
@tonywok
tonywok / results.md
Created September 15, 2011 01:33
Rails 3.1 Callbacks
s = Test.new(:name => "foo")

# ActiveRecord::Test after_initialize
# ActiveRecord::Test after_initialize, :on => :update
# ActiveRecord::Test after_initialize, :on => :create
# ActiveRecord::TestObserver after_initialize

# ===> #<Test id: nil, name: "foo", created_at: nil, updated_at: nil>
@happypeter
happypeter / mac_fuck_gfw.sh
Last active July 3, 2016 06:03
FUCK GWF apple script
#!/user/bin/env bash
on_die() {
echo
echo byebye proxy
echo
networksetup -setsocksfirewallproxystate "Ethernet 2" off #close the proxy
# the name can be "wifi" or "Ethernet 1", just see what is listed in "network preference"
}
@mbleigh
mbleigh / matchers.rb
Created September 7, 2012 16:53
RSpec matcher for JSON responses.
RSpec::Matchers.define :have_json_key do |expected_key|
match do |response|
@body = MultiJson.load(response.body)
result = @body.key?(expected_key.to_s)
result &&= @body[expected_key.to_s] == @expected_val if @val_provided
result
end
chain :with_value do |val|
@mikluko
mikluko / gist:3897117
Created October 16, 2012 03:37
Basic monit config to monitor CPU, memory and disk usage
set daemon 30 with start delay 60
set logfile syslog facility log_daemon
set httpd port 2812
allow localhost
set mailserver localhost
set alert alert@example.com but not on { instance }
mail-format {
From: noreply@example.com
@ascendbruce
ascendbruce / gist:7558475
Created November 20, 2013 06:03
用 request-log-analyzer 分析 rails 的 log

先安裝 request-log-analyzer gem,建議把 log 檔抓到自己電腦來做分析。

gem i request-log-analyzer

分析某一個 log 檔

request-log-analyzer log/production.log --output HTML --file tmp/log_report.html

指定多個 log 檔

class Ticket < ActiveRecord::Base
belongs_to :grouper
belongs_to :user
validate :user_cant_be_blacklisted, on: :confirmation
validate :user_cant_double_book, on: :confirmation
validate :grouper_cant_be_full, on: :confirmation
validate :grouper_cant_have_occurred, on: :confirmation
@ROFISH
ROFISH / Gemfile
Last active August 29, 2015 14:00
#ruby '2.1.0'
source 'https://rubygems.org'
gem 'rack', '~>1.5.2'
gem 'actionpack', '~> 4.1.0.beta1'
gem 'railties', '~> 4.1.0.beta1'
@shannonwells
shannonwells / socksify_faraday.rb
Last active May 7, 2021 20:52
Faraday + SOCKS
require 'rubygems'
require 'faraday'
require 'socksify'
require 'socksify/http'
require 'awesome_print'
# This is a SOCKS monkey patch for Faraday, with example use/unit test.
# Notes:
# * It is altered to work with SOCKS5 authentication.
# * net_http_class must return a Faraday::Adapter::NetHttp instance.
@windy
windy / forum_markdown.rb
Last active September 20, 2022 03:16
如何单独使用 Rails 的路由系统
# test for Rails 4.1.9
# file: app/models/forum_markdown.rb
class ForumMarkdown
class DummyController
def logger
RAILS_DEFAULT_LOGGER
end
def headers