Skip to content

Instantly share code, notes, and snippets.

View martinx's full-sized avatar

Martin Xu martinx

View GitHub Profile

** 目前仅支持 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'

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

@martinx
martinx / test_markdown.md
Created March 11, 2014 08:33
markdown test

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

  •  |   -          | -   | -       | -
    

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

#!/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
# 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
@martinx
martinx / deploy.rb
Created April 11, 2014 09:50 — forked from stas/deploy.rb
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
# require 'mina/rvm' # for rvm support. (http://rvm.io)
# Basic settings:
# domain - The hostname to SSH to.
# deploy_to - Path to deploy into.
# repository - Git repo to clone from. (needed by mina/git)
# 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
define( ['jquery'], function ( $ ) {
var token = $( 'meta[name="csrf-token"]' ).attr( 'content' );
$.ajaxSetup( {
beforeSend: function ( xhr ) {
xhr.setRequestHeader( 'X-CSRF-Token', token );
}
});
return token;
class Message
[:hello, :goodbye].each do |method_name|
define_method method_name do |arg|
"#{method_name} #{arg}"
end
end
end
#irb
Message.instance_methods false #=> [:hello, :goodbye]
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rvm' # for rvm support. (http://rvm.io)
set :domain, 'esdb.cn'
set :identity_file, '/User/somebody/.ssh/somebody.pem'
set :deploy_to, '/home/ubuntu/apps/xxx.com'
set :repository, 'ssh://[email protected]/somebody/xxx.com.git'
set :branch, 'master'