Skip to content

Instantly share code, notes, and snippets.

View simonwheatley's full-sized avatar

Simon Wheatley simonwheatley

View GitHub Profile
<?php
/**
* Plugin Name: Deny Giant Image Uploads
* Description: Prevents Uploads of images greater than 3.2MP
* Author: TJNowell
* Author URI: http://tomjn.com
* Plugin URI: http://tomjn.com/164/clients-who-upload-huge-camera-photos-decompression-bombs/
* Version: 1.1
*/
@stefl
stefl / scrape_tweets.rb
Created March 25, 2012 14:47
Download all tweets from the twitter search API for a given search term (limited to their maximum of 1500)
#! /usr/bin/env ruby
require "fileutils"
search_term = ARGV[0]
if search_term
time = Time.now
directory_path = File.dirname(__FILE__) + "/tweets/" + search_term + "_" + time.to_i.to_s
FileUtils.mkdir_p(directory_path)
directory = Dir.new(directory_path)
(1..15).each do |i|
`curl "http://search.twitter.com/search.json?q=#{search_term}&rpp=100&page=#{i}&include_entities=true&result_type=mixed" > #{directory.path}/#{i}.json`
@simonwheatley
simonwheatley / Infinite Response Time Reporter
Created March 1, 2012 11:02
Uses Curl to get the response time for a webpage, also regexes out the page gen time (this last relies on WP Super Cache's "Dynamic page generated in X.XX seconds." HTML comment)
#!/bin/bash
# My script below is based on this one:
# http://unixbhaskar.wordpress.com/2010/11/12/measure-website-response-time-through-curl/
if [ -z $1 ]
then
echo "Please pass a URL to measure the response time for, e.g."
echo "sh infinite_response_time.sh http://google.com/ cookie1=123\;cookie2=abc"
exit