Skip to content

Instantly share code, notes, and snippets.

@perifer
perifer / pre-push
Created December 29, 2022 12:42
Branching policy
#!/usr/bin/env bash
LC_ALL=C
local_branch="$(git rev-parse --abbrev-ref HEAD)"
valid_branch_regex="^(feature|bugfix|release|hotfix|archive)\/[a-z0-9._-]+$"
message="There is something wrong with your branch name. Branch names in this project must adhere to this contract: $valid_branch_regex. You should rename your branch to a valid name and try again."
if [[ ! $local_branch =~ $valid_branch_regex ]]
@perifer
perifer / bitbucket-origin-all.sh
Created October 22, 2013 06:12
Change the origin remote url from github to bitbucket for all git repos inside the current folder and 3 levels down
# Change the origin remote url from github to bitbucket
# for all git repos inside the current folder and 3 levels down
CURRENT=`pwd`
for DIR in $(find . -name ".git" -type d -maxdepth 3)
do
cd "$DIR"
cd ..
OLDORIGIN=`git config --get remote.origin.url`
@perifer
perifer / gist:5488903
Last active December 16, 2015 19:59
go keys

go keys

security feautures

Each client holds a secret. The secret is used as passphrase for the keys (or only one key?) on the master.

The secret is also used to create a hmac that validates that the data stored in db.json has not been tampered with. This is done by created an hmac of the data in db.json and the secret. The hmac is saved in db.json alongside with the data. Next requset to the server from a client the hmac is recreated and matched against the stored hmac to verify that the data is not changed.

go keys

go keys server

go keys server add NAME --user SERVER_USER --hostname HOSTNAME --url SERVER_URL --tags "TAG1,TAG2,TAG3" --repo REPO_URL --description "A DESCRIPTION" (other options)

--tags: coma or space seperated

go keys server edit (same options as add)

@perifer
perifer / track.js
Created March 2, 2013 08:27
Track virtual page views in Google Analytics if (window._gaq) { window._gaq.push(['_trackPageview', window.location.pathname + href]); }
if (window._gaq) {
window._gaq.push(['_trackPageview', href]);
}
@perifer
perifer / gist:3952349
Created October 25, 2012 12:42
Improved web font loader code to prevent FOUT
// Custom web font loader inspired by the TypeKit loader.
WebFontConfig = {
fontdeck: {
id: FONTDECK_ID
},
active: function() {
clearTimeout(this._timeout);
}
};
(function() {
@perifer
perifer / ckedit.make
Created July 9, 2012 13:54
Drupal make file for ckeditor/wysiwyg
; Wysiwyg make file. Specify core version below.
; Place in Drupal root and run from the drupal
; root directory with
; drush make ckedit.make --no-core .
core = 6.x
;core = 7.x
api = 2
@perifer
perifer / aliases.drushrc.php
Created March 1, 2012 13:03
Automatic drush aliases from git remotes.
<?php
/**
* Place this file in e.g ~/.drush.
* See `drush topic docs-aliases` for more info.
*/
// Use require_once since this file is invoked multiple times.
require_once('git_remote_alias.php');
git_remote_alias_set('live', $aliases);
git_remote_alias_set('staging', $aliases);
@perifer
perifer / gist:1668761
Created January 24, 2012 07:59
Track events on external pages - asynchronous Google Analytics
(function($) {
var passThrough = false;
var track = function(el, action) {
_gaq.push(["_trackEvent", "Connect/Log in", action]);
passThrough = true;
_gaq.push(function() {
$(el).trigger("click");
});
import os
import re
from fabric.api import *
from urlparse import urlparse
def task(project):
try:
# User can set their project directory with
# export PROJECT_DIR= in their shell