Skip to content

Instantly share code, notes, and snippets.

View cbandy's full-sized avatar

Chris Bandy cbandy

View GitHub Profile
@sneakers-the-rat
sneakers-the-rat / clean_pdf.sh
Last active May 27, 2024 03:44
Strip PDF Metadata
# --------------------------------------------------------------------
# Recursively find pdfs from the directory given as the first argument,
# otherwise search the current directory.
# Use exiftool and qpdf (both must be installed and locatable on $PATH)
# to strip all top-level metadata from PDFs.
#
# Note - This only removes file-level metadata, not any metadata
# in embedded images, etc.
#
# Code is provided as-is, I take no responsibility for its use,
@jberkus
jberkus / gist:6bbffae5ce10fb399d29
Last active January 13, 2018 06:55
Duplicate Index Query #2: Partial matches
-- check for containment
-- i.e. index A contains index B
-- and both share the same first column
-- but they are NOT identical
WITH index_cols_ord as (
SELECT attrelid, attnum, attname
FROM pg_attribute
JOIN pg_index ON indexrelid = attrelid
WHERE indkey[0] > 0
@jberkus
jberkus / gist:e4cadd6b8877c3bc59c8
Created September 19, 2014 00:36
Duplicate Index Query #1: Exact Duplicates
-- check for exact matches
WITH index_cols_ord as (
SELECT attrelid, attnum, attname
FROM pg_attribute
JOIN pg_index ON indexrelid = attrelid
WHERE indkey[0] > 0
ORDER BY attrelid, attnum
),
index_col_list AS (
SELECT attrelid,
@joshuaflanagan
joshuaflanagan / gist:7495006
Created November 16, 2013 02:15
Postgres extensions on Amazon RDS
name | default_version | installed_version | comment
------------------------+-----------------+-------------------+---------------------------------------------------------------------
pg_buffercache | 1.0 | | examine the shared buffer cache
earthdistance | 1.0 | | calculate great-circle distances on the surface of the Earth
pg_freespacemap | 1.0 | | examine the free space map (FSM)
intagg | 1.0 | | integer aggregator and enumerator (obsolete)
plperl | 1.0 | | PL/Perl procedural language
sslinfo | 1.0 | | information about SSL certificates
btree_gist | 1.0 | | support for indexing common datatypes in GiST
fuzzystrmatch | 1.0
@igor-alexandrov
igor-alexandrov / gist:6942754
Created October 11, 2013 22:05
Complete example of how to map association from Sequel::Model to AR. Eager loading works like a charm!
class Tour < Sequel::Model
many_to_one :vendor_pansion,
:dataset => proc{ Vendor::Pansion.where(:id => self.vendor_pansion_id) },
:reciprocal => nil, :class => 'Vendor::Pansion',
:eager_loader => (proc do |opts|
opts[:rows].each{ |object| object.associations[:vendor_pansion] = nil }
Vendor::Pansion.where(:id => opts[:id_map].keys).each do |vendor_pansion|
if tours = opts[:id_map][vendor_pansion.id]
tours.each do |tour|
# Git Navigation
#
# By Hannes Tydén <hannes@tyden.name> @pht
#
# Navigate backwards and forwards in your Git history.
#
# Inspired by https://twitter.com/avdi/status/292057753088827392
#
# Tested on
# zsh 5.0.2 (x86_64-apple-darwin12.2.1)
@mbj
mbj / external_aequitas_validator.rb
Created July 20, 2012 10:34
Use aequitas as external validator
module ExternalValidator
def self.included(descendant)
descendant.class_eval do
InstanceMethods
end
end
module InstanceMethods
def initialize(object)
@object = object
@alanq
alanq / mt.rb
Created May 16, 2012 15:18
DCI in ruby without injection - MoneyTransfer example
-----------------------------------------
Boilerplate code (in rails_app_root/lib)
-----------------------------------------
module ContextAccessor
def context
Thread.current[:context]
end
end
@pbabik
pbabik / getfeature.php
Created March 21, 2012 10:22 — forked from bmcbride/postgis_geojson.php
PHP PostGIS to GeoJSON - with BBOX query
<?php
/**
* PostGIS to GeoJSON
* Query a PostGIS table or view and return the results in GeoJSON format, suitable for use in OpenLayers, Leaflet, etc.
*
* @param string $bbox Bounding box of request *REQUIRED*
* @param string $geotable The PostGIS layer name *REQUIRED*
* @param string $geomfield The PostGIS geometry field *REQUIRED*
* @param string $srid The SRID of the returned GeoJSON *OPTIONAL (If omitted, EPSG: 4326 will be used)*
@ziadoz
ziadoz / awesome-php.md
Last active May 10, 2024 15:06
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.