This file contains hidden or 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
git clone https://github.com/grpc/grpc-go.git $GOPATH/src/google.golang.org/grpc | |
git clone https://github.com/golang/net.git $GOPATH/src/golang.org/x/net | |
git clone https://github.com/golang/text.git $GOPATH/src/golang.org/x/text | |
go get -u github.com/golang/protobuf/{proto,protoc-gen-go} | |
git clone https://github.com/google/go-genproto.git $GOPATH/src/google.golang.org/genproto | |
--------------------- |
This file contains hidden or 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
.SUFFIXES: .erl .beam | |
.erl .beam: | |
erlc -W $< | |
ERL = erl -boot start_clean | |
MODS = module1 module2 module3 | |
all: compile |
This file contains hidden or 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
# regexps to check if a string is pure chinese | |
class String | |
# 20k chars | |
CHINESE_UCS2 = /^(?: | |
[\x4e-\x9e][\x00-\xff] | |
|\x9f[\x00-\xa5] | |
)+$/xn | |
# 20k chars | |
CHINESE_UTF8 = /^(?: |
This file contains hidden or 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
def rand_find(num=1, &p) | |
scope = p.call | |
items = [] | |
rand_numbers = (0...scope.count).to_a | |
num.times do | |
break if rand_numbers.size == 0 | |
rand_number = rand_numbers.delete_at(rand rand_numbers.size) | |
items << scope[rand_number] | |
end |
This file contains hidden or 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
$(document).ready(function(){ | |
var Validator = { | |
submit_fields: [], | |
errors: [], | |
nameTitleMapper: { | |
'contest[title]': '比赛标题', | |
'contest[description]': '比赛描述', | |
'contest[category_names][]': '比赛类别', |
This file contains hidden or 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 UploadBase64Image < Dun::Activity | |
data_reader :file_data, :as, :file_name | |
set :server_address, 'http://xx.xx.xx.xx' | |
set :client, RestClient | |
def initialize(data) | |
super | |
default :as, 'image' | |
default :file_name, SecureRandom.urlsafe_base64 |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
# entities的数据结构, [{name: name, image: <File:image>}, ...] | |
class CreateEntitySet < Dun::Activity | |
data_reader :entities, :contest | |
def call | |
entities.map {|e| | |
entity = Entity.new | |
entity.sn = SecureRandom.uuid |
This file contains hidden or 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 Avatar < ActiveRecord::Base | |
attr_accessor :content_type, :original_filename, :image_data | |
before_save :decode_base64_image | |
has_attached_file :image, | |
PAPERCLIP_CONFIG.merge( | |
:styles => { | |
:thumb => '32x32#', | |
:medium => '64x64#', |
This file contains hidden or 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 'dig' | |
# Dig.set :host, 'localhost:3000' | |
# Dig.set :host, 'fchk.dev' | |
namespace :api do | |
task :get_user_bio => :environment do | |
res = Dig.get 'getUserBio', user_sn: 'ddd' | |
puts res |
This file contains hidden or 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/ruby1.9 | |
require 'fiber' | |
require 'benchmark' | |
class Ring | |
attr_reader :id | |
attr_accessor :attach | |
def initialize(id) |
NewerOlder