Skip to content

Instantly share code, notes, and snippets.

View elliotcm's full-sized avatar

Elliot Crosby-McCullough elliotcm

View GitHub Profile
@elliotcm
elliotcm / gist:000a3d092a158902c9c4f07624ea8eae
Created September 16, 2024 09:11
PostgreSQL: 10 biggest tables by disk size, plus a row count estimate
with row_counts as (SELECT reltuples, relname FROM pg_class)
select
table_name,
pg_size_pretty(pg_total_relation_size(quote_ident(table_name))) as total_size,
row_counts.reltuples::decimal(38,0) as row_count
from information_schema.tables
join row_counts on table_name = row_counts.relname
where table_schema = 'public'
order by pg_total_relation_size(quote_ident(table_name)) desc
limit 10;
@elliotcm
elliotcm / bin_travel-advice-pagewatch-disable
Last active January 22, 2016 14:47
Tool to set "autosend" flag for pagewatch in govdelivery.
#!/usr/bin/env ruby
require_relative "../lib/travel_advice_pagewatch_adjuster"
TravelAdvicePagewatchAdjuster.set_pagewatch_autosend(false)
@elliotcm
elliotcm / gist:1a6f9159448d66dc97bb
Last active August 29, 2015 14:03
Grab panopticon slugs for unpublished documents for Marine Management Organisation
unsub_info = [
["DetailedGuide", "harbour-development-and-the-law"],
["DetailedGuide", "disposal-of-dredged-material-at-sea-regulations-and-controls"],
["DetailedGuide", "offshore-cables-and-pipelines"],
["DetailedGuide", "marine-construction-and-coastal-protection"],
["DetailedGuide", "licences-for-offshore-renewable-energy-installations"],
["DetailedGuide", "european-fisheries-fund-fishing-industry-common-interests"],
["DetailedGuide", "european-fisheries-fund-projects"],
["DetailedGuide", "investing-in-aquaculture"],
["DetailedGuide", "investing-on-board-your-fishing-vessel"],
{"index":{"_id":"jobs-exact","_type":"best_bet"}}
{"exact_query":"jobs","details":"{\"best_bets\":[{\"link\":\"/jobs1\",\"position\":1},{\"link\":\"/jobs2\",\"position\":2}],\"worst_bets\":[]}"}
{"index":{"_id":"vias-exact","_type":"best_bet"}}
{"exact_query":"vias","details":"{\"best_bets\":[],\"worst_bets\":[{\"link\":\"/it-is-a-link\"}]}"}
@elliotcm
elliotcm / gist:11285693
Last active August 29, 2015 14:00
Devops existing specialist sector tag routes in Panopticon
class SpecialistSectorTagForm; attr_writer :tag; end
Tag.where(tag_type: 'specialist_sector').each do |tag|
tag_form = SpecialistSectorTagForm.new({})
tag_form.tag = tag
tag_form.save
puts "Successfully saved tag #{tag.tag_id}"
end
@elliotcm
elliotcm / gist:6560960
Last active December 23, 2015 01:29
Recommended films for @georgebrock available on Netflix Sverige (according to this list http://netflixswedencompletelist.blogspot.co.uk/).

Weeell there's only two "good" sniper films and you've watched Shooter, the other is Enemy at the Gates unfortunately not on Netflix SE.

You seem to have been watching a lot of action films so here's something else:

@elliotcm
elliotcm / pvavpva_scheduler.rb
Created June 2, 2012 16:51
PvAvPvA film scheduler
require 'rubygems'
require 'active_support/core_ext/numeric'
require 'hirb'; extend Hirb::Console
INTERMISSION = 10.minutes
def print_times_for(films, start_time)
last_end_time = start_time - INTERMISSION
run = films.map do |film|
start_time = last_end_time + INTERMISSION
@elliotcm
elliotcm / gist:2568455
Created May 1, 2012 14:45
Fetch some clock videos
(0..23).each do |hour|
(0..59).step(5) do |minute|
hour = hour.to_s.rjust(2, '0')
minute = minute.to_s.rjust(2, '0')
system "wget -c http://176.9.156.38/big_#{hour}-#{minute}.mp4"
end
end
@elliotcm
elliotcm / gist:2378385
Created April 13, 2012 17:05
Woolwich Wednesday shortlist
Singin' in the Rain
The Empire Strikes Back
Léon
Independence Day
The Nightmare Before Christmas
The Long Good Friday
Starship Troopers
Saving Private Ryan
Battle Royale
Blade Runner
@elliotcm
elliotcm / gist:2215878
Created March 27, 2012 13:30
Responsive test bookmarklet
javascript:document.write('%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3Cmeta%20charset=%22utf-8%22%3E%3Ctitle%3EResponsive%20Design%20Testing%3C/title%3E%3Cstyle%3Ebody%20%7B%20margin:%2020px;%20font-family:%20sans-serif;%20overflow-x:%20scroll;%20%7D.wrapper%20%7B%20width:%206000px;%20%7D.frame%20%7B%20float:%20left;%20%7Dh2%20%7B%20margin:%200%200%205px%200;%20%7Diframe%20%7B%20margin:%200%2020px%2020px%200;%20border:%201px%20solid%20%23666;%20%7D%3C/style%3E%3C/head%3E%3Cbody%3E%3Cdiv%20class=%22wrapper%22%3E%3Cdiv%20class=%22frame%22%3E%3Ch2%3E240%3Cspan%3E%20x%20320%3C/span%3E%20%3Csmall%3E(mobile)%3C/small%3E%3C/h2%3E%3Ciframe%20src=%22'%20+%20window.location%20+%20'%22%20sandbox=%22allow-same-origin%20allow-forms%22%20seamless%20width=%22240%22%20height=%22320%22%3E%3C/iframe%3E%3C/div%3E%3Cdiv%20class=%22frame%22%3E%3Ch2%3E320%3Cspan%3E%20x%20480%3C/span%3E%20%3Csmall%3E(mobile)%3C/small%3E%3C/h2%3E%3Ciframe%20src=%22'%20+%20window.location%20+%20'%22%20sandbox=%22allow-same-origin%20allow-forms%22%20s