Skip to content

Instantly share code, notes, and snippets.

from django.db import models
class DeviceA(object):
def do_something(self, string='Hello'):
print "Device A something '%s'" % string
def do_something_else(self):
print "Device A something else"
ALTER TABLE reports ADD FOREIGN KEY (revertid) REFERENCES vandalism(id) on delete CASCADE
import re
def valid_nick(nick):
# We have to start with A-}
if not re.match('^[\101-\173]', nick):
return False
# We can only contain A-}, 0-9 and -
if not re.match('^[\101-\1730-9\-]+$', nick):
return False
remove_action('rss_head', 'the_generator');
remove_action('rss2_head', 'the_generator');
remove_action('commentsrss2_head', 'the_generator');
remove_action('rdf_header', 'the_generator');
remove_action('atom_head', 'the_generator');
remove_action('comments_atom_head', 'the_generator');
remove_action('opml_head', 'the_generator');
remove_action('app_head', 'the_generator');
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_generator');
@DamianZaremba
DamianZaremba / cloudflare_ranges.py
Created August 12, 2012 21:21
Get the current cloudflare ip ranges
#!/usr/bin/python
import urllib2
from BeautifulSoup import BeautifulSoup
if __name__ == "__main__":
try:
response = urllib2.urlopen("https://www.cloudflare.com/wiki/index.php"\
"?title=What_are_the_CloudFlare_IP_address"\
"_ranges&action=render")
except urllib2.HTTPError, e:
@DamianZaremba
DamianZaremba / mysql.rb
Created July 26, 2012 13:06
Facter MySQL version module
Facter.add(:mysql_version) do
setcode do
Facter::Util::Resolution.exec('mysql --version').chomp.split(' ')[4].gsub(',', '')
end
end
@DamianZaremba
DamianZaremba / static_backend.pl
Created July 18, 2012 00:03
Static perl based backend for PDNS
#!/usr/bin/perl
# Restrict unsafe constructs
use strict;
# Config bits
my $hostmaster = 'hostmaster.uk-noc.com';
my $auth_server = 'dns.uk-noc.com';
my $serial = '2012071800';
my @target_ips = (
@DamianZaremba
DamianZaremba / install_sublime_text.sh
Last active May 25, 2021 21:01
Install sublime text on linux
cd /usr/src/
wget http://c758482.r82.cf2.rackcdn.com/sublime-text_build-3047_i386.deb
dpkg -i sublime-text_build-3047_i386.deb
@DamianZaremba
DamianZaremba / decompile.py
Created June 22, 2012 09:54
Horrid depython.com client
#!/usr/bin/env python
import os
import sys
import requests
from BeautifulSoup import BeautifulSoup
try:
file_path = sys.argv[1]
except:
print "Usage: %s <file path>" % sys.argv[0]
%define with_gtk2 %{?_with_gtk2: 1} %{!?_with_gtk2: 0}
%bcond_with ocf
# it seems there is no usable tcmalloc rpm for x86_64; parts of
# google-perftools don't compile on x86_64, and apparently the
# decision was to not build the package at all, even if tcmalloc
# itself would have worked just fine.
%bcond_with tcmalloc
%if ! (0%{?fedora} > 12 || 0%{?rhel} > 5)