Skip to content

Instantly share code, notes, and snippets.

View cuber's full-sized avatar

Cube cuber

View GitHub Profile
<style>
span { display: inline-block; }
#left { text-align: left; }
#right { text-align: right; }
</style>
<div style="width: 100px; height: 30px; overflow:hidden; ">
<span id="left"></span>
<span id="right"></span>
</div>
@cuber
cuber / gist:11292869
Created April 25, 2014 15:07
How To install Scala 2.10 with homebrew
# you should checkout to the history version of scala.rb
cd /path/to/homebrew (default is /usr/local)
git checkout d64edec425df44918c58b6b021ffef2628242248 Library/Formula/scala.rb
brew info scala # you will see the 2.10 version
brew install scala
# after install, turn back to the master version
brew checkout master Library/Formula/scala.rb
# you can install both 2.10 & 2.11, brew switch can easily switch to any specific version
brew switch scala 2.10
brew switch scala 2.11
@cuber
cuber / protobuf.rb
Last active August 29, 2015 14:00
Library/Formula/protobuf.rb 2.4.0a
require 'formula'
class Protobuf < Formula
url 'http://protobuf.googlecode.com/files/protobuf-2.4.0a.tar.bz2'
homepage 'http://code.google.com/p/protobuf/'
sha1 '5816b0dd686115c3d90c3beccf17fd89432d3f07'
fails_with_llvm
def options
@cuber
cuber / crc32.sql
Created May 4, 2014 04:06
crc32 for postgresql
CREATE OR REPLACE FUNCTION CRC32(VARCHAR) RETURNS BIGINT AS
$BODY$
DECLARE
src alias FOR $1;
crc BIGINT not null default x'ffffffff'::BIGINT;
len INTEGER not null default 0;
i INTEGER not null DEFAULT 1;
table BIGINT[] not null DEFAULT ARRAY[
x'00000000'::BIGINT, x'77073096'::BIGINT, x'EE0E612C'::BIGINT, x'990951BA'::BIGINT,
x'076DC419'::BIGINT, x'706AF48F'::BIGINT, x'E963A535'::BIGINT, x'9E6495A3'::BIGINT,
@cuber
cuber / 1.Q.php
Last active August 29, 2015 14:01
A->B路径求解问题
<?php
// --------------------------------------
// 通往
// 假设 [begin] -> [end] 之间有 N 个step
// 每个 step.i 又有 iM 个节点
// 需要求解 [begin] -> [end] 所有路径组合
// --------------------------------------
@cuber
cuber / 1.matrix.php
Last active August 29, 2015 14:01
矩阵法
<?php
$e = array(
array('a1', 'a2'),
array('b1', 'b2', 'b3', 'b4'),
array('c1', 'c2'),
);
$N = count($e);
$r = array();
@cuber
cuber / proxy.pac
Last active December 26, 2016 16:00
O(1) proxy.pac file
// Generated by gfwlist2pac
// created by @clowwindy via python
// modified by @cube via native zsh
// https://github.com/cuber/gfwlist2pac
var domains = {
'dnsimple.com': 1,
'stackoverflow.com': 1,
'igvita.com': 1,
'jetbrains.com': 1,
'linost.com': 1,
@cuber
cuber / google.conf
Created December 16, 2014 07:30
ngx_http_google_filter_module.conf
server {
# ...
resolver 8.8.8.8;
location {
google on;
}
# ...
}
@cuber
cuber / ugly.js
Created December 19, 2014 08:44
886404 is ugly
var Searcher = {
a: function() {
so = this;
so.g();
window._r_ = false;
window.google = {
td: function(a, b, c) {
if (window._r_) return;
var h = c.d;
var t = h.match(/<font size="-1">[^,\d]*([,\d]+)[^,\d]*条结果[^\d]*(\d+)[^\d]*(用时 <b>(.*?)<\/b> 秒)&nbsp;<\/font>/);
@cuber
cuber / evhttp_client.cc
Created April 4, 2015 11:28
Concurrent Http Client of Libevent
//
// evhttp_client.cc
//
// Created by Cube on 15/4/3.
// Copyright (c) 2015年 Cube. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>