Skip to content

Instantly share code, notes, and snippets.

@koraktor
koraktor / git-create-empty-branch.sh
Created March 26, 2009 08:04
Git: Creating an empty branch
git stash # Stash changes if any
git symbolic-ref HEAD refs/heads/${NEW_BRANCH} # Change head to a new, non-existing ref
git rm -rf . # Delete files from version control and working directory
rm -r . # Delete files from file system
git commit --allow-empty -m "Created new branch ${NEW_BRANCH}" # Commit changes in the new branch
@koraktor
koraktor / host.rb
Created April 15, 2009 13:49
ActiveRecord: Saving IPs as 32bit signed integers
require 'converts_addresses'
class Host < ActiveRecord::Base
belongs_to :subnet
converts_addresses :ip
validates_presence_of :ip
validates_uniqueness_of :ip
@koraktor
koraktor / playerTable.php
Created August 16, 2009 10:16
Generating a HTML table for player data aquired using Steam Condenser
<?php
// Be sure that the path is correct
require_once "/path/to/steam-condenser/lib/steam-condenser.php";
// Add your server's IP address here ...
$ipAddress = new InetAddress("x.x.x.x");
// ... and port number here
$portNumber = yyyyy;
$server = new GoldSrcServer($ipAddress, $portNumber);
@koraktor
koraktor / generate-changelog.sh
Created December 17, 2009 15:22
Generating a changelog from Git history
#!/bin/bash
#
# This code is free software; you can redistribute it and/or modify it under the
# terms of the new BSD License.
#
# Copyright (c) 2009, Sebastian Staudt
#
# This script takes all Git tags and displays them in a nicely ordered list with
# all changes between tags.
# If you do version bumping inside your code (e.g. Rakefile, pom.xml or
@koraktor
koraktor / brew install -vd imagemagick
Created May 11, 2010 12:39
brew install output: ImageMagick 6.6.1-5
==> Build Environment
CC: /usr/bin/cc
CXX: /usr/bin/c++
LD: /usr/bin/cc
CFLAGS: -O3 -march=core2 -msse4.1 -w -pipe
CXXFLAGS: -O3 -march=core2 -msse4.1 -w -pipe
MAKEFLAGS: -j2
PATH: /opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
==> Downloading http://image_magick.veidrodis.com/image_magick/ImageMagick-6.6.1-5.tar.bz2
File already downloaded and cached to /Users/koraktor/Library/Caches/Homebrew
@koraktor
koraktor / git.nanorc
Created August 15, 2010 08:31
A nano configuration file to enable Git syntax highlighting
# This code is free software; you can redistribute it and/or modify it under
# the terms of the new BSD License.
#
# Copyright (c) 2010, Sebastian Staudt
# A nano configuration file to enable syntax highlighting of some Git specific
# files with the GNU nano text editor (http://www.nano-editor.org)
#
# Save this file to a directory of your choice and add it to your nanorc using
# include ${PATH_TO_THE_FILE}/git.nanorc
@koraktor
koraktor / gist:527016
Created August 16, 2010 14:21
Using a Git hook for continuous integration
#!/bin/sh
#
# This code is free software; you can redistribute it and/or modify it under
# the terms of the new BSD License.
#
# Copyright (c) 2010, Sebastian Staudt
#
# This is a simple example to demonstrate continuous integration on top of
# Git.
#
@koraktor
koraktor / gist:587533
Created September 20, 2010 07:23
YARD question: Documenting multiple attr_reader
# This works:
# @return [String] This is attribute #1
attr_reader :attr1
# @return [Object] This is attribute #2
attr_reader :attr2
# But this won't:
@koraktor
koraktor / gist:607502
Created October 2, 2010 09:51
Sample hooks for using Git as a backup tool
#!/bin/sh
#
# This code is free software; you can redistribute it and/or modify it under
# the terms of the new BSD License.
#
# Copyright (c) 2010, Sebastian Staudt
#
# This is a demonstration hook that can be used to automatically update a
# backup repository.
#
@koraktor
koraktor / Output:
Created October 13, 2010 08:29
This demonstrates how to call constructors of multiple included modules in Ruby
Hello World!
The weather is nice!
See you soon.