{{ message }}

Instantly share code, notes, and snippets.

💭
(Come in under the shadow of this red rock)

# Derrick Turkderrickturk

💭
(Come in under the shadow of this red rock)
Created Jan 8, 2014
Here's a simple but useful function for quickly reviewing distributions and missing data. Suitable for preliminary data QC and exploratory analysis.
View qc_plots.R
 # (c) 2013 dwt | terminus data science, LLC # freely licensed for non-commercial use qc.plots <- function(df, max.levels=25, ask=TRUE, col="white") { old.par <- par(ask=ask) on.exit(par(old.par)) for (var in names(df)) { vals <- df[[var]]
Created Jan 8, 2014
A simple generic simulated annealing solver, and basic implementations of the "standard" acceptance probability function and exponential-decay temperature schedules.
View anneal.py
 from random import Random import math def anneal(initial, energyfn, candidatefn, acceptancefn, temperaturefn, tmax): rand = Random() t = 0 solution = initial s_best = initial e_best = energyfn(initial)
Created Jan 8, 2014
Some didactic example code, intended to help my brother through a poorly-taught "C++" class. I was a little hamstrung by the fact that the class taught (bad C + "new" and "delete" + bad Java) and called it C++...
View fork_and_pipes.cpp
 #include #include #include #include "unistd.h" #include "sys/wait.h" #include "sys/types.h" #include "sys/time.h" // I can never remember this...
Created Jan 29, 2014
In the game of web scraping, you win... or you die.
View doggr.py
 from urllib import request from sys import argv, stdout, stderr from time import sleep from random import randrange import re def main(argv): if len(argv) == 1: try: with open(argv[0], 'r') as f:
Last active Aug 29, 2015
Handy function for HSV-scale-izing real-valued data.
View hsv_scale.R
 hsv.scale <- function (var, hmin, hmax=hmin, smin=1, smax=smin, vmin=1, vmax=vmin, na.col=rgb(0.75, 0.75, 0.75)) { var.min <- min(var, na.rm=TRUE) var.max <- max(var, na.rm=TRUE) h.f <- approxfun(c(var.min, var.max), c(hmin, hmax)) s.f <- approxfun(c(var.min, var.max), c(smin, smax)) v.f <- approxfun(c(var.min, var.max), c(vmin, vmax)) tmp <- var
Created Feb 6, 2014
Javascript style "immediately invoked function expressions" plus on.exit for scope guards in R. Cleanup actions get carried out regardless of clean or error exit from block.
View iife.R
 (function() { pdf("example.pdf") on.exit(dev.off()) plot(some.data) })()
Created Feb 24, 2014
View columns.html

Last active Aug 29, 2015
Minimalist pinterest :)
View GISTEREST.md

# gisterest

## Data science

### Algorithms

Created Feb 25, 2014
Dinking around with building windows DLLs with MinGW again. And figured out where the [[gnu::stdcall]] goes.
View build.bat
 g++ -std=c++11 -Wall -Wextra -c dlltest.cpp g++ -shared -static-libgcc -static-libstdc++ -o dlltest.dll dlltest.o -Wl,--add-stdcall-alias
Created Feb 25, 2014
View fun_with_c++11.cpp
 #include constexpr int fac(int n) { return n <= 0 ? 1 : n * fac(n - 1); } struct [[weenie]] C { void f() && { std::cout << "dying C's last gasp!\n"; } void f() & { std::cout << "living, breathing C\n"; }
You can’t perform that action at this time.