Skip to content

Instantly share code, notes, and snippets.

@clchiou
clchiou / build-pyv8.sh
Created July 13, 2015 01:16
Build PyV8 for Python 2.7
#!/bin/bash
# For Python3, check:
# https://www.dinotools.de/2013/02/27/python-build-pyv8-for-python3-on-ubuntu/
sudo apt-get install subversion build-essential libboost-python-dev python2.7-dev libboost-system-dev libboost-thread-dev
svn checkout http://v8.googlecode.com/svn/trunk/ v8
svn checkout http://pyv8.googlecode.com/svn/trunk/ pyv8
@clchiou
clchiou / make-ffmpeg.sh
Created April 26, 2015 22:41
Build script for ffmpeg and its dependencies
#!/bin/bash
#
# This script checks out ffmpeg and its dependencies and builds them.
#
# Please refer to
# https://trac.ffmpeg.org/wiki/CompilationGuide
# for more information.
#
set -o errexit -o pipefail -o nounset
@clchiou
clchiou / non_graceful_shutdown.py
Created March 19, 2015 04:32
Python ThreadPoolExecutor (non-)graceful shutdown
#!/usr/bin/env python3
import concurrent.futures.thread
import sys
import time
from concurrent.futures import ThreadPoolExecutor, as_completed
def remove_file(path):
print('Removing file %s' % path)
@clchiou
clchiou / exit_now.py
Created March 18, 2015 05:28
Exit immediately after KeyboardInterrupt
#!/usr/bin/env python3
import time
import concurrent.futures.thread
from concurrent.futures import ThreadPoolExecutor, as_completed
with ThreadPoolExecutor(1) as executor:
fs = [executor.submit(time.sleep, 10)]
try:
@clchiou
clchiou / enter-chroot.sh
Last active August 29, 2015 14:05
Mount and then enter a chroot environment
#!/bin/bash
set -e
if [[ -z "$1" ]]; then
echo "Usage: $(basename $0) CHROOT_PATH"
exit 1
fi
if [[ ${UID:-$(id -u)} == 0 ]]; then
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
template <typename E>
class Matrix {
public:
static const int MAX_DIM = 10;