Skip to content

Instantly share code, notes, and snippets.

View tchaikov's full-sized avatar
🏠
no good deed goes unpunished

Kefu Chai tchaikov

🏠
no good deed goes unpunished
View GitHub Profile
@tchaikov
tchaikov / gist:2642222
Created May 9, 2012 05:52
partial specification
#include <boost/type_traits.hpp>
//#include <boost/utility.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <stdio.h>
using namespace std;
template<class Array, typename From>
@tchaikov
tchaikov / lion-fullscreen.patch
Created June 5, 2012 19:01 — forked from cefstat/lion-fullscreen.patch
Patch for Emacs fullscreen support under Mac OS X 10.7 (Lion)
=== modified file 'lisp/term/ns-win.el'
--- old/lisp/term/ns-win.el 2011-10-01 20:32:01 +0000
+++ new/lisp/term/ns-win.el 2011-11-10 16:22:51 +0000
@@ -928,6 +928,10 @@
(add-to-list 'frame-creation-function-alist '(ns . x-create-frame-with-faces))
(add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system))
+(declare-function ns-toggle-fullscreen-internal "nsfns.m" ())
+(defun ns-toggle-fullscreen ()
+ (interactive)
@tchaikov
tchaikov / tracker.m
Created June 11, 2013 17:00
read the light sensor of a macbook
// Inspired by the code found at
// http://google-mac-qtz-patches.googlecode.com/svn-history/r5/trunk/AmbientLightSensor
// and http://osxbook.com/book/bonus/chapter10/light/
// clang -fobjc-arc tracker.m -o tracker -framework IOKit -framework Foundation
#import <Foundation/Foundation.h>
#import <IOKit/IOKitLib.h>
--- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/type_traits.orig 2014-10-09 00:44:18.000000000 +0800
+++ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/type_traits 2014-10-09 00:49:50.000000000 +0800
@@ -1151,8 +1151,12 @@
#endif // _LIBCPP_HAS_NO_VARIADICS
-template <class _Tp>
+template <class _Tp, bool = is_arithmetic<_Tp>::value>
struct __numeric_type
+{};
# HG changeset patch
# User Kefu Chai <tchaikov@gmail.com>
# Date 1414900607 -28800
# Sun Nov 02 11:56:47 2014 +0800
# Branch gui-release
# Node ID cfeca0c9d02f56a20bd757015a000cfc04967ace
# Parent 82c329619836d0e7e3e491a7c52f2aeebc6679c3
fix the build error on clang 3.5 and libc++ (bug #43298)
* liboctave/operators/mx-inlines.cc:
buildid=`eu-readelf -n $file| grep Build.ID: | awk '{print $3}'`
dir=`echo $buildid | cut -c1-2`
fn=`echo $buildid | cut -c3-`
apt-file find -l /usr/lib/debug/.build-id/${dir}/${fn}.debug
import numpy as np
import matplotlib.pyplot as plt
x,y = np.loadtxt('/tmp/b1000.csv',delimiter=',',usecols=[2,3], unpack=True)
hm,xs,ys=np.histogram2d(x, y, bins=50)
extent = [xs[0], xs[-1], ys[0], ys[-1]]
plt.clf()
plt.imshow(hm.T, extent=extent, origin='lower')
plt.show()
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(TOOLCHAIN_PREFIX arm-linux-gnueabihf)
# specify the cross compiler
set(CMAKE_C_COMPILER /usr/bin/${TOOLCHAIN_PREFIX}-gcc CACHE FILEPATH "CXX cc"))
set(CMAKE_CXX_COMPILER /usr/bin/${TOOLCHAIN_PREFIX}-g++ CACHE FILEPATH "CXX cc")
set(CMAKE_AR /usr/bin/arm-linux-gnueabihf-ar CACHE FILEPATH "Archiver")
# setCMAKE_CXX_LINK_EXECUTABLE ${TOOLCHAIN_PREFIX}-ld)
# set(CMAKE_C_LINK_EXECUTABLE ${TOOLCHAIN_PREFIX}-ld)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(TOOLCHAIN_PREFIX arm-linux-gnueabihf)
# specify the cross compiler
set(CMAKE_C_COMPILER /usr/bin/${TOOLCHAIN_PREFIX}-gcc CACHE FILEPATH "CXX cc"))
set(CMAKE_CXX_COMPILER /usr/bin/${TOOLCHAIN_PREFIX}-g++ CACHE FILEPATH "CXX cc")
set(CMAKE_AR /usr/bin/arm-linux-gnueabihf-ar CACHE FILEPATH "Archiver")
# setCMAKE_CXX_LINK_EXECUTABLE ${TOOLCHAIN_PREFIX}-ld)
# set(CMAKE_C_LINK_EXECUTABLE ${TOOLCHAIN_PREFIX}-ld)
#include <boost/variant.hpp>
#include <iostream>
using namespace boost;
using namespace std;
struct addr_t {
int i = 42;
addr_t() = default;
~addr_t() noexcept = default;