Skip to content

Instantly share code, notes, and snippets.

View tonyseek's full-sized avatar

Jiangge Zhang tonyseek

View GitHub Profile
from trace import traced
class Tracer(type):
def __new__(cls, name, bases, cdict):
for n in cdict:
if callable(cdict[n]) \
and not n.startswith("__"):
cdict[n] = traced(cdict[n])
return type.__new__(cls, name, bases, cdict)
@asenchi
asenchi / logstash-mysql-query-parse.md
Created September 20, 2012 01:06 — forked from jordansissel/logstash-mysql-query-parse.md
parsing mysql's bullshit query log format with logstash

parsing mysql query logs with logstash

The problem is that some lines in the file are missing timestamps when they aren't continuations of any previous line. It's dumb, really.

The mysql query log is seriously bullshit format, but nothing logstash can't unscrew.

The main goal here is to show how we can fix the 'missing timestamp' problem.

% ruby bin/logstash agent -e '

@jkeyes
jkeyes / acme.rst
Created November 28, 2012 10:21
ReST Hyperlink with Unicode

The following ReST:

|Acme(TM)|_

.. |Acme(TM)| unicode:: Acme U+2122
.. _Acme(TM): http://example.com

produces this HTML:

_

# Place this file in the same directory as `Vagrantfile'
# then simply require "vagrant-snapshot.rb" at the top of Vagrantfile.
require 'optparse'
Vagrant.commands.register(:snap) { Snap::Commands }
# Provide rake-like desc() 'inflected' documentation
# See http://stackoverflow.com/questions/2948328/access-attributes-methods-comments-programmatically-in-ruby
class Module
@suzaku
suzaku / test_sync
Last active December 21, 2015 04:09
O_DSYNC vs. O_SYNC vs. Call fsync manually vs. no sync
In [19]: fd = os.open('t1', os.O_CREAT | os.O_DSYNC | os.O_WRONLY)
In [20]: %timeit os.write(fd, 'a')
1000 loops, best of 3: 232 us per loop
In [21]: fd2 = os.open('t2', os.O_CREAT | os.O_SYNC | os.O_WRONLY)
In [22]: %timeit os.write(fd2, 'a')
1000 loops, best of 3: 737 us per loop
{% set has_changed = make_has_changed() %}
{% for item in foo %}
{% if has_changed(item.date.year, item.date.month) %}
<h1>{{ item.date.year }} {{ item.date.month }}</h1>
{% endif %}
...
{% endfor %}
@menghan
menghan / Makefile
Last active December 23, 2015 20:09
bench:
go test benchmark_test.go --bench=. | tee result
@mattcassinelli
mattcassinelli / Simplenote List
Last active January 3, 2016 19:11
Simplenote action list to Open the app, create a blank New Note, and to add new notes with a tag for Work, Ideas, URL, or my blog AppBookPro.
simplenote://[[list:Add to SimpleNote|Open=:|New Note=new?content=|Work=new?content=&tag=work|Ideas=new?content=&tag=ideas|URL=new?content=&tag=URL|AppBookPro=new?content=&tag=appbookpro]]
simplenote://
[[
list:Add to SimpleNote
|Open=:|New Note=new?content=
|Work=new?content=&tag=work
|Ideas=new?content=&tag=ideas
|URL=new?content=&tag=URL
|AppBookPro=new?content=&tag=appbookpro
def createSlackTasks() {
mAndroidAppExtension.applicationVariants.all{
if (!it.buildType.debuggable){
def task = mProject.tasks.create("slack${it.name.capitalize()}", UploadSlackTask)
task.variant = it
task.dependsOn it.assemble
}
}
}
#!/usr/bin/python2
# -*- coding:UTF-8 -*-
# code related at: http://blog.mckelv.in/articles/1453.html
import sys
distance = lambda a,b : 0 if a==b else 1
def dtw(sa,sb):
'''