Skip to content

Instantly share code, notes, and snippets.

@imrichardcole
imrichardcole / yieldcurve6.h
Created March 13, 2023 07:26
QuantLib YieldCurve6.h
// Author: Dimitri Reiswich
#include <boost/assign/std/vector.hpp>
// #include <boost/assign.hpp>
std::vector<boost::shared_ptr<RateHelper>> getRateHelperVector()
{
[alias]
st = status
lg = log --graph --pretty=format:'%Cred%h%Creset \n-%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' \n--abbrev-commit --date=relative
ol = log --pretty=format:'%Cred%h%Creset %C(yellow)%d%Creset %s %Cgreen(%cr)%Creset'
@imrichardcole
imrichardcole / Sout.java
Created January 30, 2016 11:17
A performance benchmark of System.out.println()
@Test
public void system_out_println() {
final Benchmark<Void> benchmark = Benchmark.<Void>builder()
.withPerformanceBenchmark(() -> {
System.out.println("hello, world");
return null;
})
.withName("print to screen")
.withIterations(25000)
.build();
@imrichardcole
imrichardcole / iphoto-backup.sh
Created December 29, 2015 16:00
A script to perform incremental backups of iPhoto
#!/bin/sh
TODAY=$(date +"%Y%m%d")
LOGFILE="iphoto-backup-$TODAY.log"
IPHOTOS_LOCATION=$1
BACKUP_LOCATION=$1
mkdir "/Users/richard/tmp/backup/"
touch $LOGFILE
rsync -av "$IPHOTOS_LOCATION/Photos Library.photoslibrary/" "$BACKUP_LOCATION/Photos Library.photoslibrary" > $LOGFILE
@imrichardcole
imrichardcole / AliceSplit.java
Created April 9, 2015 10:40
Alice in wonderland word split
import com.google.common.io.Files;
import com.imrichardcole.benchpress.Benchmark;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
public class AliceSplit {
@imrichardcole
imrichardcole / StringsAndThings.java
Created June 7, 2013 19:01
Create a random alphanumeric String in Java
public class StringsAndThings {
private static final char[] characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
private static final Random random = new Random(new Date().getTime());
public static void main(String[] args) {
final String randomString = StringsAndThings.createRandomString(1000);
System.out.println(randomString);
}
@imrichardcole
imrichardcole / gira.rb
Created March 11, 2013 20:22
Simple Ruby script for interacting with git and jira
require 'grit'
repo_path = ARGV[0] || "/Users/richard/Documents/work/ruby/grit"
tag = ARGV[1] || "v0.1"
repo = Grit::Repo.new(repo_path)
commits_since_tag = repo.commits_between(tag, "HEAD")
puts "#{commits_since_tag.size} commit(s) since tag #{tag}"
from urllib2 import Request, urlopen
from sys import exit
import json
url = "teamcity url here"
content = "application/json"
request = Request(url, None, {'Accept': content})
dict = json.loads(urlopen(request).read())
status = dict['build'][0]['status']