Skip to content

Instantly share code, notes, and snippets.

View rockwotj's full-sized avatar
:shipit:

Tyler Rockwood rockwotj

:shipit:
View GitHub Profile
#!/usr/bin/env python
import sys
import os
import argparse
from os import path
from os.path import isfile as exists
import signal
import json
import xml.etree.ElementTree as ET
@rockwotj
rockwotj / motd.sh
Created January 6, 2017 05:54
Raspberry Pi motd
#!/bin/bash
clear
function color (){
echo "\e[$1m$2\e[0m"
}
function extend (){
local str="$1"
@rockwotj
rockwotj / weatherpics-rules.bolt
Last active January 20, 2016 16:32
Firebase bolt rules for the Weatherpics With Auth App
type Weatherpic {
caption: String | Null,
imageUrl: String,
uid: UserID
}
type UserID extends String;
path /weatherpics {
read() { true }
@rockwotj
rockwotj / password-keeper-rules.bolt
Last active January 9, 2016 22:19
Firebase bolt rules for the Password Keeper App
path /users/$uid {
read() = isCurrentUser($uid);
write() = isCurrentUser($uid);
}
path /users/$uid/$password is Password;
type Password {
service: String,
password: String,
@rockwotj
rockwotj / moviequote-rules.bolt
Last active January 9, 2016 21:58
Firebase bolt rules for the Moviequotes App
path /quotes {
write() = true;
read() = true;
}
path /quotes/$moviequote is Moviequote;
type Moviequote {
movie: String,
quote: String
@rockwotj
rockwotj / godist.rb
Created December 6, 2015 01:53
A short ruby script to cross platform a golang project
#! /usr/bin/env ruby
if not ARGV[0] or ARGV[0] == "-h"
puts "Usage: ./go_dist <project>"
exit
end
project_path = ARGV[0]
project = project_path.split('/')[-1]
puts "\e[1mStarting distribution of \e[32m'#{project}'\e[0m"
platforms = {
@rockwotj
rockwotj / download_anonymous_icons_from_drive.rb
Last active December 13, 2023 03:30
Downloads all of the icons of anonymous animals from Google Drive
#!/usr/bin/env ruby
icon_list = "alligator, anteater, armadillo, auroch, axolotl, badger, bat, beaver, buffalo, camel, chameleon, cheetah, chipmunk, chinchilla, chupacabra, cormorant, coyote, crow, dingo, dinosaur, dolphin, duck, dragon, elephant, ferret, fox, frog, giraffe, gopher, grizzly, hedgehog, hippo, hyena, jackal, ibex, ifrit, iguana, koala, kraken, lemur, leopard, liger, llama, manatee, mink, monkey, narwhal, nyan cat, orangutan, otter, panda, penguin, platypus, python, pumpkin, quagga, rabbit, raccoon, rhino, sheep, shrew, skunk, slow loris, squirrel, turtle, walrus, wolf, wolverine, wombat"
for icon in icon_list.split ', ' do
element = icon.sub ' ', ''
`curl https://ssl.gstatic.com/docs/common/profile/#{element}_lg.png -o icons/#{element}.png`
end
@rockwotj
rockwotj / Questions.md
Last active August 29, 2015 14:26
Programming practice for interviews - Don't use an IDE!
  1. Take an absolute path and reduce it: /a/b/../foo.txt -> /a/foo.txt, /a/../b/./foo.txt -> /b/foo.txt

  2. You are given an array representing integer. Write a function which increments this integer. Example: input [1,2,3] -> output [1,2,4] which represents 123 + 1 = 124

  3. Given an unbalanced binary tree, write code to select a node at random (each node has an equal probability of being selected).

@rockwotj
rockwotj / C# Combinatorics
Last active August 29, 2015 14:10
A couple of common combinatorics question solutions in C#
public static List<List<T>> GeneratePowerSet<T>(List<T> list)
{
var result = new List<List<T>>();
if (list.Count > 0)
{
foreach (var t in GeneratePowerSet(list.GetRange(1, list.Count - 1)))
{
result.Add(t);
var temp = DeepCopy(t);
temp.Add(list[0]);
@rockwotj
rockwotj / Java TCP Server Wrapper
Last active June 29, 2017 08:25
This java class is a high level wrapper for the java ServerSocket class and is made to make string communication a lot easier.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;