Skip to content

Instantly share code, notes, and snippets.

View thirdwing's full-sized avatar
🏠
Working from home

Qiang Kou (KK) thirdwing

🏠
Working from home
View GitHub Profile
@thirdwing
thirdwing / memory_check.cpp
Created August 16, 2014 19:57
C++ code to print out runtime memory usage
#include <iostream>
#include <fstream>
#include <unistd.h>
void process_mem_usage(double& vm_usage, double& resident_set)
{
vm_usage = 0.0;
resident_set = 0.0;
// the two fields we want
// callback4.cpp - C++11 Lambda Callback
// To build:
// g++ -std=c++11 callback4.cpp
// Situation: A "Caller" class allows another class "Callee"
// to connect to it via callback. How to implement this?
// A C++11 lambda function can be used.
@thirdwing
thirdwing / GraphicalInterface.R
Created October 5, 2013 03:07
The demo for RGtk2 in R
# required: RGtk2
calculateGUI <- function() {
## Run on "OK"
performStatistics <- function(button, user.data) {
res <- NULL
d <- NULL
error <- NULL
warning <- NULL
# Get the information about data and the file
the.file <- filename$getText()
@thirdwing
thirdwing / cart_product.cpp
Created November 14, 2014 22:36
cartesian product in C++
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<vector<int> > cart_product (const vector<vector<int>>& v) {
vector<vector<int>> s = {{}};
for (auto& u : v) {
vector<vector<int>> r;
# Make mouse useful
setw -g mouse on
# Allow xterm titles in terminal window, terminal scrolling with scrollbar, and setting overrides of C-Up, C-Down, C-Left, C-Right
# (commented out because it disables cursor navigation in vim)
#set -g terminal-overrides "xterm*:XT:smcup@:rmcup@:kUP5=\eOA:kDN5=\eOB:kLFT5=\eOD:kRIT5=\eOC"
# Scroll History
set -g history-limit 30000
@thirdwing
thirdwing / README.md
Created February 28, 2019 22:01
Example for C api of tensorflow

Valgrind might report some memory still reachable.

This is known. See tensorflow/tensorflow#17739 for detail.

Resources like thread-pool and memory allocator are shared between sessions. Shutting down the session would not shut down shared resources because those resources may be reused for future sessions. I guess you want an API to shut down memory allocator/thread-pool, which doesn't exist AFAIK

@thirdwing
thirdwing / .vimrc
Last active December 29, 2018 23:20
set backspace=indent,eol,start
colorscheme default
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
@thirdwing
thirdwing / r_install_gpu_win.md
Last active April 6, 2018 02:03
MXNet R installation with GPU support on Windows

MXNet R installation with GPU support on Windows

Clone the MXNet github repo

git clone --recursive https://github.com/dmlc/mxnet

The --recursive is to clone all the submodules used by MXNet.

#include <stdio.h>
#include <errno.h>
#include <glob.h>
char *myname;
/* globerr --- print error message for glob() */
int globerr(const char *path, int eerrno)
{
// gcc -msse3 -O3 sse_4x4.c -l cblas
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <mmintrin.h>
#include <xmmintrin.h>