Skip to content

Instantly share code, notes, and snippets.

@pixyj
pixyj / install_docker.sh
Last active August 10, 2020 11:11
Script to Install Docker on Ubuntu
sudo apt-get update
sudo apt-get install --assume-yes\
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
@pixyj
pixyj / Counter.js
Last active March 16, 2018 14:38
Minimal react-redux app - Shows what the 'connect' API does. Deployed at https://cranky-yonath-667b1f.netlify.com/
import React, { Component } from 'react'
import { render } from 'react-dom'
import { createStore } from 'redux'
import { connect, Provider } from 'react-redux'
// Reducer and Store
function counterReducer(state={value: 0}, action) {
switch(action.type) {
case 'INC':
@pixyj
pixyj / timer.py
Created February 23, 2018 13:23
Simple command line timer for macOS
import argparse
import os
import time
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Timer')
parser.add_argument('-s','--seconds', help='Seconds from now', required=True)
args = vars(parser.parse_args())
seconds = int(args['seconds'])
@pixyj
pixyj / female-names.txt
Created December 21, 2017 14:23
Trie Implementation in Python
aaren
aarika
abagael
abagail
abbe
abbey
abbi
abbie
abby
abbye

Keybase proof

I hereby claim:

  • I am pixyj on github.
  • I am pixyj (https://keybase.io/pixyj) on keybase.
  • I have a public key whose fingerprint is 8D6D 422D 5213 FBBA 29A7 B0A6 64B8 E4D3 338B E6AF

To claim this, I am signing this object:

@pixyj
pixyj / usability.md
Last active August 19, 2017 18:04
Summary of Usability talk at Google Cloud Next '17 by Alley Rutzel

Usability is a quality attribute that assesses how easy user interfaces are to use.

6 Quality components:

  1. Learnability - How easy is the first-time experience.
  2. Efficiency - How few keystrokes (or clicks / or whatever metric makes sense) are required to get the job done for repeat users.
  3. Memorability - How easy is to get started after you come back to the product after a while.
  4. Accessibility - Not just for people with disabilities. Think of how easy it is to use when outside under sunlight, or if user breaks their hand.
@pixyj
pixyj / lru.py
Created August 11, 2017 04:17
A simple LRU cache implementation in Python. See test_lru.py for an usage example.
class Item:
def __init__(self, key, value, previous, next):
self.key = key
self.value = value
self.previous = previous
self.next = next
class LRU:
def __init__(self, maxlength=10):
@pixyj
pixyj / experiment_coordinator.ex
Created February 8, 2017 13:10
Pattern matching example
defmodule ExperimentCoordinator do
use GenServer
require Logger
def handle_call({:configure, config}, _from, :not_started) do
Logger.info "Configuring node with parameters: #{inspect config}..."
{:reply, :ok, :ready}
end
def handle_call(:begin_pings, _from, :ready) do
@pixyj
pixyj / shunting_yard.ex
Last active June 7, 2017 12:52
Shunting yard algorithm in Elixir
defmodule ShuntingYard do
@moduledoc """
Shunting yard algorithm as explained at https://en.wikipedia.org/wiki/Shunting-yard_algorithm
Supports an use-case of mine where all operators are left-associative,
and no functions are present in the expression
iex> c("shunting_yard.ex")
import Queue
import threading
# This is the current version of the database.
rows = {
1: {
"version": 2,
"postcode": 111111,
"id": 1
},