Skip to content

Instantly share code, notes, and snippets.

@peterwake
peterwake / adfs-utils.rb
Created November 3, 2016 10:03
A utility snippet to check metadata for use in Devise Omniauth
require 'rest_client'
require 'uri/http'
require 'nokogiri'
require 'base64'
puts
puts
puts 'Federation Metadata Checker'
puts '==========================='
puts
@peterwake
peterwake / notes.md
Created March 3, 2017 12:21
Adding new language to existing Pootle project under pootle_fs_git

You may have to delete the existing project (don't try this next time) (Assuming Pootle in /var/www/pootle)

cd /var/www/pootle
source env/bin/activate

pootle fs fetch --force MYPROJECT
pootle fs sync MYPROJECT
@peterwake
peterwake / haml_filters.rb
Last active March 29, 2017 13:08
Adding a :redcarpet Haml Filter to Rails 4
# config/initializers/haml_filters.rb
# Thanks to https://gist.github.com/sleepingkingstudios/955676
# config/initializers/haml_filters.rb
# in your haml files do e.g.
# %td.description
# :markdown
# #{task.description}
@peterwake
peterwake / aws_move.rb
Created December 11, 2018 16:06
AWS folder move using threading
# This is a sample class that you'll probably need
# to do a bit of work on for your own needs, but it
# will hopefully save you a lot of the headaches that we had
class AwsMove
FIVE_MB = 5 * 1024 * 1024
MAX_THREADS = 25
def move_folder(s3_client, old_key, new_key)
# strip preceding '/'
@peterwake
peterwake / RGeo_with_Proj.md
Last active March 22, 2021 08:34
Installation of RGeo with Proj support (also called Proj4)

Installation of RGeo with Proj support (also called Proj4)

This is a real pain as of writing (18 Oct 2019). I can't promise it'll work either :)

Reference

Let's start from the beginning...

If you've been hacking around already you should do:

@peterwake
peterwake / spiral.js
Created March 30, 2020 08:54
OpenJSCad spiral
//openjscad.org
// Anna and Charlie's spral
function main () {
const twist = 9;
var w = [ ];
for(var i = 0; i < 40; i++) {
w.push(
color('lightblue', cube({
size: [30, 6, 2]
@peterwake
peterwake / structure1.js
Last active March 30, 2020 08:56
OpenJScad random structure
//openjscad.org
// Random structure
function main () {
var cube1 = cube({size:[4,4,4]}).translate([-2,-2,-2]);
var hole = cylinder({r:1, h: 4}).translate([0,0,-2]);
var nut1 = difference(cube1, hole);
var rod1 = cylinder({r:1, h: 10}).rotateX(90).translate([0,-2,0]);
//openjscad.org
// Anna and Charlie's spral
function main () {
const twist = 45;
let i = 0;
let delta = 1;
var w = [ ];
for(var h = 0; h < 100; h++) {
w.push(
// openjscad.org
// Tower Bridge
let fancy_bricks = true;
function random_colour() {
// based on 'BurlyWood';
return [
(222 + Math.random() * 10) / 255,
(184 + Math.random() * 10) / 255,
@peterwake
peterwake / mysql-sparse-fill-in.sql
Created November 3, 2020 12:50
MySQL query to fill in missing dates with a sparse result set
/* For a query of results in the last 31 days */
SELECT recent_dates.`date`,
IFNULL(sparse_results.`count`, 0) AS `count`
FROM
(SELECT SUBDATE(CURDATE(), number_table.delta) AS `date`
FROM
(SELECT 0 delta
UNION SELECT 1
UNION SELECT 2