Skip to content

Instantly share code, notes, and snippets.

@leeky
leeky / gist:8a60c9601484bb8cad812cfdb88d13af
Created January 27, 2022 20:17
Nightbot !day command
!commands add !day Oh wow! It's $(time Europe/London "dddd") already? I never did get the hang of $(time Europe/London "dddd")s.
query ($endCursor: String) {
repository(name: "judiciary-middleware", owner: "dxw") {
pullRequests(
states: MERGED
first: 25
after: $endCursor
orderBy: { field: CREATED_AT, direction: DESC }
) {
totalCount
pageInfo {
@leeky
leeky / crontab
Last active February 1, 2019 13:27
Raspberry Pi - HDMI Control + Display Refresh
# Install by running `crontab -e` as pi user NOT root
44 09 * * 1-5 /usr/bin/tvservice -o
45 09 * * 1-5 /usr/local/bin/tv-on.sh
00 13 * * 1-5 /usr/local/bin/refresh.sh
00 14 * * 1-5 /usr/local/bin/refresh.sh
05 18 * * 1-5 /usr/bin/tvservice -o
@leeky
leeky / model-to-redis-example.rb
Created March 1, 2016 14:12
Model to Redis Example
products = Product.includes(:coffee).all
coffees = Coffee.all
r = Redis.current
r.keys('product*').each { |k| r.del(k) }
r.keys('coffee*').each { |k| r.del(k) }
products.each do |p|
sku = p.sku
@leeky
leeky / gist:6cd3f3692c365865d35d
Created April 22, 2015 13:31
Convert PNG to base64 encoded string
require 'base64'
File.open('./outfile.txt','w') {|f| f.write "data:image/png;base64," + Base64.strict_encode64(File.read('./input.png'))}
@leeky
leeky / SassMeister-input-HTML.html
Created August 9, 2014 13:24
Generated by SassMeister.com.
<section>
<div class="moo">
<p>Donec ullamcorper nulla non metus auctor fringilla. Donec sed odio dui. Cras mattis consectetur purus sit amet fermentum. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.</p>
</div>
<div class="baa">
<p>Donec sed odio dui. Curabitur blandit tempus porttitor. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Nulla vitae elit libero, a pharetra augue. Cras justo odio, dapibus ac facilisis in, egestas eget quam.</p>
<p>Etiam porta sem malesuada magna mollis euismod. Donec ullamcorper nulla non metus auctor fringilla. Nulla vitae elit libero, a pharetra augue. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Nullam id dolor id nibh ultricies vehicula ut id elit. Cras mattis consectetur purus sit amet fermentum.</p>
<p>Nullam id dolor id nibh ultricies vehicula ut id elit. Aenean lacinia bibendum nu
@leeky
leeky / gist:77ede436db2bbb65113b
Created May 21, 2014 08:10
Install Nokogiri on Mavericks + RBENV + Ruby 1.8.7
brew install libxml2 libxslt
CC=clang gem install nokogiri -v 1.5.0 -- --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2
@leeky
leeky / rules.md
Created January 27, 2014 14:59 — forked from henrik/rules.md
  1. Your class can be no longer than 100 lines of code.
  2. Your methods can be no longer than five lines of code.
  3. You can pass no more than four parameters and you can’t just make it one big hash.
  4. When a call comes into your Rails controller, you can only instantiate one object to do whatever it is that needs to be done.

You can break these rules if you can talk your pair into agreeing with you.

@leeky
leeky / gist:6714325
Last active December 24, 2015 00:08 — forked from rafaelss/gist:3700977
Upgrading PostgreSQL with Homebrew on OS X
Steps to install and run PostgreSQL 9.2 using Homebrew (Mac OS X)
(if you aren't using version 9.1.5, change line 6 with the correct version)
1. pg_ctl -D /usr/local/var/postgres stop -s -m fast
2. mv /usr/local/var/postgres /usr/local/var/postgres91
3. curl https://raw.github.com/fragility/homebrew/737af01178590950749cf5e841f2d086c57c5a80/Library/Formula/postgresql.rb > /usr/local/Library/Formula/postgresql.rb
4. brew upgrade postgresql
5. initdb /usr/local/var/postgres -E utf8
6. pg_upgrade -b /usr/local/Cellar/postgresql/9.1.5/bin -B /usr/local/Cellar/postgresql/9.2.0/bin -d /usr/local/var/postgres91 -D /usr/local/var/postgres
7. pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
@leeky
leeky / gist:6580469
Created September 16, 2013 13:07
Raphael Arcs
paper.customAttributes.arc = function (centerX, centerY, startAngle, endAngle, innerR, outerR) {
var radians = Math.PI / 180,
largeArc = +(endAngle - startAngle > 180);
// calculate the start and end points for both inner and outer edges of the arc segment
// the -90s are about starting the angle measurement from the top get rid of these if this doesn't suit your needs
outerX1 = centerX + outerR * Math.cos((startAngle-90) * radians),
outerY1 = centerY + outerR * Math.sin((startAngle-90) * radians),
outerX2 = centerX + outerR * Math.cos((endAngle-90) * radians),
outerY2 = centerY + outerR * Math.sin((endAngle-90) * radians),
innerX1 = centerX + innerR * Math.cos((endAngle-90) * radians),