Skip to content

Instantly share code, notes, and snippets.

View ibigbug's full-sized avatar
🏓
Focusing

Yuwei Ba ibigbug

🏓
Focusing
View GitHub Profile
@ibigbug
ibigbug / python-gdb.py
Created August 16, 2017 02:02
gdb python extension
import gdb
class HeapdumpCmd(gdb.Command):
"""Do a heap dump"""
def __init__(self):
gdb.Command.__init__(self, "mdump", gdb.COMMAND_STACK, gdb.COMPLETE_NONE)
def invoke(self, _arg, _from_tty):
@ibigbug
ibigbug / keybase.md
Last active September 12, 2019 02:29

Keybase proof

I hereby claim:

  • I am ibigbug on github.
  • I am byw (https://keybase.io/byw) on keybase.
  • I have a public key ASAML1Fyh7jgPdIdWBtCsEY3cuKRT_Y8Xd-laA8i_PMFtAo

To claim this, I am signing this object:

@ibigbug
ibigbug / thrift.rb
Created June 20, 2017 16:37
Thrift@0.9.1 for Homebrew
require "formula"
class Thrift < Formula
homepage "http://thrift.apache.org"
stable do
url "http://archive.apache.org/dist/thrift/0.9.1/thrift-0.9.1.tar.gz"
#sha1 "dc54a54f8dc706ffddcd3e8c6cd5301c931af1cc"
# These patches are 0.9.1-specific and can go away once a newer version is released
import socket
HOST = ''
PORT = 9999
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
while 1:
@ibigbug
ibigbug / a.sh
Created June 29, 2016 13:25
tee daemon won't exit
#!/bin/bash
main() {
echo 1
python sig.py &
echo 2
}
main 2>&1 | tee -a a.log
package safemap
import (
"fmt"
)
const (
remove commandAction = iota
end
find
'use strict';
var fs = require('fs')
var read = function(name) {
return function(cb) {
fs.readFile(name, {encoding: 'utf-8'}, cb)
}
}
@ibigbug
ibigbug / flask-serve-static.py
Created June 24, 2015 06:07
Very simple static folder server using Flask
from flask import Flask
from flask import request
from flask import jsonify
from flask import send_from_directory
app = Flask(__name__)
@app.route('/', defaults=dict(filename=None))
@ibigbug
ibigbug / brainfuck.py
Last active May 31, 2016 13:34
brainfuck python implement
import sys
"""
A simple and powerful `Brainfuck` interpreter implementation in Python
Steal from: http://blog.csdn.net/redraiment/article/details/7483062
"""
def _gen_array(length):
return [0 for i in range(0, length)]
@ibigbug
ibigbug / flatten.js
Last active August 29, 2015 14:05
Flatten Array
function flatten(input) {
'use strict';
if (!Array.isArray(input)) // need polyfill
return input;
var ret = [];
(function inner(input, ret) {
if (input.length === 0)
return ret;
var car = input.shift(0);