Skip to content

Instantly share code, notes, and snippets.

Avatar

Peter Wake peterwake

  • Cowcross / StorIQ
  • London
View GitHub Profile
@peterwake
peterwake / mysql-sparse-fill-in.sql
Created Nov 3, 2020
MySQL query to fill in missing dates with a sparse result set
View mysql-sparse-fill-in.sql
/* 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
View tower_bridge.js
// 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,
View structure2.js
//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(
@peterwake
peterwake / structure1.js
Last active Mar 30, 2020
OpenJScad random structure
View structure1.js
//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]);
@peterwake
peterwake / spiral.js
Created Mar 30, 2020
OpenJSCad spiral
View spiral.js
//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 / RGeo_with_Proj.md
Last active Mar 22, 2021
Installation of RGeo with Proj support (also called Proj4)
View RGeo_with_Proj.md

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 / aws_move.rb
Created Dec 11, 2018
AWS folder move using threading
View aws_move.rb
# 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 / haml_filters.rb
Last active Mar 29, 2017
Adding a :redcarpet Haml Filter to Rails 4
View haml_filters.rb
# 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 / notes.md
Created Mar 3, 2017
Adding new language to existing Pootle project under pootle_fs_git
View notes.md

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 / adfs-utils.rb
Created Nov 3, 2016
A utility snippet to check metadata for use in Devise Omniauth
View adfs-utils.rb
require 'rest_client'
require 'uri/http'
require 'nokogiri'
require 'base64'
puts
puts
puts 'Federation Metadata Checker'
puts '==========================='
puts