Skip to content

Instantly share code, notes, and snippets.

View snaewe's full-sized avatar

Stefan Naewe snaewe

  • Planet Earth (UTC+2)
View GitHub Profile
[alias]
wip = !"git add -A; git ls-files --deleted -z | xargs -0 git rm; git commit -m \"wip\""
unwip = !"git log -n 1 | grep -q -c wip && git reset HEAD~1"
rb = !"git wip;git rebase -i origin/master;git unwip"
pr = !"git fetch;git wip;git rebase --stat origin;git unwip;git heads"
head = !"git log -n1"
lost = !"git fsck | awk '/dangling commit/ {print $3}' | git show --format='SHA1: %C(yellow)%h%Creset %f' --stdin | awk '/SHA1/ {sub(\"SHA1: \", \"\"); print}'"
heads = !"git log origin/master.. --format='%Cred%h%Creset;%C(yellow)%an%Creset;%H;%Cblue%f%Creset' | git name-rev --stdin --always --name-only | column -t -s';'"
#include "library_mismatch.hpp"
BOOST_USE_LIBRARY_VERSION(foo,FEATURES2)
int foo() {}
@kennethreitz
kennethreitz / sync.py
Created October 10, 2010 19:08
GitHub Syncer. Clones or Pulls all GitHub repos (including watched list).
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Kenneth Reitz's GitHub Syncer
This script uses the GitHub API to get a list of all forked, mirrored, public, and
private repos in your GitHub account. If the repo already exists locally, it will
update it via git-pull. Otherwise, it will properly clone the repo.
It will organize your repos into the following directory structure:
@mausch
mausch / git-shallow-submodule.sh
Created November 18, 2010 17:10
Shallow-cloned submodules in git
#!/bin/bash
# Idea from http://stackoverflow.com/questions/2144406/git-shallow-submodules
git submodule init
for i in $(git submodule | sed -e 's/.* //'); do
spath=$(git config -f .gitmodules --get submodule.$i.path)
surl=$(git config -f .gitmodules --get submodule.$i.url)
git clone --depth 1 $surl $spath
done
git submodule update
@lentil
lentil / gist:810399
Created February 3, 2011 22:55
PEP8 pre-commit hook in Python
#!/usr/bin/env python
from __future__ import with_statement
import os
import re
import shutil
import subprocess
import sys
import tempfile
@aalvarado
aalvarado / reabase-on-upstream
Created September 29, 2011 16:39
bashscript for rebasing on upstream master.
#!/bin/sh
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
current_branch=$(parse_git_branch)
if [[ -n "$current_branch" ]]; then
git fetch -v upstream
git checkout master
@adnbr
adnbr / counting-millis.c
Created April 21, 2012 19:01
Counting the passing of milliseconds using Timer1 on AVR.
/* Counting Milliseconds with Timer1
* ---------------------------------
* For more information see
* http://www.adnbr.co.uk/articles/counting-milliseconds
*
* 620 bytes - ATmega168 - 16MHz
*/
// 16MHz Clock
#define F_CPU 16000000UL
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@jonas
jonas / progresstinate.sh
Created October 24, 2012 15:31
Show progress spinner based on chatty commands
# Usage:
# progresstinate "Building $SERVER_WAR" \
# mvn clean install
progresstinate() {
msg="$1"; shift; args="$@"; symbol="-"
printf "$msg [$symbol]"
"$@" | while read line; do
symbol="$(echo "$symbol" | tr -- '-/|\\' '/|\\-')"
printf "\b\b$symbol]"
done
@felipec
felipec / autogroups
Last active November 22, 2020 04:02
Display a list of all the processes listed by their autogroup (CONFIG_SCHED_AUTOGROUP)
#!/usr/bin/env ruby
$autogroups = Hash.new { |h,k| h[k] = [] }
Dir.glob('/proc/*').each do |e|
pid = File.basename(e).to_i
next if pid == 0
begin
cmdline = File.read(e + '/cmdline').split("\0").join(" ")
next if cmdline.empty?