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 / tcltk_demo.R
Created October 5, 2013 03:05
The demo for tcltk package in R
require('tcltk')
calcinp =''
mkput = function(sym){
function(...){
calcinp <<- paste(calcinp,sym,sep='')
tkconfigure(display,text=calcinp)
}
}
clearit = function(...){
@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 / lsos.R
Last active December 30, 2015 13:39
# improved list of objects by Dirk
.ls.objects <- function (pos = 1, pattern, order.by,
decreasing=FALSE, head=FALSE, n=5) {
napply <- function(names, fn) sapply(names, function(x)
fn(get(x, pos = pos)))
names <- ls(pos = pos, pattern = pattern)
obj.class <- napply(names, function(x) as.character(class(x))[1])
obj.mode <- napply(names, mode)
obj.type <- ifelse(is.na(obj.class), obj.mode, obj.class)
obj.size <- napply(names, object.size)
@thirdwing
thirdwing / ListBuilder.h
Created August 1, 2014 00:36
ListBuilder.h from Kevin Ushey
//
// Based on code sent by Kevin Ushey
// to Rcpp-devel on Tue, 8 Jul 2014
//
#ifndef LIST_BUILDER_H
#define LIST_BUILDER_H
#include <Rcpp.h>
using namespace Rcpp;
@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
@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;
require(reshape2)
require(rgl)
plot_rgl_model <- function(fdata){
fdata <- fdata[order(fdata[, 1], fdata[, 2]), ]
orig_names <- colnames(fdata)
colnames(fdata) <- c("x", "y", "z")
fdata <- as.data.frame(fdata)
// 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.

#mlpack on Windows

mlpack, while not designed with Windows as a specific target, can still be built and run on Windows with some configuration. This document details the steps necessary to get MLPACK compiled using MinGW64.

#Prerequisites

  • MinGW64: The compiler we use. Please add it into PATH
  • boost: This is the boost 1.56 static library compiled by myself using MinGW64. Static library is a better choice on Windows.
  • Armadillo
  • BLAS and lapack: Static BLAS and lapack library which are needed by Armadillo. Compiled using MinGW64
@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')