Skip to content

Instantly share code, notes, and snippets.

@DamianZaremba
DamianZaremba / examplenotifier.py
Last active September 29, 2016 13:29
Very simple OpenStack Nova notifier to create/delete PowerDNS records for instances on creation/deletion.
'''
Very simple OpenStack Nova notifier to create/delete PowerDNS records for instances on creation/deletion.
Format of records is %(instance)s.%(project_name).example.com.
To use:
* Install this in a python path (site-packages is easiest)
* Configure nova using notification_driver=examplenotifier
'''
import MySQLdb
@DamianZaremba
DamianZaremba / gist:8148963
Created December 27, 2013 15:59
Multiple relays on the skpang 4ch relay board
You can switch multiple relays on the same was as single relays – it’s just a different value passed.
If you think of the relays as 1, 2, 4, 8 then it makes sense. Passing these values directly will turn on the relays singularly, something like
for relay in [1, 2, 4, 8]:
bus.write_byte_data(0×20,0×09,relay)
time.sleep(1)
will step though all the relays (this is what the test_relays script does).
If you want to switch multiple relays on, add the numbers together and use that. For example:
@DamianZaremba
DamianZaremba / index.php
Created May 31, 2013 00:34
Github Pages, Cloudflare Cache Purge
<?php
// Cloudflare settings
$CF_API_TOKEN = "";
$CF_ZONE = "";
$CF_EMAIL = "";
// API key
$AUTHORIZATION_KEY = "";
@DamianZaremba
DamianZaremba / pagination.rb
Created May 15, 2013 19:28
Hack to support paging at the root in Jekyll. Looks like paginate_path should support /:num, but that breaks my jekyll install totally. This plugin patches the built in class.
# Drop into content/_plugins/pagination.rb
# Outputs pages into /1/ /2/ /3/ /4/ etc
module Jekyll
module Generators
class Pager < Pager
def self.paginate_path(site_config, num_page)
return nil if num_page.nil? || num_page <= 1
"/%d" % num_page
end
end
@DamianZaremba
DamianZaremba / gist:5377958
Created April 13, 2013 11:04
Get Lenovo warranty status
import urllib
import urllib2
from BeautifulSoup import BeautifulSoup
url = 'http://support.lenovo.com/templatedata/Web%20Content/JSP/' \
'warrantyLookup.jsp'
data = urllib.urlencode({'sysSerial' : 'xxxxxx'})
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
@DamianZaremba
DamianZaremba / gist:5328603
Created April 7, 2013 02:22
Little stats grabber output on Ubuntu and OSX with a few values redacted from the output
{'cpu': [{'manufacturer': 'GenuineIntel',
'model': 'Intel(R) Core(TM) i7-3610QM CPU @ 2.30GHz'}],
'drives': [{'identifer': 'disk0',
'model': 'VMware Virtual S',
'size': 681574400,
'vendor': 'VMware,'}],
'interfaces': {'identifer': 'en0', 'mac-address': 'xx:xx:xx:xx:xx:x'},
'manufacturer': 'Mac',
'memory': [{'manufacturer': 'VMware Virtual RAM',
'serial': '1',
@DamianZaremba
DamianZaremba / setup_mac.sh
Last active January 15, 2020 08:19
Commands to add an OSX machine to an AD environment so users can authenticate
# Assumes the following:
# Hostname: TEST1
# Domain: EXAMPLE.COM (you probably don't want to use your public domain for your AD domain... but that's out of scope for this example)
# Admin user: setupuser
# Admin pass: He11oW0rld!
# Machine will go into the default computers ou (root)
# Domain admins will get local admin rights on login
# All users will get mobile accounts (offline login)
# All data will be stored locally (no UNC home dir)
# Default shell will be bash
@DamianZaremba
DamianZaremba / gist:5072759
Created March 2, 2013 19:26
Install command line tools from the command line on OSX
Damians-Mac:~ damian$ hdid xcode46cltools_10_86938131a.dmg
/dev/disk2 Apple_partition_scheme
/dev/disk2s1 Apple_partition_map
/dev/disk2s2 Apple_HFS /Volumes/Command Line Tools (Lion)
Damians-Mac:~ damian$ sudo installer -pkg /Volumes/Command\ Line\ Tools\ \(Mountain\ Lion\)/Command\ Line\ Tools\ \(Mountain\ Lion\).mpkg -target /
Damians-Mac:~ damian$ umount /Volumes/Command\ Line\ Tools\ \(Mountain\ Lion\)
@DamianZaremba
DamianZaremba / gist:4745805
Created February 9, 2013 15:55
Epic traceroute
traceroute to 216.81.59.173 (216.81.59.173), 64 hops max, 52 byte packets
1 10.44.200.254 (10.44.200.254) 5.057 ms 3.215 ms 4.460 ms
2 host-2-97-96-1.as13285.net (2.97.96.1) 95.907 ms 31.328 ms 30.944 ms
3 host-78-151-225-101.static.as13285.net (78.151.225.101) 32.417 ms 32.150 ms 32.657 ms
4 host-78-151-225-26.static.as13285.net (78.151.225.26) 33.414 ms
host-78-151-225-108.static.as13285.net (78.151.225.108) 32.723 ms
host-78-151-225-26.static.as13285.net (78.151.225.26) 33.472 ms
5 xe-11-1-0-rt001.the.as13285.net (62.24.240.6) 38.430 ms 39.111 ms
xe-11-1-0-rt001.sov.as13285.net (62.24.240.14) 39.522 ms
6 host-78-144-1-61.as13285.net (78.144.1.61) 38.020 ms
@DamianZaremba
DamianZaremba / switches2graphite.py
Created February 3, 2013 17:43
Badly written POC for snmpish switches -> graphite graphing
#!/usr/bin/env python
import time
import re
import socket
from pysnmp.entity.rfc3413.oneliner import cmdgen
cmdGen = cmdgen.CommandGenerator()
CARBON_IP = '10.44.206.51'
CARBON_PORT = 2030