Skip to content

Instantly share code, notes, and snippets.

@holizz
holizz / gist:63a55daa81a6106c5b16
Created June 14, 2015 13:26
Comcast alert injected into HTTP response
<script language="JavaScript" type="text/javascript">
// Copyright (C) 2013 Comcast Cable Communications, LLC
// Intended use of this message is to display critical and time sensitive notifications to customers.
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
@holizz
holizz / fix-oembed.php
Created July 2, 2012 20:13
Attempt to fix oEmbed in WordPress - doesn't work because certain oEmbed providers won't give you HTTPS-suitable content
# Fix oEmbed for HTTPS
add_filter('oembed_providers', function ($providers) {
$new_providers = array();
foreach ($providers as $key => $value) {
$matchmask = $key;
$providerurl = $value[0];
$regex = $value[1];
# Convert simple-style to full regex (assuming all regexes use # as delimiter)
@holizz
holizz / gist:2954136
Created June 19, 2012 13:25
Fix many SQL injection vectors.
diff --git a/admin/your_subscriptions.php b/admin/your_subscriptions.php
index ddf74ae..97dbba5 100755
--- a/admin/your_subscriptions.php
+++ b/admin/your_subscriptions.php
@@ -7,7 +7,7 @@ global $user_ID, $s2nonce;
if ( isset($_GET['email']) ) {
global $wpdb;
- $user_ID = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_email = '" . urldecode($_GET['email']) . "'");
+ $user_ID = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_email = %s", urldecode($_GET['email'])));
#!/bin/sh
set -e
test X$1 == X && echo 'Args plox' && exit 1 ||
## Manual configuration
VHOST_DIR=/var/vhosts
VHOST_CONF=/etc/httpd/conf/extra/httpd-vhosts.conf
We couldn’t find that file to show.
#!/usr/bin/env python
import csv
import numpy
data = []
for row in csv.reader(open('votes.csv')):
data.append(row)
import subprocess
def git(cmd, *args):
return subprocess.Popen(['git',cmd]+list(args), stdout=subprocess.PIPE).communicate()[0].decode()
def leaf(tree, pos):
while True:
if len(pos) == 0:
return tree
#!/usr/bin/env python
import socket
def uzblctrl(socket_file, input):
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect(socket_file)
sock.settimeout(0.5) # 500ms
sock.send(input+'\n')
# Copy/pasted from http://gist.github.com/152929
import json
import re
import urllib2
class PostcodeLookupError(Exception):
pass
def from_postcode(postcode):
var theme = "crystal";
function toggle(app) {
var this_app = document.getElementById(app);
var is_small = false;
if (class_contains(this_app, 'app_small')) {
is_small = true;
}
if (this_app.style.display=="block") {
this_app.style.display="none";