Skip to content

Instantly share code, notes, and snippets.

Avatar

Morten Piibeleht mortenpi

  • Massey University
  • Auckland, New Zealand
View GitHub Profile
View FindGSL.cmake
# Try to find gnu scientific library GSL
# See
# http://www.gnu.org/software/gsl/ and
# http://gnuwin32.sourceforge.net/packages/gsl.htm
#
# Based on a script of Felix Woelk and Jan Woetzel
# (www.mip.informatik.uni-kiel.de)
#
# Available at: http://www.miscdebris.net/blog/2010/06/21/cmake-module-to-find-gnu-scientific-library-findgsl-cmake/
#
@mortenpi
mortenpi / Timer.cc
Created Apr 28, 2014
C++ Timer class using POSIX times()
View Timer.cc
#include "Timer.hh"
#include <iostream>
#include <sys/times.h>
#include <unistd.h>
// ---------------------------------------------------------------------
// class Time
// ---------------------------------------------------------------------
const long Time::sc_clk_tck = sysconf(_SC_CLK_TCK);
View sizeof.cc
#include <iostream>
using namespace std;
struct type_t {
int i;
};
void function()
{
@mortenpi
mortenpi / acbh-audio.py
Created Aug 21, 2015
Assassin's Creed: Brotherhood audio puzzle solver
View acbh-audio.py
#!/usr/bin/env python3
import itertools
def powerset(iterable):
xs = list(iterable)
return itertools.chain.from_iterable(
itertools.combinations(xs,n) for n in range(len(xs)+1)
)
samples = [
@mortenpi
mortenpi / yumhelp-dbgen.py
Last active Sep 6, 2015
A quick hack to generate a sqlite database from yumdb and repository cache to ease understanding what packages are installed and available.
View yumhelp-dbgen.py
#!/usr/bin/env python3
import argparse
import os
import os.path
import re
import sqlite3
def yumdb_packages(path):
dirs = os.listdir(path)
dirs.sort()
@mortenpi
mortenpi / NoninteractiveGadfly.jl
Created Sep 7, 2015
Makes the plots in Gadfly non-interactive (Juno lags with interactive plots)
View NoninteractiveGadfly.jl
module NoninteractiveGadfly
import Compose
import Compose: writemime
import Gadfly
export @noninteractive
type NoninteractivePlot
p::Gadfly.Plot
end
@mortenpi
mortenpi / ComposeHacks.jl
Last active Sep 21, 2015
A collection of helper macros and stuff for Julia's Compose and Gadfly packages.
View ComposeHacks.jl
# ComposeHacks module
#
# This module is a collection of hacks to make working with Compose and Gadfly
# more convenient (in Julia).
#
# The MIT License (MIT)
#
# Copyright (c) 2015 Morten Piibeleht
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
@mortenpi
mortenpi / bit.jl
Created Sep 28, 2015
Get the nth bit of a number in Julia.
View bit.jl
# Gets the Nth bit of m
function bit(N, m)
m & (1<<(N-1)) >> (N-1)
end
@show [bit(n,0) for n=1:5]
@show [bit(n,1) for n=1:5]
@show [bit(n,2) for n=1:5]
@show [bit(n,3) for n=1:5]
@show [bit(n,5) for n=1:5]
@mortenpi
mortenpi / time_lm.jl
Created Oct 3, 2015
Time a function multiple times to see how memory usage behaves.
View time_lm.jl
import Base: gc_bytes, gc_time_ns, time_print
function lm_1_10(x1, x10)
A = (x10-x1)/9
B = (10*x1-x10)/9
A,B
end
macro time_N(N, ex)
quote
@mortenpi
mortenpi / softwarecenter.css
Last active Nov 15, 2015
A better style for the Ubuntu Software Center (/usr/share/software-center/ui/gtk3/css/softwarecenter.css)
View softwarecenter.css
@define-color light-aubergine #BBBBBB;
@define-color super-light-aubergine #EDEDED;
/*
do not use text-shadow until bugzilla.gnome.org bug #686209 is
fixed - its leaking memory
*/
#featured-star {
You can’t perform that action at this time.