Skip to content

Instantly share code, notes, and snippets.

#schema.rb
ActiveRecord::Schema.define(:version => 2) do
create_table "stories", :force => true do |t|
t.string "title", "subtitle"
t.string "type"
t.integer "length_counter", :default => 0
t.boolean "published"
end
replaceLinkText : function(text) {
text = this._unescapeHTML.unescape(text.replace(/&/g,"&"));
var elem = document.createElement("description");
elem.className = "twitter-notifier-message-body";
var pat = /((http(s?))\:\/\/)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\/([\w#!:.?+=&%@~*\';,\-\/\$])*)?/g;
var re = /[.,;:]$/;
while (pat.exec(text) != null) {
# orig http://open.taobao.com/demo/RubyDemo.rb
#此DEMO的功能:查询手机类的淘客商品
require 'digest/md5'
require 'open-uri'
require 'cgi'
#组装参数
param_array = {
#组装协议参数
module Rack
class MemoryBloat
def initialize(app, logger)
@app = app
@logger = logger
end
def call(env)
memory_usage_before = memory_usage
result = @app.call(env)
@quake
quake / gist:975794
Created May 17, 2011 02:39
jscex clearInterval
<script>
var canvas = document.getElementById("clockCanvas");
var ctx = canvas.getContext ? canvas.getContext("2d") : null;
var intervalId = setInterval(function () {
drawClock(new Date());
}, 1000);
</script>
<a href="#" onclick="clearInterval(intervalId);">Stop</a>
@quake
quake / gist:7972812
Created December 15, 2013 13:06
ActiveRecord输出上周被点击最多的文章标题
Blog.where(created_at: 1.week.ago.beginning_of_week..1.week.ago.end_of_week).order(view_counts: :desc).first.subject
/*
破解 http://geetest.com/tryit/
打开浏览器在console里面运行如下代码
加载jquery模拟drag脚本,考虑到滑块大小,第一次直接拖动到50px,后续每秒钟拖动8px
从人工拖动的结果可以看出,该验证码方式位置误差在+/- 5px左右,所以50px+8px这样简单粗暴的2行代码就可以有30%的成功率
破解失败情况是在滑块缺口位置偏右了,导致尝试太多
加上图像识别滑块缺口位置,就可以轻松100%地破解
*/
function d(first) {
struct ContainerFoo(i32, i32);
struct ContainerBar(i64, i64);
trait Contains {
type A;
type B;
fn contains(&self, &Self::A, &Self::B) -> bool;
}
[dev-dependencies]
tokio-core = "0.1"
libp2p-tcp-transport = { path = "../tcp-transport"}
libp2p-peerstore = { path = "../peerstore"}
multiplex = { path = "../multiplex-rs" }
rand = "0.4"
env_logger = "0.5.4"
@quake
quake / error.md
Last active August 12, 2019 14:49
2019-08-12 14:38:12.928 +00:00 NetworkRuntime-0 ERROR panic  thread 'NetworkRuntime-0' panicked at 'please check if reach a deadlock': src/libcore/option.rs:1036stack backtrace:
   0: ckb_logger::setup_panic_logger::{{closure}}::h37ba76f9d9060c7e (0x55e53e65775f)
             at util/logger/src/lib.rs:277
   1: std::panicking::rust_panic_with_hook::h057ff03eb4c8000f (0x55e53e75fb09)
             at src/libstd/panicking.rs:478
   2: std::panicking::continue_panic_fmt::ha6d6ae144369025b (0x55e53e75f5a2)
             at src/libstd/panicking.rs:381
   3: rust_begin_unwind (0x55e53e75f486)
             at src/libstd/panicking.rs:308