Skip to content

Instantly share code, notes, and snippets.

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

Victor Wang GiaoGiaoCat

👀
正在複製你的代碼
  • China
View GitHub Profile
@GiaoGiaoCat
GiaoGiaoCat / style.plantuml
Last active June 4, 2019 13:54
PlantUML 样式
' defaults
' skinparam monochrome true
skinparam roundcorner 10
skinparam shadowing false
skinparam DefaultFontName Proxima Nova
skinparam ArrowColor #00b2e2
skinparam DefaultFontColor #454645
@GiaoGiaoCat
GiaoGiaoCat / style.plantuml
Created June 4, 2019 13:40
PlantUML 样式
' defaults
' skinparam monochrome true
skinparam roundcorner 20
skinparam shadowing false
skinparam DefaultFontName Proxima Nova
skinparam ArrowColor #00b2e2
skinparam DefaultFontColor #454645
@GiaoGiaoCat
GiaoGiaoCat / Gemfile
Created July 2, 2018 03:37
Public.Law
gem 'mysql2'
gem 'rails', '5.1.6'
gem 'dalli'
gem 'dig_bang'
gem 'jquery-rails'
gem 'kaminari'
gem 'law_string', github: 'public-law/law_string'
gem 'memery'
gem 'naturally'
@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"
## 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 / .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
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 / 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
@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 / 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