Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Toby Osbourn tosbourn

🏠
Working from home
View GitHub Profile
View gist:e901dc96c9e8b225fd5dfdd84837bfd5
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 Jan 30, 2018
Some docker commands I always forget
View docker-commands.sh
docker-compose up #runs docker compose (looks at docker-compose.yml)
docker ps # lists all containers
docker exec -it `docker container id` bash
View dynamic_filters.ex
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: []
View MySQL Conventions.md
  • 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 Feb 4, 2017
How to recreate Facebook's console warning
View facebook_warning.html
<!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;';
View Get PS to make text in a layer work
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
View gist:a5f42242a1f9205426bae607fd5bcfce
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');
View gist:6a3203fa366be207984b
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)
View union-array-ampersand-vs-set.rb
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
View imagecaption
<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>