Skip to content

Instantly share code, notes, and snippets.

@DamianZaremba
DamianZaremba / archive_emails.py
Created December 3, 2014 19:47
Symbiosis email archiver
#!/usr/bin/env python
import os
import os.path
import time
import shutil
import glob
import email
def get_maildirs():
@DamianZaremba
DamianZaremba / c7_int_name.rb
Created July 23, 2014 19:29
CentOS 7 Interface Name Calculator for Puppet
require 'facter'
# Function to figure out old school to new school mappings
# Uses the biosdevname info to generate a mapping
module Puppet::Parser::Functions
newfunction(:c7_int_name, :type => :rvalue) do |args|
if args.length != 1
raise(Puppet::ParseError, "No interface name passed to convert")
end
int_name = args[0]
@DamianZaremba
DamianZaremba / more_sane_output.log
Last active August 29, 2015 14:02
Logstash mysql output error
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/events
java.sql.DriverManager.getConnection(java/sql/DriverManager.java:596)
java.sql.DriverManager.getConnection(java/sql/DriverManager.java:215)
java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:606)
RUBY.connect(/home/damian/Projects/tj/logstash/build/tarball/logstash-1.4.1-modified/lib/logstash/outputs/mysql.rb:101)
RUBY.flush(/home/damian/Projects/tj/logstash/build/tarball/logstash-1.4.1-modified/lib/logstash/outputs/mysql.rb:56)
RUBY.buffer_flush(/home/damian/Projects/tj/logstash/build/tarball/logstash-1.4.1-modified/vendor/bundle/jruby/1.9/gems/stud-0.0.17/lib/stud/buffer.rb:219)
org.jruby.RubyHash.each(org/jruby/RubyHash.java:1339)
RUBY.buffer_flush(/home/damian/Projects/tj/logstash/build/tarball/logstash-1.4.1-modified/vendor/bundle/jruby/1.9/gems/stud-0.0.17/lib/stud/buffer.rb:216)
@DamianZaremba
DamianZaremba / env
Last active August 29, 2015 14:01
Pip proxy issue
$ env | grep proxy
http_proxy=http://proxy:3128/
rsync_proxy=http://proxy:3128/
https_proxy=http://proxy:3128/
sftp_proxy=http://proxy:3128/
irb(main):001:0> hostname = 'puppet-03'
=> "puppet-03"
irb(main):002:0> hostname.split('-', 0)
=> ["puppet", "03"]
irb(main):003:0> hostname.split('-', 1)
=> ["puppet-03"]
irb(main):004:0> hostname.split('-', 2)
=> ["puppet", "03"]
@DamianZaremba
DamianZaremba / bad.rb
Created May 6, 2014 11:02
Broken facter plugin
# This is a horrible thing
# Kinda (mostly) figures out the server type from the hostname
Facter.add("servertype") do
setcode do
hostname = Facter.value('hostname')
if hostname.include?('-')
hostname_parts = hostname.split("-", 0)
hostname_parts[0].downcase
elsif hostname =~ /^ns/
@DamianZaremba
DamianZaremba / hiera.yaml
Last active August 29, 2015 14:01
Puppet 3.5 hiera issue
[Tue May 06 12:10:29] [root@puppet-03 facter]$cat /etc/puppet/environments/production/hiera/hiera.yaml
---
:backends: yaml
:yaml:
:datadir: "/etc/puppet/environments/%{::environment}/hiera"
:hierarchy:
- "node/%{::fqdn}" # ws-27.lhr4.****************
- "type/%{::servertype}" # TI
- "silo/%{::silo}" # lhr_xml_05
- "project/something" # project specific stuff
@DamianZaremba
DamianZaremba / fail
Created April 2, 2014 19:09 — forked from anonymous/fail
Url: http://www.carbonhire.com/[email protected]
PHP warning
mysql_connect(): Access denied for user 'geniushire'@'10.147.146.186' (using password: YES)
/var/app/current/track.php(12)
01 <?php 02 03 define('CRONJOB', TRUE); 04 include("index.php"); 05 06 $email = isset($_GET['email']) ? $_GET['email'] : ""; 07 $hash = md5("carbon".$email); 08 setcookie("guid", $hash, time() + (10 * 365 * 24 * 60 * 60), "/", "carbonhire.com"); 09 //print_r($_COOKIE); 10 header("Location: http://hastrk1.com/serve?action=click&publisher_id=59998&site_id=47256&offer_id=274954", true, 302); 11 12 $link = mysql_connect('geniushire-real-1.cbuqrrbjabbr.us-east-1.rds.amazonaws.com', 'geniushire', ';kcvGayqe05t4!?'); 13 if (!$link) { 14 die('Could not connect: ' . mysql_error()); 15 } 16 17 mysql_select_db("geniushire_real_new", $link) or die('Could not select database.');$sql = "UPDATE gh_central SET cookie_id = '".$hash."' WHERE email = '".$email."'"; 18 if($email != ""){ 19 $sql = "UPDATE gh_central SET
@DamianZaremba
DamianZaremba / youtube.com.js
Created February 21, 2014 13:38
Fix the stupid stuck header thing on youtube...
/* This file lives @ ~/.js/youtube.com.js
* Requires: https://github.com/defunkt/dotjs
*/
/* Make it not stick the header to the top of the window */
$('#masthead-positioner').css('position', 'static');
@DamianZaremba
DamianZaremba / gist:8852325
Last active August 29, 2015 13:56
Wikimedia labs snmptrap thing setup
Set check_external_commands=1 in /etc/icinga/icinga.cfg
apt-get install snmpd snmptt
cat > /etc/init.d/snmptrapd <<'EOF'
#! /bin/sh -e
### BEGIN INIT INFO
# Provides: snmptrapd
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog