Skip to content

Instantly share code, notes, and snippets.

@samuelsmal
samuelsmal / pomodoro.sh
Created December 3, 2014 14:40
command line pomodoro timer
#!/bin/bash
while true; do
sleep 1500 && notify-send "break"; sleep 300 && notify-send "back to work";
done
@samuelsmal
samuelsmal / runge_kutta.nb
Last active August 29, 2015 14:18
Mathematica Runge-Kutta
(* One step Runge-Kutta *)
(* fn : Definition of the function *)
(* init : List of initial values, dimensions have to agree with the input of fn *)
(* step : Step size for the numerical simulation *)
(* Usage: *)
(* One step: *)
(* RungeKutta[{#[[2]], #[[1]]^2 - 2#[[2]]}&,{.1, -.5}, .1] *)
(* Multiple steps: *)
(* NestList[RungeKutta[{#[[2]], #[[1]]^2 - 2#[[2]]}&, #, 0.1]& , {.1, -.5}, 5] *)
@samuelsmal
samuelsmal / goldenratio.variables.scss
Created September 22, 2015 12:03
A list of golden ration variables. Based upon gld.chadlindemann.com
$golden: 1.618;
$base: 100%;
$gld10: $base / $golden;
$gld9: $base - $gld10;
$gld8: $gld9 / $golden;
$gld7: $gld9 - $gld8;
$gld6: $gld7 / $golden;
$gld5: $gld7 - $gld6;
$gld4: $gld5 / $golden;
$gld3: $gld5 - $gld4;
@samuelsmal
samuelsmal / api-version-comparator.js
Created October 12, 2015 09:00
Javascript API Version comparator function
/**
* Compares two given API version strings in base 10. Only numbers separated by a dot (".") are supported.
* It compares lhs < rhs and returns the default UNIX comparison identifier:
*
* if lhs < rhs
* return -1
* else if lhs > rhs
* return 1
* else
* return 0
@samuelsmal
samuelsmal / partial.directive.js
Last active January 13, 2016 16:02
Angular partial directive (Rails partial equivalent)
/* global angular: false */
;(function () {
'use strict'
/**
* sam-partial directive
*
* This is simple *partial* directive. It functions the same as `ng-include`
* but instead of nesting it replaces the element.
@samuelsmal
samuelsmal / sam-on-enter.directive.js
Created January 14, 2016 10:21
onEnter angular directive
/* global angular: false */
(function () {
'use strict'
angular
.module('sam.utils')
.directive('onEnter', onEnter)
function onEnter () {
@samuelsmal
samuelsmal / edn-to-csv.clj
Created April 6, 2016 08:20
Clojure script to extract some fields from a edn-file and store it as a CSV file
#!/usr/bin/env boot
(require '[clojure.java.io :as io])
(require '[clojure.edn :as edn])
(def fname "/path/to/clojure-edn.clj")
(def ofname "/path/to/out.csv")
;; out-format:
;; "keykeykey", "valvalval"
@samuelsmal
samuelsmal / scala-reading-list.md
Last active June 22, 2016 09:09
Introduction to the world of Scala

As I just begun reading and learning Scala somethings might be outdated. If that is so, please leave a comment below. The order reflects the importance - or just my way of learning a new language.

Basically it is: overview, syntax, some usage, pitfalls, best practices.

@samuelsmal
samuelsmal / point_colour_access.h
Created July 23, 2016 13:06
accessing the colour information of a point in the point cloud library
// p is a point
const auto pv = p.getVector3fMap();
const uint32_t rgb = *reinterpret_cast<const int*>(&p.rgb);
int r = int((rgb >> 16) & 0x0000ff);
int g = int((rgb >> 8) & 0x0000ff);
int b = int((rgb) & 0x0000ff);
@samuelsmal
samuelsmal / gist:185d0c6b027c3d24b47a892f062cb9bc
Created July 25, 2016 21:26
jupyter notebook saving hook
import os
from subprocess import check_call
c = get_config()
def post_save(model, os_path, contents_manager):
"""post-save hook for converting notebooks to .py scripts"""
if model['type'] != 'notebook':
return # only do this for notebooks
d, fname = os.path.split(os_path)