Skip to content

Instantly share code, notes, and snippets.

View smly's full-sized avatar
👁️‍🗨️

smly smly

👁️‍🗨️
View GitHub Profile
@smly
smly / gist:4978576
Last active December 13, 2015 21:38
for ... else ...
$ python -v
Python 2.7.2

case1:

else: print 1

result1:

@smly
smly / opensmb
Last active October 10, 2015 06:48
open file at samba shares (Windows file-sharing) using the file path in windows
#!/bin/zsh
## Open file at samba shares (Windows file-sharing) using the file path in windows
## (for OSX only)
usage()
{
>&2 <<-\HELP
Usage: opensmb '\\fileserver\public\all_your_base_are_belong_to_us.mp3'
HELP
@smly
smly / for TransportException
Created May 29, 2012 14:13
diff -c /data/hoge/huga/local/lib/ruby/gems/1.8/gems/flockdb-0.7.1/lib/flock/service.rb{.backup,}
*** /data/hoge/huga/local/lib/ruby/gems/1.8/gems/flockdb-0.7.1/lib/flock/service.rb.backup 2012-05-29 17:19:00.000000000 +0900
--- /data/hoge/huga/local/lib/ruby/gems/1.8/gems/flockdb-0.7.1/lib/flock/service.rb 2012-05-29 17:21:01.000000000 +0900
***************
*** 1,6 ****
module Flock
class Service < ThriftClient
! DEFAULTS = { :transport_wrapper => Thrift::BufferedTransport }
def initialize(servers = nil, options = {})
if servers.nil? or servers.empty?
@smly
smly / for TransportException
Created May 29, 2012 14:13
diff -c /data/hoge/huga/local/lib/ruby/gems/1.8/gems/flockdb-0.7.1/lib/flock/service.rb{.backup,}
*** /data/hoge/huga/local/lib/ruby/gems/1.8/gems/flockdb-0.7.1/lib/flock/service.rb.backup 2012-05-29 17:19:00.000000000 +0900
--- /data/hoge/huga/local/lib/ruby/gems/1.8/gems/flockdb-0.7.1/lib/flock/service.rb 2012-05-29 17:21:01.000000000 +0900
***************
*** 1,6 ****
module Flock
class Service < ThriftClient
! DEFAULTS = { :transport_wrapper => Thrift::BufferedTransport }
def initialize(servers = nil, options = {})
if servers.nil? or servers.empty?
@smly
smly / flockdb-ruby-client.rb
Created May 29, 2012 08:28
diff ~/local/lib/ruby/gems/1.8/gems/flockdb-0.7.1/lib/flock/service.rb{.backup,}
3c3
< DEFAULTS = { :transport_wrapper => Thrift::BufferedTransport }
---
> DEFAULTS = {:transport_wrapper => Thrift::FramedTransport, :connect_timeout => 1 }
@smly
smly / gist:2290696
Created April 3, 2012 09:37
avocadodb formula
diff --git a/Library/Formula/avocadodb.rb b/Library/Formula/avocadodb.rb
index 612d816..39205df 100644
--- a/Library/Formula/avocadodb.rb
+++ b/Library/Formula/avocadodb.rb
@@ -6,14 +6,9 @@ class Avocadodb < Formula
sha1 '99223ea26b679c92ba431a4743a7143dd6a4adf3'
head "https://github.com/triAGENS/AvocadoDB.git"
- depends_on 'libev'
- depends_on 'v8'
@smly
smly / pymf_buf_report
Created March 9, 2012 22:21
Miscellaneous routines (scipy.misc)
λ smly@moss:/opt/mnt/hotgraph|master⚡ → python 7:08:02
Python 2.7.2 (default, Mar 7 2012, 15:34:56)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymf/__init__.py", line 41, in <module>
from .sivm_sgreedy import *
File "/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymf/sivm_sgreedy.py", line 25, in <module>
@smly
smly / gist:1936603
Created February 29, 2012 00:45
LOL_redis_scripting.rb
require 'redis'
r = Redis.new
LuaScript = <<EOF
function fib(n)
if n < 2 then return n end
local a = redis.call('hget',KEYS[1],n-1) or fib(n-1)
local b = redis.call('hget',KEYS[1],n-2) or fib(n-2)
@smly
smly / bron-kerbosch-pivot.cpp
Created December 24, 2011 06:54
smly::find_cliques -- a pivoting version of Bron-Kerbosch algorithm
#include <iostream>
#include <sstream>
#include <vector>
#include <boost/unordered_map.hpp>
#include <boost/unordered_set.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
// #define DEBUG
@smly
smly / gist:1479553
Created December 15, 2011 02:26
redis benchmark: redis-2.4.4 / Amazon EC2 large
testredis01/0$ redis-cli flushall
OK
testredis01/0$ ./redis-load clients 100 requests 10000000 datasize 32 keyspace 10000000 set 100
PRNG seed is: 243646450 - use the 'seed' option to reproduce the same sequence
====== Report ======
10000000 requests in 253.451 seconds
39455.36 requests per second
100 parallel clients
payload: 32..32 bytes
keep alive: 1