Skip to content

Instantly share code, notes, and snippets.

View stefanbirkner's full-sized avatar

Stefan Birkner stefanbirkner

View GitHub Profile
@dspinellis
dspinellis / Makefile
Last active March 5, 2022 14:16
Add a help target for any Makefile
URL=https://www.spinellis.gr/unix
love: # Help: Create a file name love
touch love
money: # Help: Hit the jackpot
yes $$ | fmt | head
me a wizard: MOOC # Help: Become a Unix command-line wizard
@netzwerg
netzwerg / FizzBuzz.java
Created May 1, 2016 05:06
FizzBuzz in Java 8 with Javaslang
import javaslang.collection.Stream;
/**
* An implementation of https://dierk.gitbooks.io/fregegoodness/content/src/docs/asciidoc/fizzbuzz.html
* using http://www.javaslang.io
*
* @author Rahel Lüthy
*/
public class FizzBuzz {
@npryce
npryce / LoggerTest.java
Last active August 29, 2015 14:17
How to create a Log4J Logger for unit testing Java code that logs
LoggingEvent loggedEvent = null;
private Logger capturingLogger() {
return new Logger("testing") {
{
level = Level.ALL;
repository = mock(LoggerRepository.class);
when(repository.isDisabled(anyInt())).thenReturn(false);
}
@mkempka
mkempka / Manifold.java
Created May 22, 2013 11:59
A rule runs a test case many times in parallel. Can be used for load tests. If more than one of the parallel executions fails, only the first fail is reported. Example: To run each test method in the class 5 times, add @rule public Manifold runParallel = new Manifold(5); to the class
import java.util.concurrent.CountDownLatch;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
/**
* A rule runs each test case many times in parallel. Can be used for load tests. If more than one
* of the parallel executions fails, only the first fail is reported. Example: To run each test
* method in the class 5 times, add <code> @Rule
@napcs
napcs / video.md
Created September 8, 2012 16:25
Video project

Intro to Programming video

I want to make a video to show my class of would-be IT people. If you write code, would you send me a video clip (webcam, less than 30s) with the following?

  • Introduce yourself (name, where you work)
  • Why you love what you do
  • Why you love open-source software (optional, but would be super helpful)

Email the clip (or a link I can download the clip) to bphogan at gmail and be sure to include your Twitter username so I can add that on your clip.

@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@rcrowley
rcrowley / oracle-jdk-deb.sh
Created April 12, 2012 00:20
Oracle JDK Debian packaging
VERSION="6u31-b04"
BUILD="betable4"
set -e -x
# Keep track of the original working directory.
OLDESTPWD="$PWD"
# Work in a temporary directory.
cd "$(mktemp -d)"
@haf
haf / bash
Created January 3, 2012 16:11
Installing graphite Ubuntu 11.10
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 10/13/2011
####################################
sudo apt-get update
sudo apt-get upgrade
@alexaivars
alexaivars / fabfile.py
Created November 1, 2011 13:27
Use fabric with a vagrant instance
from fabric.api import env, local, run
def vagrant():
# change from the default user to 'vagrant'
env.user = 'vagrant'
# connect to the port-forwarded ssh
env.hosts = ['127.0.0.1:2222']
# use vagrant ssh key
result = local('vagrant ssh_config | grep IdentityFile', capture=True)
@iamnoah
iamnoah / index.js
Created December 1, 2009 23:56
Simple node.js webserver with logging. Serves whatever files are reachable from the directory where node is running.
/*
* Copyright (c) 2010 Noah Sloan <http://noahsloan.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*