Skip to content

Instantly share code, notes, and snippets.

@jdembowski
jdembowski / bulk-enforcement.py
Last active August 1, 2018 17:19
Enforcement API excercise
#!/usr/bin/python
# This will need the investigate module installed via 'pip install investigate'
import investigate, json, fileinput, codecs, sys, os, requests, time, re
def slice(l, n):
n = max(1, n)
return [l[i:i + n] for i in range(0, len(l), n)]
# Read key, single line
with open('api-key.txt', 'r') as k:
@jdembowski
jdembowski / list-domains.py
Last active October 25, 2017 01:19
Read all the domains in an Umbrella Enforcement API integration
#!/usr/bin/python
import urllib2, json, fileinput, sys, os, time
from datetime import datetime
from time import gmtime, strftime
# Read key, single line
with open('api-key.txt', 'r') as k:
api_key = k.read().rstrip()
#!/usr/bin/python
# This will need the investigate module installed via 'pip install investigate'
import investigate, json, fileinput, codecs, sys, os, requests, time, re
def slice(l, n):
n = max(1, n)
return [l[i:i + n] for i in range(0, len(l), n)]
# Read key, single line
with open('api-key.txt', 'r') as k:
#!/usr/bin/python
# This will need the investigate module installed via 'pip install investigate'
import investigate, time, json, fileinput, codecs, sys, os
def slice(l, n):
n = max(1, n)
return [l[i:i + n] for i in range(0, len(l), n)]
#!/usr/bin/python
import os, sys, json
from time import sleep
from urllib2 import Request, urlopen, URLError, HTTPError
# From https://stackoverflow.com/questions/3462784/check-if-a-string-matches-an-ip-address-pattern-in-python
def validate_ip(s):
a = s.split('.')
if len(a) != 4:
@jdembowski
jdembowski / functions.php
Created March 4, 2017 14:47
Remove nag notices from Swell Lite theme
<?php
// Queue up the child theme CSS
add_action( 'wp_enqueue_scripts', 'cleanretina_child_enqueue_styles' );
function cleanretina_child_enqueue_styles() {
$parent_style = 'parent-style';
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
@jdembowski
jdembowski / functions.php
Last active March 4, 2017 04:41
Clean Retina Child theme functions.php file
<?php
// Queue up the child theme CSS
add_action( 'wp_enqueue_scripts', 'cleanretina_child_enqueue_styles' );
function cleanretina_child_enqueue_styles() {
$parent_style = 'parent-style';
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
// ==UserScript==
// @name WordPress topic redirect
// @namespace WordPress_topic_redirect
// @description Forces https, adds view=all to topic urls and redirects if needed.
// @version 1
// @grant none
// @run-at document-start
// @include *://*wordpress.org/support/topic/*
// @include https://wordpress.org/support/plugin/*
// @include https://wordpress.org/support/theme/*
@jdembowski
jdembowski / not-gravatar.php
Last active July 13, 2021 23:04
Use Gravatar images in WordPress but don't reveal the Gravatar img src URL. Display the Gravatar inline instead.
<?php
/*
Plugin Name: Tin Foil Hat Gravatars
Description: Use Gravatars but don't use Gravatars. What? Shut up.
Author: Jan Dembowski
Author URI: https://blog.dembowski.net/
Version: 0.7
License: GPL2
*/
#
# Start with a fresh Raspbian Jessie Lite installation from https://www.raspberrypi.org/downloads/raspbian/
#
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
sudo apt-get -y install vim
sudo apt-get -y install subversion
sudo apt-get -y install git