Skip to content

Instantly share code, notes, and snippets.

View tosbourn's full-sized avatar
🏠
Working from home

Toby Osbourn tosbourn

🏠
Working from home
View GitHub Profile

Keybase proof

I hereby claim:

  • I am tosbourn on github.
  • I am tosbourn (https://keybase.io/tosbourn) on keybase.
  • I have a public key whose fingerprint is 8ED7 2636 598E 2917 E1CD FF24 5D89 AC71 BEF8 E674

To claim this, I am signing this object:

@tosbourn
tosbourn / kill off port 5000
Created October 22, 2014 08:40
Kill off any process on :5000
lsof -wni tcp:5000 | awk 'NR>1{kill -9 $2}'
require "set"
require 'benchmark/ips'
X = [5, 5, 1, 1]
Y = [1, 2, 5]
SET_X = Set.new(X)
SET_Y = Set.new(Y)
def fast
@tosbourn
tosbourn / calc.js
Created April 17, 2012 13:52
Quick Calc Function
/**
* Quick calc functionality.
*
* Make sure you pass values of the same metric (all inches, or all centimetres or whatever)
* @input fw int floor width.
* @input fl int floor length.
* @input tw int tile width.
* @input tl int tile length.
*
* @return int Number of tiles.
@tosbourn
tosbourn / bigmysqltables.sql
Created April 25, 2012 09:21
Script to find largest 10 tables your database.
SELECT CONCAT(table_schema, '.', table_name),
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
FROM information_schema.TABLES
ORDER BY data_length + index_length DESC
LIMIT 10;
@tosbourn
tosbourn / gist:4949176
Created February 13, 2013 22:59
My uber cool gist!
Here is my Gist!
Look at it!
Gisting all over the place
require 'FileUtils'
homepath = File.expand_path "~"
desktop_files = Dir.entries homepath + "/Desktop"
desktop_files.to_a
screen_shot_folder = homepath + "/Desktop/Screenshots"
Dir::mkdir(screen_shot_folder) unless File.exists?(screen_shot_folder)
desktop_files.each {
@tosbourn
tosbourn / Important Firefox Test
Created March 24, 2013 17:12
Some sample code to show off how Firefox treats !important when used with CSS animations
<html>
<head>
<title>Wee Animation Test</title>
<style>
.awesome_but_not_important {
height: 150px;
width: 150px;
background-color: red;
padding: 5px;
-webkit-animation: awesome 5s linear infinite;
@tosbourn
tosbourn / gist:6a3203fa366be207984b
Created March 5, 2016 20:04
raspbian firmware update
pi@raspberrypi:~ $ sudo rpi-update
*** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
*** Performing self-update
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 10666 100 10666 0 0 77592 0 --:--:-- --:--:-- --:--:-- 77854
*** Relaunching after update
*** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
*** We're running for the first time
*** Backing up files (this will take a few minutes)
Tito.on('registration:started', function(data){
for(var i=0; i<data.line_items.length; i++) {
var line_item = data.line_items[i];
ga('ec:addProduct', {
'id': line_item.release_slug,
'name': line_item.title,
'price': line_item.price,
'quantity': line_item.quantity
});
ga('ec:setAction', 'add');