Skip to content

Instantly share code, notes, and snippets.

View beordle's full-sized avatar
💌
On vacation, oh..

Jindong Zhang beordle

💌
On vacation, oh..
  • Tencent
  • Beijing, China
View GitHub Profile
@andelf
andelf / EasyJSON.swift
Last active August 29, 2015 14:03
Swift JSON Helper
import Foundation
//let raw = String.stringWithContentsOfURL(NSURL(string: "http://www.weather.com.cn/data/sk/101010100.html"))
struct EasyJSON {
var _obj: AnyObject!
init(_ obj: AnyObject) {
//assert(NSJSONSerialization.isValidJSONObject(obj), "must be valid json object")
_obj = obj
@andelf
andelf / flatten.py
Created October 24, 2011 05:04
How to flatten a python nested list(tuple)
flatten = lambda lst: reduce(lambda l,i: l + flatten(i) if isinstance(i, (list,tuple)) else l + [i], lst, [])
print flatten([2, [2, [4, 5, [7], [2, [6, 2, 6, [6], 4]], 6]]])
# -> [2, 2, 4, 5, 7, 2, 6, 2, 6, 6, 4, 6]
@binux
binux / pool.py
Created May 26, 2011 06:39
使用threading+queue的线程池封装,使用对象在每个对象中保存独立的连接,可以安全地使用ctrl-c打断
# !/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
import time
import Queue
import threading
import traceback
class ExitException(Exception):
@mrluanma
mrluanma / flatten.py
Created December 15, 2011 11:07 — forked from andelf/flatten.py
How to flatten a python nested list(tuple)
flatten = lambda lst: reduce(lambda l, i: l + flatten(i) if isinstance(i, (list, tuple)) else l + [i], lst, [])
print flatten([2, [2, [4, 5, [7], [2, [6, 2, 6, [6], 4]], 6]]])
# -> [2, 2, 4, 5, 7, 2, 6, 2, 6, 6, 4, 6]
@vincenting
vincenting / client.py
Last active February 5, 2021 06:42
微信公共平台脚本
# coding=utf-8
__author__ = 'Vincent Ting'
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Vincent Ting'
import cookielib
import urllib2
@nasitra
nasitra / backtrace.c
Created October 9, 2016 06:31
Print call stack by using libunwind
#include <libunwind.h>
#include <libunwind-ptrace.h>
#include "backtrace.h"
#define MAX_BACKTRACE_FRAMES 64
void unwind(pid_t pid) {
unw_addr_space_t addr_space = NULL;
struct UPT_info* upt_info = NULL;
@aero
aero / readline_ev.cpp
Created March 12, 2015 09:12
Example: Integrating readline with libev eventloop.
// g++ -o readline_ev -g readline_ev.cpp -g -lreadline -lev
//
#include <stdlib.h>
#include <unistd.h>
#include <readline/readline.h>
#include <readline/history.h>
#include <ev.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <linux/memfd.h>
#include <sys/mman.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
void broadcaster( int socket )
{
@pjobson
pjobson / 0.win10_phy_to_virtualbox_vm.md
Last active December 27, 2021 03:45
Windows 10 Physical Drive to VirtualBox VM

Windows Physical Drive to VirtualBox VM

What You Need

  • Windows Computer (I'm using Win10)
  • Linux Computer (I'm using Mint 20.1)
  • External Drive
    • The largest supported image size is 127GB, so if you have a bunch of personal files on your Windows computer, migrate it to a different drive..

Boot your Windows Machine

@ianlewis
ianlewis / sys_sum.go
Created May 25, 2019 16:42
Simple syscall in gVisor
// Copyright 2018 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,