Skip to content

Instantly share code, notes, and snippets.

@creative-quant
creative-quant / ts.turning.points.R
Created March 8, 2016 19:37
An example of finding turning points in a time series using pastecs
require(graphics)
#some data
d <- density(faithful$eruptions, bw = "sj")
#make it a time series
ts_y<-ts(d$y)
#calculate turning points (extrema)
require(pastecs)
tp<-turnpoints(ts_y)
@creative-quant
creative-quant / str_const.h
Created April 14, 2016 12:00
str_const from Scott Schurr - 2012.cppnow.org -> schurr_cpp11_tools_for_class_authors.pdf
class str_const { // constexpr string
private:
const char* const p_;
const std::size_t sz_;
public:
template<std::size_t N>
constexpr str_const(const char (&a)[N]) : // ctor
p_(a), sz_(N - 1) {
}
constexpr char operator[](std::size_t n) { // []
@creative-quant
creative-quant / git-project-stats.sh
Created April 27, 2016 20:57
a script to get git user and project stats
#!/bin/bash
echo "by $USER"
git log --shortstat --author "$USER" \
| grep "files\? changed" \
| awk '{files+=$1; inserted+=$4; deleted+=$6} END \
{print "files changed", files, "lines inserted:", inserted, "lines deleted:", deleted}'
echo "total"
git log --shortstat \
| grep "files\? changed" \
| awk '{files+=$1; inserted+=$4; deleted+=$6} END \