Skip to content

Instantly share code, notes, and snippets.

@davetapley
davetapley / update_sdists.sh
Created January 3, 2012 22:17
If a package's sdist tarball is newer than its cabal-dev installed version, reinstall it
#!/bin/bash
SANDBOX_DIR="cabal-dev"
SDIST_DIR="./sdist/"
SDIST_SUFFIX=".tar.gz"
PACKAGES_CONF_DIR=$SANDBOX_DIR"/packages-"`ghc --numeric-version`".conf/"
find $SDIST_DIR -name *$SDIST_SUFFIX -print0 | while read -d $'\0' sdist_path
do
@davetapley
davetapley / savon_model_spec_fail.rb
Created July 17, 2012 06:24
Rspec showing savon_spec is unable to work with a class which extends Savon::Model
require 'rspec'
require 'savon_spec'
RSpec.configure do |config|
config.include Savon::Spec::Macros
end
describe 'with client' do
let(:client) do
@davetapley
davetapley / gist:3841593
Created October 5, 2012 18:38
Postgres relation disk sizes in human format
SELECT nspname || '.' || relname AS "relation",
pg_size_pretty(pg_relation_size(C.oid)) AS "size"
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
ORDER BY pg_relation_size(C.oid) DESC
LIMIT 20;
@davetapley
davetapley / trunc_mail.txt
Created October 9, 2012 16:05
Part of raw mail which causes aggressive truncation
OMITTED NORMAL MAIL HEADERS
X-Github-Reason: comment
List-Archive: https://github.com/dylankeil/chronos
List-Unsubscribe: <mailto:[email protected]>
List-Id: dylankeil/chronos <chronos.dylankeil.github.com>
List-Post: <mailto:[email protected]>
X-Github-Recipient: dukedave
@davetapley
davetapley / vv_le.sql
Created October 25, 2012 20:40
VACCUM VERBOSE
=> VACUUM VERBOSE location_events;
INFO: vacuuming "public.location_events"
INFO: scanned index "location_events_pkey" to remove 3882346 row versions
DETAIL: CPU 0.91s/7.16u sec elapsed 13.93 sec.
INFO: scanned index "index_location_events_on_user_id" to remove 3882346 row versions
DETAIL: CPU 1.68s/9.01u sec elapsed 21.61 sec.
INFO: scanned index "index_location_events_on_user_id_where_not_archived" to remove 3882346 row versions
DETAIL: CPU 0.00s/1.70u sec elapsed 1.66 sec.
INFO: "location_events": removed 3882346 row versions in 92228 pages
DETAIL: CPU 0.21s/1.98u sec elapsed 8.32 sec.
@davetapley
davetapley / gist:3955433
Created October 25, 2012 21:10
Convo about partial index with Rhodium toad
(13:27:40) dukedave: Lazy post: Any comments on my question here, the single answer, and my comment on that answer: http://dba.stackexchange.com/questions/25890/does-updating-a-partially-indexed-field-add-or-remove-it-from-an-index-in-postgr
(13:29:05) RhodiumToad: dukedave: your answer seems correct
(13:29:19) supplicant: I think dukedave is the commenter?
(13:29:31) dukedave: Yes, I'm the asker and commenter :)
(13:29:48) RhodiumToad: dukedave: ok, so the answer you received is correct :-)
(13:29:50) dukedave: The answer certainly makes sense, but I'm still seeing the partial index grow
(13:29:56) dukedave: Which seems in consistent
(13:30:19) RhodiumToad: dukedave: no, not really. it'll depend on the exact pattern of updates. here's why:
(13:30:44) dukedave: The purpose of making it partial was that it only has non-archived rows in it, which should be a reasonably fixed number
(13:30:44) RhodiumToad: dukedave: I'm assuming we're inserting in strictly increasing order of ids, since that's what usually happ
@davetapley
davetapley / Mittens.user.js
Created October 31, 2012 22:02
More theraputic democracy
// ==UserScript==
// @name Mittens
// @namespace http://userscripts.org/users/489276
// @include http*
// @version 1
// @grant None
// ==/UserScript==
// Thanks to: http://stackoverflow.com/a/5494405/21115http://stackoverflow.com/a/5494405/21115
@davetapley
davetapley / gist:4033669
Created November 7, 2012 19:05
dig git.tddium.com
; <<>> DiG 9.8.1-P1 <<>> git.tddium.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51959
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;git.tddium.com. IN A
;; ANSWER SECTION:
# Normal has_many / belongs_to:
>> a = c.permitted_ips
=> []
# What we got back was just an Array:
>> a.class
=> Array
# Now build a new record:
>> c.permitted_ips.build :address => '123123'
@davetapley
davetapley / range_overlaps.rb
Created December 5, 2012 00:58
Extending Range with overlaps?
class Range
def overlaps?(other)
(self.first <= other.last) and (other.first <= self.last)
end
end