Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Victor Wang wjp2013

🎯
Focusing
Block or report user

Report or block wjp2013

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@wjp2013
wjp2013 / style.plantuml
Last active Jun 4, 2019
PlantUML 样式
View style.plantuml
' defaults
' skinparam monochrome true
skinparam roundcorner 10
skinparam shadowing false
skinparam DefaultFontName Proxima Nova
skinparam ArrowColor #00b2e2
skinparam DefaultFontColor #454645
View style.plantuml
' defaults
' skinparam monochrome true
skinparam roundcorner 20
skinparam shadowing false
skinparam DefaultFontName Proxima Nova
skinparam ArrowColor #00b2e2
skinparam DefaultFontColor #454645
View Gemfile
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'
@wjp2013
wjp2013 / Brewfile
Last active Jan 5, 2018
个人开发环境
View Brewfile
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"
View gist:eb119ae11b0d5f80d626c2bd51549dc9
## 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"; }
@wjp2013
wjp2013 / .sh
Created Sep 28, 2016
批量转换文件编码
View .sh
#!/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
View images_controller.rb
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)
@wjp2013
wjp2013 / get_in.rb
Last active Jun 12, 2016
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.
View get_in.rb
# 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
@wjp2013
wjp2013 / wechat-useragent.js
Created Mar 6, 2015
微信内置浏览器UserAgent的判断
View wechat-useragent.js
// 检测浏览器的 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(){
@wjp2013
wjp2013 / 0_reuse_code.js
Last active Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
You can’t perform that action at this time.