Skip to content

Instantly share code, notes, and snippets.

View legnaleurc's full-sized avatar

Wei-Cheng Pan legnaleurc

View GitHub Profile
#! /usr/bin/env python3
import asyncio
from concurrent.futures import ThreadPoolExecutor
import requests
import sys
def background_task():
rv = requests.get('https://httpbin.org/get')
@legnaleurc
legnaleurc / git2hg.md
Last active January 12, 2018 06:14
Mercurial Cheatsheet
git mercurial
git log hg log -f
git remote show hg incoming
git remote update hg pull
git branch hg bookmarks
git checkout $commit_id hg update $changeset_id
git add -p
git commit
hg commit -i
git rebase -i $commit_id hg histedit $changeset_id
@legnaleurc
legnaleurc / stream.cgi
Last active July 26, 2017 05:10
streaming PoC
#! /bin/sh
echo 'Content-Type: video/mp4'
echo
ffmpeg -i 'rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov' -c:v copy -c:a copy -f mp4 -movflags frag_keyframe+empty_moov -
#include <stdio.h>
#include <pthread.h>
void * worker (void * o) {
int * p = NULL;
printf("%d\n", *p);
return NULL;
}
@legnaleurc
legnaleurc / build-llvm-clang.sh
Last active October 26, 2016 10:19
Build LLVM Clang toolchain
#! /bin/sh
set -e -x
BUILD_DIR='/tmp/llvm-clang'
INSTALL_DIR='~/local/opt/llvm-clang'
LLVM_VERSION='3.9.0'
DARWIN_VERSION='16.1.0'
@legnaleurc
legnaleurc / transstack.py
Last active May 17, 2016 07:35
Translate C++ stack frame address to source address
#! /usr/bin/env python3
import re
import shutil
import sys
import asyncio
class BaseParser(object):
@legnaleurc
legnaleurc / stackstalker.cpp
Last active May 17, 2016 07:45
SpiderMonkey Stack Stalker
#include "mozilla/StackWalk.h"
#include "nsPrintfCString.h"
// HACK forward declartion
extern "C" char* PrintJSStack();
void JS_smprintf_free(char*);
#define DEBUG_STACK_PATH "/tmp/raw_stacks.txt"
namespace debug {
@legnaleurc
legnaleurc / devtools_client.py
Created February 3, 2016 09:19
devtools_client.py
#! /usr/bin/env python3
import asyncio
import json
import sys
import yaml
def main(args=None):
@legnaleurc
legnaleurc / boost1.55_coroutine.patch
Last active August 29, 2015 14:23
boost1.55_coroutine.patch
Index: debian/changelog
===================================================================
--- debian/changelog (revision 14903)
+++ debian/changelog (working copy)
@@ -1,3 +1,9 @@
+boost1.55 (1.55.0+dfsg-4.1~coroutine1) experimental; urgency=low
+
+ * Enable coroutine shared library.
+
+ -- Wei-Cheng Pan <legnaleurc@gmail.com> Fri, 26 Jun 2015 04:34:46 +0000
@legnaleurc
legnaleurc / asyncio.py
Last active November 17, 2018 21:27
Tornado v.s. asyncio (Python 3.5+)
#! /usr/bin/env python3
import asyncio
import contextlib
async def ping(ip):
p = await asyncio.create_subprocess_exec('ping', '-c', '4', ip, stdout=asyncio.subprocess.PIPE)
async for line in p.stdout:
print(line)