Skip to content

Instantly share code, notes, and snippets.

View GiaoGiaoCat's full-sized avatar
👀
正在複製你的代碼

Victor Wang GiaoGiaoCat

👀
正在複製你的代碼
  • China
View GitHub Profile
@GiaoGiaoCat
GiaoGiaoCat / gist:1393770
Created November 25, 2011 15:24
Steps to install RVM + Ruby 1.9.2 + Rails + nginx + Passenger on CentOS (tested on v5.5)
# Steps to install RVM + Ruby 1.9.2 + Rails + nginx + Passenger on CentOS (tested on v5.5)
# Install git and curl, if not already installed
sudo yum install git
sudo yum install curl
# Create the rvm group and add any users who will be using rvm to the group
sudo su -
groupadd rvm
@GiaoGiaoCat
GiaoGiaoCat / deploy.rb
Created February 20, 2014 06:02 — forked from stas/deploy.rb
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
# require 'mina/rvm' # for rvm support. (http://rvm.io)
# Basic settings:
# domain - The hostname to SSH to.
# deploy_to - Path to deploy into.
# repository - Git repo to clone from. (needed by mina/git)
@GiaoGiaoCat
GiaoGiaoCat / gist:5669857fdfa5ed7d25ca
Last active August 29, 2015 14:06
阅读笔趣阁的小说
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'pry'
class Reader
BASE_URL = 'http://www.biquge.la/book/546/'
LINE_SHOULD_BREAK = 10
@@count = 0
@GiaoGiaoCat
GiaoGiaoCat / 0_reuse_code.js
Last active August 29, 2015 14:13
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@GiaoGiaoCat
GiaoGiaoCat / wechat-useragent.js
Created March 6, 2015 03:59
微信内置浏览器UserAgent的判断
// 检测浏览器的 User Agent 应该是非常简单的事情
// 微信在 Android 下的 User Agent
mozilla/5.0 (linux; u; android 4.1.2; zh-cn; mi-one plus build/jzo54k) applewebkit/534.30 (khtml, like gecko) version/4.0 mobile safari/534.30 micromessenger/5.0.1.352
// 微信在 iPhone 下的 User Agent
mozilla/5.0 (iphone; cpu iphone os 5_1_1 like mac os x) applewebkit/534.46 (khtml, like gecko) mobile/9b206 micromessenger/5.0
// 通过javascript判断
// 很容易看出来,微信的 User Agent 都有‘micromessenger’字符串标示,我们判断是否含有这些字符串就OK了
function isWeixinBrowser(){
@GiaoGiaoCat
GiaoGiaoCat / get_in.rb
Last active June 12, 2016 06:32
Returns the value in a nested associative structure, where ks is a sequence of keys. Returns nil if the key is not present, or the not-found value if supplied.
# https://www.conj.io/store/v1/org.clojure/clojure/1.8.0/clj/clojure.core/get-in
module CoreExtensions
module GetIN
def get_in(enum, default = nil)
enum.inject(self) do |mem, var|
case var
when Fixnum then mem = mem.at(var)
when Symbol, String then mem = mem.fetch(var, default)
end
mem
class ImagesController < ApplicationController
before_action :load_parent_resource
include RestfulResources
restful_resources resource_name: :image
private
def load_resources
@images = resource_scope.all.group_by(&:kind)
@GiaoGiaoCat
GiaoGiaoCat / .sh
Created September 28, 2016 06:18
批量转换文件编码
#!/bin/bash
DIR=$1 # 转换编码文件目录
FT=$2 # 需要转换的文件类型(扩展名)
SE=$3 # 原始编码
DE=$4 # 目标编码
for file in `find $DIR -type f -name *.$FT`; do
echo "conversion $file encoding $SE to $DE"
iconv -f $SE -t $DE "$file" > "$file".tmp
## rewrite spider
if ($http_user_agent ~* (baiduspider|googlebot|Googlebot|soso|bing|sogou|yahoo|sohu-search|yodao|YoudaoBot|robozilla|msnbot)) {
rewrite ^/(.*)$ https://www.baidu.com permanent;
}
## rewrite mobile
location /{
set $mob 'y';
if ($http_user_agent ~* "(Android|iPhone|Windows Phone)"){ set $mob "${mob}e"; }
@GiaoGiaoCat
GiaoGiaoCat / Brewfile
Last active January 5, 2018 06:00
个人开发环境
cask_args appdir: "/Applications"
tap "codeclimate/formulae"
tap "homebrew/completions"
tap "homebrew/core"
tap "homebrew/bundle"
tap "homebrew/services"
tap "caskroom/fonts"
tap "caskroom/versions"
tap "caskroom/cask"