Skip to content

Instantly share code, notes, and snippets.

View addy's full-sized avatar
😸
Body found floating by the docks

Addison Shaw addy

😸
Body found floating by the docks
View GitHub Profile
var palette = new Rickshaw.Color.Palette();
var graph = new Rickshaw.Graph( {
element: document.querySelector("#chart"),
width: 550,
height: 250,
series: [
{
name: "dubstep",
data: [ { x: 1990, y: 0 }, { x: 1991, y: 0 }, { x: 1992, y: 0 }, { x: 1993, y: 0 }, { x: 1994, y: 0 }, { x: 1995, y: 0 }, { x: 1996, y: 0 }, { x: 1997, y: 0 }, { x: 1998, y: 0 }, { x: 1999, y: 0 }, { x: 2000, y: 1 }, { x: 2001, y: 1 }, { x: 2002, y: 0 }, { x: 2003, y: 1 }, { x: 2004, y: 2 }, { x: 2005, y: 6 }, { x: 2006, y: 21 }, { x: 2007, y: 26 }, { x: 2008, y: 41 }, { x: 2009, y: 48 }, { x: 2010, y: 36 }, { x: 2011, y: 0 } ],
public class Solution {
public Map<Character, GraphNode> map = new HashMap<>();
public Set<String> relations = new HashSet<>();
public Set<GraphNode> visited = new HashSet<>();
public Stack<GraphNode> topSort = new Stack<>();
public String alienOrder(String[] words)
{
for (int i = 0; i < words.length - 1; i++)

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@addy
addy / public.asc
Created March 6, 2018 02:11
Public Key
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQGNBFqV6E4BDADKqAHZA4fyBWh/f8CZ6J++F3aNpiOm2otRfCINMV3Sq+Qd6AZT
bkjSDDGTnukFVcz4QMzWY69CqvOZn4dAFTewCY9oIwVmzMDFpRXPuAGttwb0dF0q
CNWJLQpdhrgCZX556hxHqohOnHMnJZL7w6gpM3kJMB6IfRSkAyIVyTFQXT8PrP8A
8CBFRh/gQSe+dmsQhyR5pYmrQj0Lt+2DnBjZx+DDQr5X1dj5uMwES+ynXB6PNzlU
TI4ChB2n3Y5PhwuH5BlJjhy0dHikhS6XCeaTry4wbKNgbIBKFvRRxTFdfQlnAbLK
s38/XvAGtlbCDmFtB5bOzqoNy1y2vlQt3BODC465Erj/vkGS/h3ua+wC4mOnkdF3
@addy
addy / main.rs
Created March 6, 2018 03:35
Mandelbrot Image Maker
extern crate num;
extern crate image;
extern crate crossbeam;
use image::ColorType;
use image::png::PNGEncoder;
use num::Complex;
use std::str::FromStr;
use std::fs::File;
use std::io::Write;
Verifying my Blockstack ID is secured with the address 1HqBxWXEih8ob6PrEH4wCDMNto4TKTcJbn https://explorer.blockstack.org/address/1HqBxWXEih8ob6PrEH4wCDMNto4TKTcJbn
class Solution
{
public double[] calcEquation(String[][] equations, double[] values, String[][] queries)
{
Map<String, Map<String, Double>> graph = new HashMap<>();
double[] ret = new double[queries.length];
for (int i = 0; i < equations.length; i++) {
String first = equations[i][0];
String second = equations[i][1];
if (!graph.containsKey(first)) {
@addy
addy / trie.js
Created February 19, 2019 20:45
trie.js
/*
This is just a small implementation of a Trie, used to store keys to an external map
in the 'leaves' of the tree. This can be used to make reverse lookup in a word map much
more efficient.
*/
class Node {
constructor(val) {
this.val = val;
this.children = new Map();
this.parent = null;
@addy
addy / two_sum.rs
Created March 16, 2019 00:35
Two Sum
use std::collections::HashMap;
use std::vec::Vec;
pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
let mut seen = HashMap::new();
for (i, num) in nums.iter().enumerate() {
let val = target - num;
match seen.get(&val) {
Some(&k) => return vec![k as i32, i as i32],
@addy
addy / find_permutation.java
Created July 17, 2019 02:31
find_permutation
public int[] findPermutation(String s) {
char[] c = s.toCharArray();
int[] ret = new int[c.length + 1];
int start = 0;
int low = 1;
int iIndex = 0;
while (start < c.length)
{
// Look for our first 'I', increasing "low" so that
// later when we iterate to our 'I' index, decreasing low, we don't hit 0.