This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 检测浏览器的 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(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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"; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
OlderNewer