Skip to content

Instantly share code, notes, and snippets.

View Larusso's full-sized avatar
🍪
Ohmnomnom

Manfred Endres Larusso

🍪
Ohmnomnom
  • Wooga
  • Berlin
View GitHub Profile
@Larusso
Larusso / gist:4750678
Last active December 12, 2015 09:19
Simple alias to turn git submodule change tracking to ignore all
[alias]
submodule-ignore-on = submodule -q foreach 'git config --file $toplevel/.gitmodules submodule.$name.ignore "all"'
submodule-ignore-off = submodule -q foreach 'git config --file $toplevel/.gitmodules --unset submodule.$name.ignore'
#include "objc_id.hpp"
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSString *s1 = @"hello";
NSString *s2 = [@"hell" stringByAppendingString: @"o"];
if ((objc_id(s1) == objc_id(s2))) {
NSLog(@"win");
@Larusso
Larusso / gist:5892640
Last active December 19, 2015 03:48
Pack and unpack function arguments in python
#!/usr/bin/python
#coding: utf-8
def _test_a(*args, **kvargs):
if args:
_test_function(*args)
else if kvargs:
_test_function(**kvargs)
@Larusso
Larusso / Output latest git commit hash by user
Last active December 21, 2015 19:09
this little alias will output the last commit hash committed by the current git user usage: git last-commit // will output the last commit hash in current branch git last-commit --all // will output the last commit hash in repository
git config --global alias.last-commit '!sh -c "git log -1 --pretty=tformat:\"%H\" --author=\"`git config user.name`\" $*"' -
@Larusso
Larusso / Image2Map.py
Created September 11, 2013 16:18 — forked from bjorn/Image2Map.py
# Filename : Image2Map.py
# Authors : Georg Muntingh and Bjorn Lindeijer
# Version : 1.2
# Date : June 16, 2010
# Copyright : Public Domain
import os, sys, Image, networkx
class TileMap:
""" This class represents a map of tiles.
@Larusso
Larusso / git clone-fork
Created April 17, 2014 21:43
Clone a fork of a repository and setup the upstream remotes to follow the upstream repository.
git config --global alias.clone-fork '!sh -c "[ $# = 3 ] && git clone $1 $3 && cd $3 && git remote add upstream $2 && git fetch upstream && git checkout -b upstream_master --track upstream/master && git co @{-1} && exit 0 || echo \"usage: git clone-fork <fork-repository> <upstream-repository> <directory>\" >&2 && exit 1 "' -
@Larusso
Larusso / git-reset-pattern
Last active August 29, 2015 14:00
git reset with pattern
e()
{
echo $1 | grep -E $2 | grep -E '(^M\s|^D\s|^R\s)' | cut -c 3-;
}
f()
{
git st --porcelain | while read line
do
file=$(e "$line" $1)
@Larusso
Larusso / color-text-table.rb
Created February 4, 2015 11:31
Monkeypatch for text-table to support ANSI colors
require 'colorize'
module Text
class Table
class Cell
def initialize(options = {}) #:nodoc:
@value = options[:value].to_s
@row = options[:row]
@align = options[:align ] || :left
@colspan = options[:colspan] || 1
[alias]
ci = commit
st = status
co = checkout
lg = !"git lg1"
graph = !"git lg"
lg1 = !sh -c \"git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' $*\"
lg2 = !sh -c \"git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' $*\"
lg3 = !sh -c \"git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)' $*\"
@Larusso
Larusso / jenkins_list_jobs_with_parameter_name.groovy
Last active September 8, 2016 08:33
Jenkins script that list all parameterized jobs with given parameter.
import hudson.model.*
parameter_name = "DEVELOPER_DIR"
allItems = Hudson.instance.items
allItems.each { job ->
prop = job.getProperty(ParametersDefinitionProperty.class)
if(prop != null) {
allDefinitions = prop.getParameterDefinitions()
filteredDefinitions = allDefinitions.findAll {definition -> definition.name != parameter_name}