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
@tosbourn
tosbourn / gist:e901dc96c9e8b225fd5dfdd84837bfd5
Created October 10, 2018 14:02
How to generate a VAS base64 key
openssl ecparam -name prime256v1 -genkey -noout -out nfcKey.pem
openssl ec -in nfcKey.pem -pubout -out nfcPubkey.pem -conv_form compressed
cat nfcPubkey.pem
Top and tail the resulting key and join any broken lines
@tosbourn
tosbourn / docker-commands.sh
Created January 30, 2018 10:43
Some docker commands I always forget
docker-compose up #runs docker compose (looks at docker-compose.yml)
docker ps # lists all containers
docker exec -it `docker container id` bash
def filter(params) do
Post
|> order_by(^filter_order_by(params["order_by"]))
|> where(^filter_where(params))
|> where(^filter_published_at(params["published_at"]))
end
def filter_order_by("published_at_desc"), do: [desc: :published_at]
def filter_order_by("published_at"), do: [asc: :published_at]
def filter_order_by(_), do: []
  • Always uppercase actions
  • Always backtick tables
  • Always use != for "not equals to"
  • Always give an alias to a table
SELECT a.name FROM `aTable` a WHERE a.id != 5
@tosbourn
tosbourn / facebook_warning.html
Created February 4, 2017 23:37
How to recreate Facebook's console warning
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script type="text/javascript">
const warningTitleCSS = 'color:red; font-size:60px; font-weight: bold; -webkit-text-stroke: 1px black;';
const warningDescCSS = 'font-size: 18px;';
set names to read "/Users/IE14/Dropbox (InnovationEnterprise)/Email Marketing/Pesonalised Emails/NamesTest.txt" as «class utf8»
tell application "Adobe Photoshop CC 2015.5"
tell current document
# Access NAME layer
set current layer to layer "Name"
tell current layer to if not visible then set visible to true
# LOOP through names
repeat with name in (paragraphs of names as list)
# Add name to name layer
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');
@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)
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 / imagecaption
Created January 20, 2015 19:05
Image Caption
<figure>
<img src="http://placekitten.com/200/300" alt="Small picture of a kitten" />
<figcaption>
Small picture of a kitten, graciously shared by <a href="http://placekitten.com">placekitten.com</a>
</figcaption>
</figure>