Skip to content

Instantly share code, notes, and snippets.

View kelunik's full-sized avatar

Niklas Keller kelunik

View GitHub Profile
@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"
@jterrace
jterrace / xvfb
Created June 11, 2012 18:46
xvfb init script for Ubuntu
XVFB=/usr/bin/Xvfb
XVFBARGS=":1 -screen 0 1024x768x24 -ac +extension GLX +render -noreset"
PIDFILE=/var/run/xvfb.pid
case "$1" in
start)
echo -n "Starting virtual X frame buffer: Xvfb"
start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS
echo "."
;;
stop)
@neilellis
neilellis / README.md
Last active May 26, 2020 13:09
Build large maven projects quicker on OS X, this gist will ensure a ramdisk is mounted in /Volumes/ramdisk and triggers a profile that redirects output to a ram disk. It also only builds modules which have changed and their dependent modules. This is done by supplying the target directory of the ultimate artifact you are interested in.

Make sure you have a profile called quick that redefines the location of maven's output to the ramdisk. To do this ensure all of the below are in your parent POM.

<properties><my.build.directory>target</my.build.directory></properties>

<build><directory>${my.build.directory}</directory></build

<profile>
  <id>quick</id>
@aras-p
aras-p / preprocessor_fun.h
Last active April 12, 2024 17:24
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@xkr47
xkr47 / log4j.properties
Created August 29, 2013 19:02
log4j configuration with different colors for different log levels - also works with Eclipse Ansi Console: http://mihai-nita.net/2013/06/03/eclipse-plugin-ansi-in-console/
log4j.debug=false
# Default level is INFO
log4j.rootLogger=INFO,StdoutErrorFatal,StdoutWarn,StdoutInfo,StdoutDebug,StdoutTrace
# and for com.some.package.* log everything
log4j.logger.com.some.package=TRACE
log4j.appender.StdoutErrorFatal=org.apache.log4j.ConsoleAppender
log4j.appender.StdoutErrorFatal.layout=org.apache.log4j.PatternLayout
@zeekay
zeekay / say-hi.py
Last active May 19, 2017 20:58
IRC chat client in < 60 lines of code.
#!/usr/bin/env python
#
# Minimal IRC client. Compatible with Python 2 and 3.
import os, select, signal, socket, sys, time
try: username = os.getlogin()
except: username = "unknown"
hostname = socket.gethostname()
irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@tott
tott / ip_in_range.php
Created November 27, 2013 22:46
php check if IP is in given network range
/**
* Check if a given ip is in a network
* @param string $ip IP to check in IPV4 format eg. 127.0.0.1
* @param string $range IP/CIDR netmask eg. 127.0.0.0/24, also 127.0.0.1 is accepted and /32 assumed
* @return boolean true if the ip is in this range / false if not.
*/
function ip_in_range( $ip, $range ) {
if ( strpos( $range, '/' ) == false ) {
$range .= '/32';
}
@thomasfr
thomasfr / Git push deployment in 7 easy steps.md
Last active April 2, 2024 14:57
7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook
@magicznyleszek
magicznyleszek / jekyll-and-liquid.md
Last active January 12, 2024 03:46
Jekyll & Liquid Cheatsheet

Jekyll & Liquid Cheatsheet

A list of the most common functionalities in Jekyll (Liquid). You can use Jekyll with GitHub Pages, just make sure you are using the proper version.

Running

Running a local server for testing purposes:

@randomphrase
randomphrase / cmdoptions.cpp
Last active February 17, 2023 05:51
Demonstration of how to do subcommand option processing with boost program_options
#define BOOST_TEST_MODULE subcommand options
#include <boost/test/unit_test.hpp>
#include <boost/program_options.hpp>
#include <boost/variant/variant.hpp>
#include <boost/variant/get.hpp>
struct GenericOptions {
bool debug_;
};