Skip to content

Instantly share code, notes, and snippets.

View xu-cheng's full-sized avatar

Cheng XU xu-cheng

View GitHub Profile
// Ref:
// https://github.com/mobilecoinofficial/mc-oblivious/blob/master/aligned-cmov/src/cmov_impl_asm.rs
#include <cassert>
#include <cstddef>
#include <cstdint>
// cmov 64 bits data
inline __attribute__((always_inline)) void cmov_u64(const bool condition,
const uint64_t* src,

Keybase proof

I hereby claim:

  • I am xu-cheng on github.
  • I am xucheng (https://keybase.io/xucheng) on keybase.
  • I have a public key whose fingerprint is 0C60 744C 59EF 7255 8FD0 702A 8794 B5D7 A3C6 7F70

To claim this, I am signing this object:

@xu-cheng
xu-cheng / script.sh
Last active March 6, 2016 11:08
Homebrew Rewrite git history
## extract Formula
git filter-branch -f --prune-empty \
--subdirectory-filter 'Library' \
-- --all
git filter-branch -f --prune-empty \
--index-filter \
'git rm --cached --ignore-unmatch -r -q -- . ; git reset -q $GIT_COMMIT -- Formula Aliases;' \
-- --al
## extract core
formula = ARGV.formulae.first
pkg_config_name = ARGV.value("pkg-config-name") || formula.name
dep_formulae_list = []
env_methods_list = []
cflags_I = `pkg-config --cflags-only-I #{pkg_config_name}`.chomp.split.
map { |f| f.sub(/^-I/, "") }.map do |path|
if path =~ %r{^#{Regexp.escape(HOMEBREW_CELLAR.to_s)}/([^/]+)/[^/]+/(include|lib)(/.*)?} ||
path =~ %r{^#{Regexp.escape(HOMEBREW_PREFIX.to_s)}/opt/([^/]+)/(include|lib)(/.*)?}
if $1 == formula.name
%[-I\#{#{$2}}#{$3}]
@xu-cheng
xu-cheng / youtube_list_videos.py
Created August 25, 2013 15:19
Get all YouTube videos of a channel.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2013 by Xu Cheng (xucheng@me.com)
#
import urllib2
import json
@xu-cheng
xu-cheng / Makefile
Created August 18, 2013 02:01
Makefile to compile LaTeX documents.
#####################################################
# LaTeX Makefile
# Author: Xu Cheng
#
# This Makefile is used to compile LaTeX documents
# Included is basic support for BibTeX bibliographies
#
# This Makefile is written based on below document:
# http://www.physics.wm.edu/~norman/thesis/Makefile
#####################################################
@xu-cheng
xu-cheng / CountDown.py
Created July 31, 2013 04:25
CountDown
# CountDown Timer for iPad
# Copyright (c) 2013 by Xu Cheng
# Usage:
# one figure: start/pause/resume the timer.
# two figures: reset the timer.
# three figures: set the initial time of timer.
from scene import *
from time import time
from math import modf
@xu-cheng
xu-cheng / pytrace.py
Last active December 20, 2015 10:49
Create trace of your python program.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2013 by Xu Cheng (xucheng@me.com)
#
import sys
if sys.version[0] == '2':
from io import open
@xu-cheng
xu-cheng / cygpath.py
Last active December 14, 2015 22:39
Handle Cygwin Path in Sublime
import os
import re
import sublime
cygwin_drive_regex = re.compile(r"^/cygdrive/([a-zA-Z])/")
def cygwin_path_handle(path):
"""Cygwin Path Support"""
if sublime.platform() == "windows":
return os.path.normcase(re.sub(cygwin_drive_regex, lambda m: "%s:/" % m.groups()[0], path))
{
"show_output_panel": false,
"dont_prepend_clang_includes": true,
"additional_language_options":
{
"c++" :
[
"-std=gnu++11",
"-isystem", "C:\\cygwin\\usr\\i686-w64-mingw32\\sys-root\\mingw\\include\\c++\\4.8.0",