Skip to content

Instantly share code, notes, and snippets.

View liushooter's full-sized avatar

Shooter liushooter

View GitHub Profile
// Created by STRd6
// MIT License
// jquery.paste_image_reader.js
(function($) {
var defaults;
$.event.fix = (function(originalFix) {
return function(event) {
event = originalFix.apply(this, arguments);
if (event.type.indexOf('copy') === 0 || event.type.indexOf('paste') === 0) {
event.clipboardData = event.originalEvent.clipboardData;
@liushooter
liushooter / Gemfile
Last active August 29, 2015 14:24 — forked from msg7086/Gemfile
source 'https://rubygems.org'
gem 'activesupport'
gem 'rspec-rails'
/**
* Clipboard.js
*
* Copyright, Moxiecode Systems AB
* Released under LGPL License.
*
* License: http://www.tinymce.com/license
* Contributing: http://www.tinymce.com/contributing
*/
@liushooter
liushooter / change-referrer.demo.phantom.js
Last active August 29, 2015 14:25 — forked from papoms/change-referrer.demo.phantom.js
Try to overwrite window.document.referrer from within phantomjs / onInitialized
var page = require('webpage').create();
page.onConsoleMessage = function (msg) {
console.log('From Page Console: '+msg);
};
page.onInitialized = function() {
page.evaluate(function () {
"use strict";
//The Referrer we want to set
@liushooter
liushooter / deploy.rb
Last active August 29, 2015 14:25
Deply Rails App with Puma and Nginx via Mina
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'
@liushooter
liushooter / uri.js
Last active August 29, 2015 14:26 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@liushooter
liushooter / delegate.rb
Last active August 29, 2015 14:26
rails delegate
class Company
has_many :users
end
class User
delegate :name, to: :company, prefix: true
# User.last.company_name
belongs_to :company
@liushooter
liushooter / combining.js
Last active August 29, 2015 14:27 — forked from gaearon/combining.js
Combining Stateless Stores
// ------------
// counterStore.js
// ------------
import {
INCREMENT_COUNTER,
DECREMENT_COUNTER
} from '../constants/ActionTypes';
const initialState = { counter: 0 };
@liushooter
liushooter / gist:d9ba8906c6acce124c44
Last active August 29, 2015 14:27 — forked from iantropov/gist:6743621
Reproducing without additional gems and with sqlite
# Activate the gem you are reporting the issue against.
gem 'activerecord', '4.0.0'
require 'active_record'
require 'minitest/autorun'
require 'logger'
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
@liushooter
liushooter / gist:a14827ea6275272cac93
Last active September 1, 2015 09:59 — forked from lanrion/gist:9479631
浅析微信信息信息接收与信息回复

微信的信息接收与回复,两者是独立的。

信息接收

共同点在于:都有 ToUserName,FromUserName,CreateTime,MsgType, 这四个字段。

在信息接收方面,分为“普通消息”、“事件推送”,“语音识别结果(微信用户发送语音,微信服务器翻译成文本,只不过比语音消息多一个识别结果字段:Recognition)”。

  • 文本消息(通过“Content”关键字来获取文本内容,这点比较重要,也是使用比较多的场合)
  • 图片消息