Skip to content

Instantly share code, notes, and snippets.

@stephenjbarr
stephenjbarr / sjb_rinside1.cpp
Created August 30, 2012 05:36
an example of using R's optim to optimize a C++ function exposed via Rcpp::InternalFunction
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8; -*-
//
// Simple example showing how expose a C++ function
//
// Copyright (C) 2010 Dirk Eddelbuettel and Romain Francois
#include <RInside.h> // for the embedded R via RInside
// a c++ function we wish to expose to R
const char* hello( std::string who ){
@stephenjbarr
stephenjbarr / Makefile
Created August 30, 2012 06:25
A few demonstrations of Rcpp::InternalFunction
## -*- mode: make; tab-width: 8; -*-
##
## Simple Makefile
##
## From RInside examples
## TODO:
## proper configure for non-Debian file locations, [ Done ]
## allow RHOME to be set for non-default R etc
## comment this out if you need a different version of R,
@sftrabbit
sftrabbit / beta_distribution.hpp
Last active July 24, 2024 10:22
A beta distribution random number distribution for C++11. Conforms to the requirements for a random number distribution (§26.5.1.6 [rand.req.dist]) and is therefore compatible with the <random> C++ library header. Implemented in terms of two gamma distributions (std::gamma_distribution): if X and Y are independently distributed Γ(α, θ) and Γ(β, …
#include <iostream>
#include <sstream>
#include <string>
#include <random>
namespace sftrabbit {
template <typename RealType = double>
class beta_distribution
{
-- | Internal implementation of the @io-streams@ library, intended for library
-- writers
--
-- Library users should use the interface provided by "System.IO.Streams"
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
@npezolano
npezolano / makeR
Last active December 17, 2015 11:59
compile R on mac osx with gcc ,clang and accelerate framework
#make R with GCC
./configure CC="gcc-mp-4.7 -arch x86_64" CXX="gcc-mp-4.7 -arch x86_64" F77="gfortran-mp-4.7 -arch x86_64" FC="gfortran-mp-4.7 -arch x86_64" OBJC="gcc-mp-4.7 -arch x86_64" --x-includes=/usr/X11/include/ --x-libraries=/usr/X11/lib/ --with-blas='-framework Accelerate' --with-lapack --without-aqua CPPFLAGS="-D__ACCELERATE__" --prefix=/Users/admin1/lib/R --enable-BLAS-shlib
#make R with Clang
./configure CC="clang -arch x86_64" CXX="clang -arch x86_64" F77="gfortran -arch x86_64" FC="gfortran -arch x86_64" OBJC="clang -arch x86_64" --x-includes=/usr/X11/include/ --x-libraries=/usr/X11/lib/ --with-blas='-framework Accelerate' --with-lapack --without-aqua CPPFLAGS="-D__ACCELERATE__" --prefix=/Users/admin1/libclang34 --enable-BLAS-shlib
module Main where
import Criterion.Main
import qualified Data.List.Ordered as O
import qualified Data.List as L
import qualified Data.Set as S
import qualified Data.IntSet as IS
repeatsTail, orderedIntersect, listIntersect, setIntersect :: [Integer] -> [Integer] -> [Integer] -> [Integer]
intsetIntersect :: [Int] -> [Int] -> [Int] -> [Int]
@alexanderkjeldaas
alexanderkjeldaas / peace.sh
Last active December 19, 2015 23:59
Safer cabal --upgrade-dependencies. Easy detection of non-optimal upper bounds. Unregister broken packages with ghc. Reset ghc pkg db.
# unregister broken GHC packages. Run this a few times to resolve
# dependency rot in installed packages. ghc-pkg-clean -f
# cabal/dev/packages*.conf also works.
function ghc-pkg-clean() {
for p in `ghc-pkg check $* 2>&1 | grep problems | awk '{print $6}' | sed -e 's/:$//'`
do
echo unregistering $p; ghc-pkg $* unregister $p
done
}
@sordina
sordina / EkgJsonParser.hs
Last active December 26, 2015 11:39
Monitor "upstream" processes with EKG
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
module EkgJsonParser where
import Data.Aeson
import Data.Aeson.Types
import Control.Monad
import Data.ByteString.Lazy
@naftaliharris
naftaliharris / trypy
Last active January 2, 2016 09:39
An enhancement to the "python" executable that automatically launches you into a debugger if your code throws an exception.
#!/bin/bash
# An enhancement to the "python" executable that automatically launches you into the python debugger on error.
#
# Use it like you would the "python" executable, for example:
# $ trypy somefile.py
# or
# $ trypy somefile.py arg1 arg2
#
# EXAMPLE:
@jdmaturen
jdmaturen / company-ownership.md
Last active July 29, 2023 22:39
Who pays when startup employees keep their equity?

Who pays when startup employees keep their equity?

JD Maturen, 2016/07/05, San Francisco, CA

As has been much discussed, stock options as used today are not a practical or reliable way of compensating employees of fast growing startups. With an often high strike price, a large tax burden on execution due to AMT, and a 90 day execution window after leaving the company many share options are left unexecuted.

There have been a variety of proposed modifications to how equity is distributed to address these issues for individual employees. However, there hasn't been much discussion of how these modifications will change overall ownership dynamics of startups. In this post we'll dive into the situation as it stands today where there is very near 100% equity loss when employees leave companies pre-exit and then we'll look at what would happen if there were instead a 0% loss rate.

What we'll see is that employees gain nearly 3-fold, while both founders and investors – particularly early investors – get dilute