Skip to content

Instantly share code, notes, and snippets.

View mimosa's full-sized avatar
🏔️

Howl王 mimosa

🏔️
View GitHub Profile
@mimosa
mimosa / bench.rb
Last active May 28, 2018 03:12
roar vs ams vs rabl vs jbuilder
require 'bundler'
require 'active_model_serializers'
require 'roar/decorator'
require 'roar/json'
require 'rabl'
require 'jbuilder'
require 'benchmark'
require 'ffaker'
Post = Struct.new(:id, :author, :body, :draft) do
@mimosa
mimosa / REDME.md
Created January 12, 2017 00:06
How to connect Docker to CoreOS in Veertu

How to connect Docker to CoreOS in Veertu

Why CoreOS?

CoreOS has become the preferred distro for Docker. You can download the [Stable ISO]

Why Veertu?

Like xhyve, Veertu takes advantage of the Hypervisor.framework that was introduced in OS X 10.10, which brings Type 1 hypervisor technology (direct, host-level access to hardware) to OS X. You can download it in the [CloudFront]

  1. Start the CoreOS image.
    • Set a password for user core
@mimosa
mimosa / msg_pack.rb
Last active December 16, 2016 06:53
MessagePack
# -*- encoding: utf-8 -*-
require 'msgpack' unless defined?(::MessagePack)
require 'bigdecimal' unless defined?(::BigDecimal)
require 'time' unless Time.respond_to?(:parse)
class BigDecimal
def to_msgpack_ext
[to_s].pack('A*')
end
@mimosa
mimosa / bilibili_api.lua
Last active October 5, 2018 12:23
B站 api key 规则,每3小时轮换一个 :(
function string.fh(str)
return (str:gsub('..', function (cc)
return string.char(tonumber(cc, 16))
end))
end
function sort_nums()
return ("6337393836663535306539363566613865616264646435653033363665356466"):fh()
end
bit = require('bit')
@mimosa
mimosa / .macos
Created September 15, 2016 14:12
#!/usr/bin/env bash
#
# by Benjamin Crozat <benjamin@croz.at>
# https://benjamincrozat.com
#
# Inspired by Mathias Bynens' .macos file.
# https://github.com/mathiasbynens/dotfiles/blob/master/.macos
#
# Not entirely tested yet. Does not fully work on macOS Sierra
@mimosa
mimosa / README.md
Last active September 9, 2016 09:26
快递跟踪
tracer = Kuaidi100.new
a = tracer.trace('1202306458234')
# =>
{
  :status          => true, 
  :shipping_method => "韵达", 
  :tracking_no     => "1202306458234", 
  :routes          => [{
    :time    => "2016-09-09 15:41:22", 
@mimosa
mimosa / README.md
Created June 27, 2016 04:17
微信扫码登录。
  1. 判定是否在微信中打开
def wechat?
    request.user_agent =~ /MicroMessenger/i 
end
  1. 分别调用 微信网页扫码公众号授权
# -*- encoding: utf-8 -*-
require 'openssl'
require 'base64'
# 生成一对秘钥
# rsa = OpenSSL::PKey::RSA.generate( 2048 )
# public_rsa = rsa.public_key.to_pem
# private_rsa = rsa.to_pem
Anonymous UUID: E5A9B508-AE47-7CA0-08FC-150B18AB4EE8
Wed Mar 23 15:33:42 2016
*** Panic Report ***
panic(cpu 4 caller 0xffffff80003ce40a): Kernel trap at 0xffffff8000383d32, type 14=page fault, registers:
CR0: 0x000000008001003b, CR2: 0xffffffa00b08f7c8, CR3: 0x00000002607d80f6, CR4: 0x00000000001627e0
RAX: 0xffffff8000aecfb0, RBX: 0x0000000000000075, RCX: 0xffffff8000aec860, RDX: 0xffffffa00b08f7c0
RSP: 0xffffff91f060bcf0, RBP: 0xffffff91f060bd00, RSI: 0xffffff800b0917c0, RDI: 0x0000000000000075
R8: 0x000000000000018b, R9: 0xffffff800b097780, R10: 0x0000000000000000, R11: 0x0000000000000246
# -*- encoding: utf-8 -*-
require 'typhoeus'
def hydra(concurrency=5)
@hydra ||= Typhoeus::Hydra.new(max_concurrency: concurrency)
end
def download(urls, concurrency=5)
urls.each_with_index do |url, idx|
request = Typhoeus::Request.new(url)