Skip to content

Instantly share code, notes, and snippets.

🤠
It's great in Phoenix 🚲

Dave Tapley dukedave

🤠
It's great in Phoenix 🚲
Block or report user

Report or block dukedave

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dukedave
dukedave / update_sdists.sh
Created Jan 3, 2012
If a package's sdist tarball is newer than its cabal-dev installed version, reinstall it
View update_sdists.sh
#!/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
@dukedave
dukedave / savon_model_spec_fail.rb
Created Jul 17, 2012
Rspec showing savon_spec is unable to work with a class which extends Savon::Model
View savon_model_spec_fail.rb
require 'rspec'
require 'savon_spec'
RSpec.configure do |config|
config.include Savon::Spec::Macros
end
describe 'with client' do
let(:client) do
@dukedave
dukedave / gist:3841593
Created Oct 5, 2012
Postgres relation disk sizes in human format
View gist:3841593
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;
@dukedave
dukedave / trunc_mail.txt
Created Oct 9, 2012
Part of raw mail which causes aggressive truncation
View trunc_mail.txt
OMITTED NORMAL MAIL HEADERS
X-Github-Reason: comment
List-Archive: https://github.com/dylankeil/chronos
List-Unsubscribe: <mailto:unsub+i-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXxx@reply.github.com>
List-Id: dylankeil/chronos <chronos.dylankeil.github.com>
List-Post: <mailto:reply+i-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX@reply.github.com>
X-Github-Recipient: dukedave
@dukedave
dukedave / vv_le.sql
Created Oct 25, 2012
VACCUM VERBOSE
View vv_le.sql
=> 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.
@dukedave
dukedave / gist:3955433
Created Oct 25, 2012
Convo about partial index with Rhodium toad
View gist:3955433
(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
@dukedave
dukedave / Mittens.user.js
Created Oct 31, 2012
More theraputic democracy
View Mittens.user.js
// ==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
@dukedave
dukedave / gist:4033669
Created Nov 7, 2012
dig git.tddium.com
View gist:4033669
; <<>> 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:
View array_re-evaulation.rb
# 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'
@dukedave
dukedave / range_overlaps.rb
Created Dec 5, 2012
Extending Range with overlaps?
View range_overlaps.rb
class Range
def overlaps?(other)
(self.first <= other.last) and (other.first <= self.last)
end
end
You can’t perform that action at this time.