Skip to content

Instantly share code, notes, and snippets.

View a-r-d's full-sized avatar
🍌

Aaron Decker a-r-d

🍌
View GitHub Profile
@a-r-d
a-r-d / states.as
Created May 2, 2014 16:03
Array of states in AS3. Could also be JavaScript.
public static const states:Array = [
{symbol:"AK",name:"Alaska"},
{symbol:"AZ",name:"Arizona"},
{symbol:"AR",name:"Arkansas"},
{symbol:"CA",name:"California"},
{symbol:"CO",name:"Colorado"},
{symbol:"CT",name:"Connecticut"},
{symbol:"DE",name:"Delaware"},
{symbol:"DC",name:"Dist of Columbia"},
{symbol:"FL",name:"Florida"},
@a-r-d
a-r-d / sclice_string.py
Created May 11, 2014 17:53
A little game for learning string slicing in python. Figure out the correct substring that should result from a given slice.
import random
score = 0
attempts = 0
test_words = [
"hello world",
"dolphin",
"waffles",
"pancakes",
"bannana"
@a-r-d
a-r-d / StaticSwapper.as
Last active August 29, 2015 14:01
Swaps the static vars from one class to another. Had to create this to do some configuration copying on a library class. Anyway, it is an example of reflection in AS3.
package com.example
{
import flash.utils.Dictionary;
import flash.utils.describeType;
public class StaticSwapper
{
public function StaticSwapper()
{
@a-r-d
a-r-d / swap.html
Last active August 29, 2015 14:07
Simple Image Swap
<div>
<a href=''>
<img class="image-swap-hover"
data-hover="http://i.imgur.com/EHQCuwT.png"
src="http://i.imgur.com/6xd21Qy.png"
width="500"
alt="Pikachu" />
</a>
</div>
<script>
@a-r-d
a-r-d / deploy-roots.sh
Last active August 29, 2015 14:07
Bash script for deploying roots themes. Packages theme file into a zip, omits .git and node_modules.
#!/bin/bash
#
# This is a simple deploy script to create a .zip file of your theme
# The first argument passed becomes the .zip filename.
echo "Building site for packaging..."
grunt build
echo "Begin zipping..."
FILE="roots-deploy-theme.zip"
if [ ! -z "$1" ]
then
@a-r-d
a-r-d / producthack.js
Last active August 29, 2015 14:11
Some hacky squarespace stuff to future reference
// http://answers.squarespace.com/questions/17107/how-can-i-have-the-image-change-with-the-variant-on-my-product-pages
jQuery(document).ready(function(){
var variantList = [];
// secret data stored in variants
jQuery('.product-variants').hide();
jQuery.each($('.product-variants'), function(i){
var variant = this;
console.log("Variant:");
@a-r-d
a-r-d / exceptions.java
Last active August 29, 2015 14:24
How exceptions work in Java
// Call some method that may throw an exception!
private void derp() throws Exception {
somethingDangerous();
}
private void derpCaller() {
try {
derp();
} catch (Exception e) {
@a-r-d
a-r-d / BalanceDelimiters.java
Last active September 13, 2015 20:15
Just a common interview problem for balancing parens using a stack.
package derp;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Stack;
public class BalanceDelimiters {
@a-r-d
a-r-d / StackWithMinVal.java
Created September 13, 2015 21:53
A java class that is a generic stack data structure that tracks the min value.
package hackerrank;
public class StackWithMinVal {
public class Node<T extends Comparable<T>> {
public T value;
public Node<T> prev;
@Override
public String toString() {
@a-r-d
a-r-d / NQueensBacktracking.java
Created September 20, 2015 07:34
Some experimenting with N-Queens problem
import java.util.Arrays;
public class NQueensBacktracking {
public static void main(String[] args) {
greedyRunner(8);
greedyRunner(10);
greedyRunner(15);
greedyRunner(20);
greedyRunner(22);