Skip to content

Instantly share code, notes, and snippets.

View hang-qi's full-sized avatar

Hang Qi hang-qi

  • Google
  • Mountain View, CA
View GitHub Profile
@hang-qi
hang-qi / # scalapack - 2017-05-21_17-50-35.txt
Created May 22, 2017 00:52
scalapack (homebrew/science/scalapack) on macOS 10.12.4 - Homebrew build logs
Homebrew build logs for homebrew/science/scalapack on macOS 10.12.4
Build date: 2017-05-21 17:50:35
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hang-qi
hang-qi / latex_tabular.py
Created January 19, 2015 07:49
Generate a latex tabular for the given data matrix.
def latex_table(data, items=None, headers=None, format_str=None):
"""Generate a latex tabular for the given data matrix.
For example:
data_mat = [[1,2,3],[2,4,5]]
items = ['Item 1', 'Item 2']
headers = ['col1', 'col2', 'col3']
format_str='.2f'
latex_table(data_mat, items, headers, format_str)
/* Base styles (regardless of theme) */
.bs-callout {
margin: 20px 0;
padding: 15px 30px 15px 15px;
border-left: 5px solid #eee;
}
.bs-callout h4 {
margin-top: 0;
}
@hang-qi
hang-qi / 0_reuse_code.js
Created June 13, 2014 18:36
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
project(qt-example)
# Find includes in corresponding build directories.
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Tell CMake to run moc when needed.
set(CMAKE_AUTOMOC ON)
# Find the Qt5Widget dependencies.
@hang-qi
hang-qi / draw_sample.m
Created April 4, 2013 08:07
MATLAB: draw_sample
function [sample] = draw_sample(prob_density)
% Draw a sample from 1D probability density.
cdf = cumsum(prob_density);
sample = sum(rand > cdf) + 1;
end
@hang-qi
hang-qi / smart_assert.h
Created April 4, 2013 06:26
C++: SmartAssert
#ifndef _SMART_ASSERT_H_
#define _SMART_ASSERT_H_
#include <string>
#include <sstream>
#include <ostream>
#include <algorithm>
#include <stdexcept>
namespace utility
@hang-qi
hang-qi / scope_guard.h
Created April 4, 2013 06:26
C++: ScopeGuard
#ifndef _SCOPE_GUARD_H_
#define _SCOPE_GUARD_H_
#include <functional>
// One shall use ON_SCOPE_EXIT() macro to create a anonymous ScopeGuard object.
// The anonymous function "callback" will be automatically called in the
// deconstractor when the object is out of the scope.
// Usage:
@hang-qi
hang-qi / gist:5011353
Created February 22, 2013 07:07
CMake: CMakeList for C++11
cmake_minimum_required (VERSION 2.6)
project (project_name)
# Initialize CXXFLAGS.
set(CMAKE_CXX_FLAGS "-Wall -std=c++0x")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")