Skip to content

Instantly share code, notes, and snippets.

View martinx's full-sized avatar

Martin Xu martinx

View GitHub Profile
# lib/tasks/deploy.rake
namespace :deploy do
desc 'Deploy to staging environment'
task :staging do
exec 'mina deploy -f config/deploy/staging.rb'
end
end
#!/usr/bin/env ruby
require "openssl"
class BF < Struct.new(:key, :pad_with_spaces)
def encrypt(str)
cipher = OpenSSL::Cipher.new('bf-ecb').encrypt
if pad_with_spaces
str += " " until str.bytesize % 8 == 0
cipher.padding = 0
@martinx
martinx / test_markdown.md
Created March 11, 2014 08:33
markdown test

名称 | 类型| 是否必须| 说明| 默认值

  •  |   -          | -   | -       | -
    

method| String| 否| API接口名称| 无

** 目前仅支持 MacOS ##

打开终端程序, 复制、粘贴、执行以下句子:

curl -s -I https://www.atom.io/api/updates/download --header 'User-Agent: Atom/0.1 CFNetwork/1.5'|grep '^Location:'| sed -e 's+^.*\(https://.*\)$+\1+g'

稍等片刻,会输出类似下面的一行内容:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<title>Float Label Pattern</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<style type="text/css" media="screen">
.row {
/*position: relative;*/
padding-top: 24px;
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with the same name as the keys in <tt>filtering_params</tt>
# with their associated values. Most useful for calling named scopes from
2013-05-22 11:12:42 audio_filename:a/7/ywpqjh7l.audio
2013-05-22 11:12:42 uploading file:/w/apsqwezpre/www/a/7/ywpqjh7l.audio
W, [2013-05-22T11:12:42.775132 #25685] WARN -- : HTTP status code 612 => Utils.http_request('http://rs.qbox.me/stat/YXBzMjphLzcveXdwcWpoN2wuYXVkaW8=')
2013-05-22 11:12:42 false
2013-05-22 11:12:42 gen token
2013-05-22 11:12:42 uploading
W, [2013-05-22T11:13:43.390193 #25685] WARN -- : Request Timeout => Utils.http_request('http://up-bj-3.qbox.me/bput/likpaUITl60cqeYeiZRMLrIrYNuUfVeiZN1csSIKhqxi97SRgTHkSQGLC1KBAFC3YirCIAZQKZoEZhMY9yYEEX5LJiAOa3gEgiqGKBiuwCFAAsRj0zVtgomIjg0uXy76KDTw4wAAAAAAACAAAAAAAGkHAAC-BYlRAABAAAAAIAACAAAABAD_____/2097152')
W, [2013-05-22T11:13:43.547051 #25685] WARN -- : HTTP status code 701 => Utils.http_request('http://up-bj-3.qbox.me/bput/likpaUITl60cqeYeiZRMLrIrYNuUfVeiZN1csSIKhqxi97SRgTHkSQGLC1KBAFC3YirCIAZQKZoEZhMY9yYEEX5LJiAOa3gEgiqGKBiuwCFAAsRj0zVtgomIjg0uXy76KDTw4wAAAAAAACAAAAAAAGkHAAC-BYlRAABAAAAAIAACAAAABAD_____/2097152')
W, [2013-05-22T11:13:43.764412
2013-05-16 15:20:13 gen token
2013-05-16 15:20:13 uploading
W, [2013-05-16T15:21:14.059880 #23366] WARN -- : Request Timeout => Utils.http_request('http://up-bj-3.qbox.me/bput/likpaUITl60cqeYeiZRMLrIrYNuUfVeiZN1csSIKhqxi97SRgTHkSQGLC1KBAFC3YirCIAZQKZoEZhMY9yYEEX5LJiAOa3gEgiqGKBiuwCFAAsRj0zVtgomIjg0uXy76KDTw4wAAAAAAACAAAAAAAGkHAAC-BYlRAABAAAAAIAACAAAABAD_____/2097152')
W, [2013-05-16T15:21:14.259095 #23366] WARN -- : HTTP status code 701 => Utils.http_request('http://up-bj-3.qbox.me/bput/likpaUITl60cqeYeiZRMLrIrYNuUfVeiZN1csSIKhqxi97SRgTHkSQGLC1KBAFC3YirCIAZQKZoEZhMY9yYEEX5LJiAOa3gEgiqGKBiuwCFAAsRj0zVtgomIjg0uXy76KDTw4wAAAAAAACAAAAAAAGkHAAC-BYlRAABAAAAAIAACAAAABAD_____/2097152')
W, [2013-05-16T15:21:14.530586 #23366] WARN -- : HTTP status code 701 => Utils.http_request('http://up-bj-3.qbox.me/bput/likpaUITl60cqeYeiZRMLrIrYNuUfVeiZN1csSIKhqxi97SRgTHkSQGLC1KBAFC3YirCIAZQKZoEZhMY9yYEEX5LJiAOa3gEgiqGKBiuwCFAAsRj0zVtgomIjg0uXy76KDTw4wAAAAAAACAAAAAAAGkHAAC-BYlRAABAAAAAIAACAAAABAD_____/2097152')
W, [2013-05-16T15:
@martinx
martinx / qiniu_console
Created May 16, 2013 07:00
Qiniu upload error
226/2996
2013-05-16 14:54:48 slug_audio_url:a/7/ywpqjh7l.audio
2013-05-16 14:54:48 uploading file:/w/apsqwezpre/www/a/7/ywpqjh7l.audio
2013-05-16 14:54:48 gen token
2013-05-16 14:54:48 uploading
D, [2013-05-16T14:54:48.713159 #10128] DEBUG -- : Initializing tmpfile: /tmp/Qiniu-RS-Ruby-SDK/a/7/ywpqjh7l.audio/progresses
D, [2013-05-16T14:54:48.713433 #10128] DEBUG -- : Initializing tmpfile: /tmp/Qiniu-RS-Ruby-SDK/a/7/ywpqjh7l.audio/ctxes
D, [2013-05-16T14:54:49.470966 #10128] DEBUG -- : Updating tmpfile: /tmp/Qiniu-RS-Ruby-SDK/a/7/ywpqjh7l.audio/progresses
D, [2013-05-16T14:54:49.471189 #10128] DEBUG -- : chunk 1 in block 0 successfully uploaded.
{:ctx=>"xmHnhZRx_-o7wrEr1pMSQgEG6oIJ0zFLXZcUN2xeLa-C3gtSjKksVQcQCFqSarOy1RAKBGmaw1HkKGiIMOJToEQUCJAsKZOIwEJbEGcIbDRax0vJpojL2IrsVsH6HGEJABKJHgAAAAAAAAQAAAAAAGkHAAC-BYlRAABAAAAABAACAAAABAD_____", :offset=>262144, :restsize=>3932160, :status_code=>200, :host=>"http://up-bj-3.qbox.me"}
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Vincent Ting'
import cookielib
import urllib2
import urllib
import json
import hashlib