Skip to content

Instantly share code, notes, and snippets.

View timonv's full-sized avatar
🚀

Timon Vonk timonv

🚀
View GitHub Profile
@timonv
timonv / .zshrc
Created September 11, 2017 14:35
function weather() {
LOC=${1:-Amsterdam}
curl "nl.wttr.in/~$LOC"
}
import Ember from 'ember';
import DropdownNavigationMixin from 'salonized/mixins/dropdown-navigation';
const { Component, computed } = Ember;
export default Component.extend(DropdownNavigationMixin, {
classNames: ['sz-select', 'dropdown'],
classNameBindings: ['withAvatar:sz-select-avatar'],
attributeBindings: ['data-name'],
items: null,
# Benchmark of several http clients on the api
#
require 'net/http'
require 'typhoeus'
require 'curb'
URL = "https://nltk.tolq.com/split"
POST_DATA = File.open("test_data/simple.json", &:read)
HEADERS = { 'Content-Type': 'application/json' }
class Server < Sinatra::Base
enable :loggin
use Appsignal::Rack::Listener
use Appsignal::Rack::SinatraInstrumentation
CREATE FUNCTION create_tr_sequence_for_ca() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
execute format('create sequence tr_seq_%s', NEW.id);
RETURN NEW;
END
$$;
CREATE TRIGGER create_tr_sequence_for_ca AFTER INSERT ON client_accounts FOR EACH ROW EXECUTE PROCEDURE create_tr_sequence_for_ca();
@timonv
timonv / .zshrc
Last active February 4, 2016 22:30
A zsh function that allows easy switching to or creating of named tmux sessions with auto completion
# c short for context
function c() {
if [ -n "$1" ]; then
local SESSION=$(tmux list-sessions | awk '{ print $1 }' | grep $1)
fi
# If no arguments, list sessions
if [ -z "$1" ]; then
tmux list-sessions
# If not in tmux, but session exists; attach
elif [ -z "$TMUX" ] && [ -n "$SESSION" ]; then
function c() {
if [[ -n $(tmux list-sessions | awk '{print $1}' | grep $1) ]]; then
tmux switch-client -t $1
elif [[ -n $TMUX ]]; then
tmux switch-client -t "$(TMUX= tmux -S "${TMUX%,*,*}" new-session -dPs "$1")"
else
tmux new-session -s "$1"
fi
}
query = from workout in Workout,
where: workout.id == ^id,
left_join: group in assoc(workout, :workout_set_groups),
left_join: set in assoc(group, :workout_sets),
join: excercise in assoc(group, :excercise),
preload: [workout_set_groups: {group, excercise: excercise, workout_sets: set}]
@timonv
timonv / run.rs
Last active November 5, 2015 08:17
use std::process::{Command, Child};
pub fn run() -> Result<Child> {
let child = try!(Command::new("echo").arg("world").spawn());
Ok(child)
}
#[cfg(test)]
mod test {
require 'memoist'
require 'benchmark'
class Normal
def value
1000.times do |i|
123.45 * 3323.2 / i + 1
end
end