Skip to content

Instantly share code, notes, and snippets.

View mechiland's full-sized avatar
🧘
What's Next?

Michael Chen mechiland

🧘
What's Next?
  • Hipacloud
View GitHub Profile
@mechiland
mechiland / delete_weibo.js
Created February 22, 2018 02:20
Delete Weibo
// ==UserScript==
// @name Delete Weibo
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://weibo.cn/<Your WeiboID>/profile
// @grant none
// ==/UserScript==
@mechiland
mechiland / Vagrantfile
Created August 3, 2016 09:44
Rails Devbox Setup
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.provision :shell, path: 'bootstrap.sh', keep_color: true
config.vm.network "private_network", type: "dhcp"
config.vm.synced_folder ".", "/vagrant", type: "nfs"
config.vm.hostname = 'rails-dev-box'
prefix = %w(31 32 33 34 35 36 37 38 39 51 52 53 55 56 57 58 59 70 71 72 73 75 77 80 81 82 83 85 86 87 88 89)
(1..100).each do |n|
puts "1#{prefix.sample}#{rand(10**8)}"
end
@mechiland
mechiland / JinshujuHandler.ashx
Created March 27, 2014 05:36
Jinshuju API Push for C#
<%@ WebHandler Language="C#" Class="JinshujuHandler" %>
using System;
using System.Web;
using System.Text;
using System.IO;
using Newtonsoft.Json.Linq;//引用第三方控件Newtonsoft.Json.dll
/*
*Company:QingDao Transinfo
*Author: Andy.Sun
@mechiland
mechiland / create_milestone.rb
Created December 2, 2013 08:55
create github milestones
require 'octokit'
require 'date'
milestones = [
"70: JUL29"
]
start = 92
range = (Date.parse('2014-01-01')...Date.parse('2014-3-31'))
name = "#{start}: "
@mechiland
mechiland / jinshuju.rb
Created June 27, 2013 07:20
Sinatra listening Jinshuju
require 'sinatra'
require "sinatra/streaming"
set connections: [], loggin: true, bind: '0.0.0.0'
get '/stream', provides: 'text/event-stream' do
stream :keep_open do |out|
settings.connections << out
out.callback { settings.connections.delete(out) }
end
@mechiland
mechiland / gist:5269281
Last active December 15, 2015 13:39
Mobile Web Notes
http://html5boilerplate.com/mobile/
http://zeptojs.com/
中文:
http://www.adobe.com/cn/devnet/html5/articles/flame-on-a-beginners-guide-to-emberjs.html
http://www.w3school.com.cn/html5/html_5_webstorage.asp
中文: http://emberjs.cn
http://emberjs.com/
@mechiland
mechiland / gist:5055089
Created February 28, 2013 08:09
nginx allow crawler to visit website
map $http_user_agent $is_bot {
default 0;
~*(crawl|Googlebot|Slurp|spider|bingbot|yodaobot|youdaobot)$ 1;
}
set $should_redirect 1;
if ($is_bot) {
set $should_redirect 0;
}
@mechiland
mechiland / homework.md
Created April 6, 2012 12:54
Software Development: the new horizons - Home Work
@mechiland
mechiland / gist:2005577
Created March 9, 2012 07:54
Extract email reply
# http://stackoverflow.com/questions/824205/while-processing-an-email-reply-how-can-i-ignore-any-email-client-specifics-th
def find_reply(email)
message_id = email.message_id('')
x_mailer = email.header_string('x-mailer')
# For optimization, this list could be sorted from most popular to least popular email client/service
rules = [
[ 'Gmail', lambda { message_id =~ /.+gmail\.com>\z/}, /^.*#{FROM_NAME}\s+<#{FROM_ADDRESS}>\s*wrote:.*$/ ],
[ 'Yahoo! Mail', lambda { message_id =~ /.+yahoo\.com>\z/}, /^_+\nFrom: #{FROM_NAME} <#{FROM_ADDRESS}>$/ ],