Skip to content

Instantly share code, notes, and snippets.

View shaojunda's full-sized avatar
🏠
Working from home

shaojunda shaojunda

🏠
Working from home
  • Cryptape
  • HangZhou
View GitHub Profile
@tinogomes
tinogomes / pre-commit-complete
Last active March 24, 2021 13:59
Git Hook pre-commit to pass Rubocop and Brakeman on Rails application for validations
#!/bin/sh
#
# Check for ruby style errors
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
NC='\033[0m'
if git rev-parse --verify HEAD >/dev/null 2>&1
@ryerh
ryerh / tmux-cheatsheet.markdown
Last active April 7, 2025 01:38 — forked from MohamedAlaa/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表 & 简明教程

注意:本文内容适用于 Tmux 2.3 及以上的版本,但是绝大部分的特性低版本也都适用,鼠标支持、VI 模式、插件管理在低版本可能会与本文不兼容。

Tmux 快捷键 & 速查表 & 简明教程

启动新会话:

tmux [new -s 会话名 -n 窗口名]

恢复会话:

@jason5ng32
jason5ng32 / surge.conf
Last active November 6, 2024 06:39
Surge Configs ( for 2.x )
[General]
loglevel = notify
skip-proxy = 127.0.0.1, 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, 100.64.0.0/10, localhost, *.local, ::ffff:0:0:0:0/1, ::ffff:128:0:0:0/1
bypass-tun = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12
# dns-server = 119.29.29.29,223.5.5.5,114.114.115.115
# external-controller-access = [email protected]:6155
# ipv6 = true
// REMEMBER TO CHANGE THE external-controller-access' PASSWORD
@mlanett
mlanett / rails http status codes
Last active February 3, 2025 11:36
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@romansklenar
romansklenar / crosstab.sql
Last active February 1, 2023 18:46
PostgreSQL "pivot table" example using tablefunc extension
CREATE EXTENSION tablefunc;
CREATE TABLE sales(year int, month int, qty int);
INSERT INTO sales VALUES(2007, 1, 1000);
INSERT INTO sales VALUES(2007, 2, 1500);
INSERT INTO sales VALUES(2007, 7, 500);
INSERT INTO sales VALUES(2007, 11, 1500);
INSERT INTO sales VALUES(2007, 12, 2000);
INSERT INTO sales VALUES(2008, 1, 1000);
INSERT INTO sales VALUES(2009, 5, 2500);
@wrburgess
wrburgess / gist:2439800
Created April 21, 2012 21:42
CodeSchool - Rails Testing for Zombies Notes #test #testunit #rails

CodeSchool Rails Testing for Zombies Notes

Test::Unit Assertions

assert_respond_to [object], :[method] #does object method exist? ex. assert_respond_to "string", :lowercase
assert_equal [string, [method] #is first string equal to results of second method?
assert_match [regex], [method] #is first regex equal to second string?
assert_nil
assert_not_nil [method] #is method nil?  

assert_raise(RuntimeError), [method]

@lbj96347
lbj96347 / JS-Regular.html
Created February 1, 2012 06:06
JS正则提取字符串/中文/英文/数字
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>javaScript正则表达式提取字符串中字母、数字、中文</title>
</head>
<body>
<input type="text" id="oText" value="李秉骏的常用代号是96347,英文名字是CashLee噢" size=100><br/>
<input type="button" value="number" onclick="get_character_you_want(this);">
@ryansch
ryansch / hooks_controller.rb
Created September 28, 2010 15:03
Rails Controller for Chargify Webhooks
require 'md5'
class Chargify::HooksController < ApplicationController
protect_from_forgery :except => :dispatch
before_filter :verify, :only => :dispatch
EVENTS = %w[ test signup_success signup_failure renewal_success renewal_failure payment_success payment_failure billing_date_change subscription_state_change subscription_product_change ].freeze
def dispatch
event = params[:event]