Skip to content

Instantly share code, notes, and snippets.

@djudd
djudd / convert_to_text.sh
Created August 4, 2014 05:19
Extract text from arbitrary files
#!/bin/bash
if [ -z "$2" ]; then
echo "Usage: ./convert_to_text.sh in.pdf out.txt";
exit 1;
fi
INPUT=$1
OUTPUT=$2
TYPE=`file -b --mime-type "$INPUT"`
@djudd
djudd / duplicate-indexes.sql
Created March 31, 2014 23:13
Detect duplicate indexes in Postgres 9+
with indexes as (
select
t.relname as table_name,
i.relname as index_name,
array_agg(a.attname order by position(cast(a.attnum as text) in cast(ix.indkey as text)) asc) as column_names
from
pg_class t,
pg_class i,
pg_index ix,
pg_attribute a
@djudd
djudd / mongodb-large-collection-stats.js
Created June 21, 2013 18:41
Get stats for all collections >= 1GB
db.getCollectionNames().forEach(function(c) {s = db[c].stats(1024*1024*1024); if (s.size > 0) { printjson(s); }})
@djudd
djudd / install.sh
Last active October 7, 2017 22:55
Install Poppler from source on Heroku
cd /app/
wget http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.10.91.tar.gz
cd fontconfig-2.10.91
tar -xzf fontconfig-2.10.91.tar.gz
./configure
make
cd /app/
wget http://poppler.freedesktop.org/poppler-0.22.1.tar.gz
tar -xzf poppler-0.22.1.tar.gz
@djudd
djudd / gist:4004848
Created November 2, 2012 22:52
really simple Ruby Googlecharts graph
require 'gchart'
require 'json'
data = JSON.parse(IO.read('google-hit-results.json'))['result']
totals = data.collect { |point| point['count'] }
labels = data.collect do |point|
point['_id']['date']['day']
end
@djudd
djudd / gist:4000108
Created November 2, 2012 10:46
Snipped for Drupal page allowing users to post to site global Twitter
<?php
if (!user_access('post to twitter')) {
drupal_set_message("You don't have permission to post to our Twitter account, sorry!");
}
else {
module_load_include('inc', 'twitter');
function twitter_standalone_form() {
$form = twitter_post_form();
$form['submit'] = array(