Skip to content

Instantly share code, notes, and snippets.

@evilchili
evilchili / gist:1848087
Created February 16, 2012 21:42
invoke a downstream jenkins job with the current job parameters + additions
import hudson.model.*
// extract the version tag from the console log
def version_pattern = ".*\\[\\s*INFO\\s*\\]\\s+VERSION=(.*)\\s*\$"
def matcher = manager.getLogMatcher( version_pattern )
if ( matcher?.matches() ) {
// add the version string to the job summary
def ver = matcher.group(1)
manager.addInfoBadge( "Version: $ver" )
@evilchili
evilchili / .vimrc
Created June 4, 2012 15:28
sample .vimrc config for supertabcompletion
set ofu=syntaxcomplete#Complete
" remap completion to control+space
inoremap <expr> <C-Space> pumvisible() \|\| &omnifunc == '' ?
\ "\<lt>C-n>" :
@evilchili
evilchili / postfix_blackhole.sh
Last active October 12, 2018 23:50
blackhole all mail except for one domain using postfix
# define a transport for mail you want to deliver
echo "$VALID_DOMAIN smtp:[$VALID_RELAYHOST]" > /etc/postfix/transport
postconf -e transport_maps = hash:/etc/postfix/transport
# everything else goes to a bogus relayhost, which causes a bounce
postconf -e relayhost = 169.254.0.0
# immediately throw away all bounces
postconf -e maximal_queue_lifetime = 0
postconf -e bounce_queue_lifetime = 0
@evilchili
evilchili / scriptmerge.php.diff
Created November 30, 2012 19:54
patch to fix plugins/system/scriptmerge/scriptmerge.php
--- scriptmerge.php.dist 2012-11-30 11:52:31.000000000 -0800
+++ scriptmerge.php 2012-11-30 11:49:07.000000000 -0800
@@ -300,7 +300,7 @@
$cacheExpireFile = $cachePath.'_expire';
// Check the cache
- if(true || ScriptMergeHelper::hasExpired($cacheExpire, $cachePath)) {
+ if( ScriptMergeHelper::hasExpired($cacheExpireFile, $cachePath)) {
$buffer = null;
--- opencart.php 2013-01-24 09:15:54.000000000 -0800
+++ /tmp/opencart.php 2013-01-24 09:16:53.000000000 -0800
@@ -115,6 +115,7 @@
if (!$setting['serialized']) {
self::$config->set($setting['key'], $setting['value']);
} else {
+ $setting['value'] = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $setting['value'] );
self::$config->set($setting['key'], unserialize( $setting['value'] ) );
}
}
@evilchili
evilchili / delete_oldest_dirs.sh
Created March 22, 2013 17:00
Deleted the N oldest directories in the current directory
#!/usr/bin/env bash
# find . -maxdepth 1 -type d -printf '%T@ %p\0'
# -- For every directory in the current directory, print a numeric timestamp, a space, the filename, and a null
#
# sort -z -n
# -- Split the output on nulls (-z) and sort numerically (-n)
#
# gawk 'BEGIN {RS="\0";ORS="\0";FS=" "} NR<=3 {print $2}' | \
# -- Print first (ie, oldest) three filenames in the list, separated by nulls.
#
@evilchili
evilchili / pwdhash.sh
Created August 27, 2013 21:58
Trying to extract a PBKDF2-HMAC-SHA1 from user plist on mountain lion; failing. What am I missing?
#!/bin/sh
USER=$1
# get the shadow hash from the user entry
dscl . read /Users/$USER dsAttrTypeNative:ShadowHashData | tail -1 \
# remove everything but hex data and spaces
| tr -dc '0-9a-f ' \
sh-3.2# puppet resource x_user fnord ensure=present
2013-08-28 09:36:12.919 ruby[73195:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff92f37b06 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff99da73f0 objc_exception_throw + 43
2 CoreFoundation 0x00007fff92eea117 -[__NSPlaceholderArray initWithObjects:count:] + 119
3 RubyCocoa 0x0000000105697f2c set_octypes_for_format_str + 1900
4 RubyCocoa 0x0000000105696163 rbobj_to_nsobj + 595
5 RubyCocoa 0x0000000105696648 rbobj_to_ocdata + 328
@evilchili
evilchili / logstash-emitter.conf
Created October 18, 2013 19:08
logstash emitter config for jenkins server logs
input {
file {
path => "/var/log/jenkins/*"
type => "jenkins-server"
start_position => "beginning"
}
}
# The first filter munges the logs into discrete events.
filter {
@evilchili
evilchili / models.py
Created October 30, 2013 19:24
monkeypatching pagemanager.published to honor protected assets' users/groups
from copy import deepcopy
from django.db import models
from django.db.models import Q
from mezzanine.pages.models import Page
from mezzanine.core.models import RichText
from django.contrib.auth.models import Group, User
from mezzanine.pages.managers import PageManager
from django.utils.timezone import now
from django.conf import settings
from django.contrib.contenttypes.models import ContentType