Skip to content

Instantly share code, notes, and snippets.

View 2sin18's full-sized avatar

Yuan, Man 2sin18

  • Alibaba Group
  • Beijing
View GitHub Profile
@2sin18
2sin18 / C++ Utilities
Last active August 29, 2015 14:04
Utilities to use templates in C++ with less pain
////////////////////////////////////////////////////////////////////////////////
/*
Copyright (c) 2014 Sam Yuen
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
@2sin18
2sin18 / boolang
Last active August 29, 2015 14:04
Boolang for DSL in C++
#include <stdlib.h>
#include <stdint.h>
/*
////////////////////////////////////////////////////////////////////////////////
== [[bet]] binary expression tree
A 'bet' is a binary expression tree, which could be any type as below:
- An indicator, e.g. dpa, dpb
// It's a CPU-bound program for testing
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
static size_t num_slices;
static size_t num_cpus;
static pthread_mutex_t pi_lock;
static double pi;
@2sin18
2sin18 / bibpdf.pl
Created November 24, 2013 14:57
Sync information between BibTeX file and PDF XMP
#!/usr/bin/perl -w
# Sync the information between BibTeX and PDF XMP.
# sam.yuen@foxmail.com
use strict;
use warnings;
use POSIX;
use Getopt::Std;