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
@hollodotme
hollodotme / Install-nginx-with-http2-support.md
Created April 9, 2016 17:07
Install nginx with http2 support on ubuntu 14.04 LTS (Trusty)

How to install nginx (>= 1.9.5) with http2 support on Ubuntu 14.04 LTS (Trusty)

IMPORTANT: Backup your nginx site configs (usually under /etc/nginx/sites-available)!

Remove old nginx

Remove old nginx incl. nginx-common:

apt-get autoremove --purge nginx nginx-common
@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
@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.
@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'
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
@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 檔

@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
@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|
@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"
}
@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>