Skip to content

Instantly share code, notes, and snippets.

@melkorm
melkorm / post-receive.md
Last active July 2, 2020 11:19
GIT: Pre receive hook to prevent pushing unresolved conflicts
#!/usr/bin/env bash
read old_sha new_sha refname

# if we delete branch don't do anything
if [[ "$new_sha" =~ ^0+$ ]]; then
   exit 0
fi

# if we push new branch we need to set correct old_sha
#!/usr/bin/env python
'''
Change Facebook test users password
'''
import urllib, urllib2, json
# makes a batch call to facebook
# access_token : facebook access token
@melkorm
melkorm / gist:9ca23cb366d439e47e11
Last active August 29, 2015 14:05
Solaris services managment
sudo svcs | grep service
sudo svcadm start|restart|stop serviceName
if service is in maintenance status use:
svcadm clear serviceName
@melkorm
melkorm / RegexTester.java
Created August 28, 2014 12:11
Java RegEx testing class
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
public class RegexTester {
public static void main(String[] arguments) {
String userInputPattern = arguments[0];
System.err.println(userInputPattern);
String userInputText = arguments[1];
System.err.println(userInputText);
try {
@melkorm
melkorm / gist:b17ad09643370e7960ec
Last active August 29, 2015 14:07
Graylog2 with Vagrant & PuPHPet
# Graylog2
class { 'graylog2::repo':
version => '0.21'
} ->
class { 'graylog2::server':
password_secret => '16BKgz0Qelg6eFeJYh8lc4hWU1jJJmAgHlPEx6qkB16BKgz0Qelg6eFeJYh8lc4hWU1jJJmAgHlPEx6qkB', // needs to be atleast 64 chars long
root_password_sha2 => '8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918',
elasticsearch_cluster_name => 'graylog2',
elasticsearch_discovery_zen_ping_multicast_enabled => false,
elasticsearch_discovery_zen_ping_unicast_hosts => '127.0.0.1:9301',
@melkorm
melkorm / gist:9d3e3be7490d0f3c827e
Last active August 29, 2015 14:07
Sync all remote branches with other origin repository
#!/bin/sh
branches=`git branch -r`
for i in ${branches}; do
echo `git checkout -t $i`
done
echo `git push -u bitbucket --all`
@melkorm
melkorm / cleanup.sh
Last active August 29, 2015 14:07
Remove all merged remote branches except dev and master
#!/usr/bin/env bash
branches=`git branch -r --merged | grep -v 'dev\|master' | sed 's/origin\///g'`
for i in $branches ; do
echo "Delete branch $i? (y/N)"
read delete
if [ $delete == 'y' ]; then
echo `git push origin :$i`
fi
done
@melkorm
melkorm / gitconfig
Last active October 21, 2015 08:29
Power GIT config
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
lnc = log --pretty=format:"%h\\ %s\\ [%cn]"
lds = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
ld = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative
le = log --oneline --decorate
filelog = log -u
fl = log -u
lasttag = describe --tags --abbrev=0
lt = describe --tags --abbrev=0
@melkorm
melkorm / cleanup_local.sh
Created October 21, 2014 12:17
[GIT] Cleanup local branches
#!/usr/bin/env bash
branches=`git branch | grep -v 'dev\|master' | sed 's/origin\///g'`
for i in $branches ; do
echo "Delete branch $i? (y/N)"
read delete
if [ $delete == 'y' ]; then
echo `git br -D $i`
fi
done
@melkorm
melkorm / find-and-copy
Created November 26, 2014 12:48
Find & gzip files
find . -type f -print0 | tar -czvf backup.tar.gz --null -T -