Skip to content

Instantly share code, notes, and snippets.

View neenjaw's full-sized avatar
:shipit:
Shippin' code

Tim Austin neenjaw

:shipit:
Shippin' code
View GitHub Profile
# A function that shows the results of running competitions consisting of 2 to 4 runners.
def save_ranking(first, second, third=None, fourth=None):
rank = {}
rank[1], rank[2] = first, second
rank[3] = third if third is not None else 'Nobody'
rank[4] = fourth if fourth is not None else 'Nobody'
print(rank)
# Pass the 2 positional arguments
save_ranking('ming', 'alice')
@neenjaw
neenjaw / readme.md
Created October 31, 2018 19:33
Python Tips

Some learning points

virtualenv

make new

virtualenv -p python3 ./env

activate / deactivate

@neenjaw
neenjaw / canada_states_titlecase.json
Created November 30, 2018 22:54 — forked from pbojinov/canada_states_titlecase.json
US states & Canadian Provinces in JSON form
[
{
"name": "Alberta",
"abbreviation": "AB"
},
{
"name": "British Columbia",
"abbreviation": "BC"
},
{
defmodule RobotSimulator do
alias RobotSimulator, as: RS
...
# Simulate robot position advancement
defp do_sim(r = %RS{direction: :north, position: {x, y}}, "A"), do: %{r | position: {x, y + 1}}
defp do_sim(r = %RS{direction: :east, position: {x, y}}, "A"), do: %{r | position: {x + 1, y}}
defp do_sim(r = %RS{direction: :south, position: {x, y}}, "A"), do: %{r | position: {x, y - 1}}
defp do_sim(r = %RS{direction: :west, position: {x, y}}, "A"), do: %{r | position: {x - 1, y}}
@neenjaw
neenjaw / tampermonkey.js
Last active May 12, 2019 04:08
Exercism.io -- Hide comment panel to increase readability of code panel
// ==UserScript==
// @name Exercism panel expand
// @namespace Exercism
// @version 0.1
// @description Expand coding panel by hiding the comment panel
// @author Tim Austin
// @match https://exercism.io/*/solutions/*
// @grant none
// ==/UserScript==
@neenjaw
neenjaw / mixify_all.sh
Created June 16, 2019 04:07
Mixify Exercism Shell Scripts
#!/bin/bash
EXERCISES=$(cd exercises; ls -d *)
for EXERCISE in $EXERCISES
do
echo "* Attempting mixify: ${EXERCISE}"
./mixify_exercise.sh ${EXERCISE}
done
# save this in the PATH as docker-clean
docker ps -aqf status=exited
xargs docker rm
docker images -qf dangling=true
xargs docker rmi
@neenjaw
neenjaw / test.sh
Created July 11, 2019 14:54
Neat snippit.
test_results=$(echo "$test_results" \
| grep "* test" \
| sed 's:\r:\n:' \
| awk 'NR % 2 == 1' \
| sed -r "s:\x1B\[31m:$(printf " -- \\033[31mFail\\033[0m"):g" \
| sed -r "s:\x1B\[32m:$(printf " -- \\033[32mPass\\033[0m"):g")
@neenjaw
neenjaw / Macro.md
Created July 16, 2019 11:24
Elixir Phoenix macro to generate crud routes
@neenjaw
neenjaw / say.ex
Created July 26, 2019 05:08
Say.exs alternate version
defmodule Say do
@doc """
Translate a positive integer into English.
"""
@ones_names %{
1 => "one",
2 => "two",
3 => "three",
4 => "four",