Skip to content

Instantly share code, notes, and snippets.

View rosshadden's full-sized avatar

Ross Hadden rosshadden

View GitHub Profile
[Finch]
mouse = 1
color-available = green; black
color-away = blue; black
color-idle = gray; black
color-offline = red; black
color-message-sent = cyan; default
color-message-received = red; default
color-message-highlight = black; green
color-message-action = yellow; default
// A: This is valid JS:
var foobar = {
foo: function bar() {
// pass
}
};
// B: This is valid ES6
let foobar = {
foo() {
@rosshadden
rosshadden / DeadLock.java
Last active January 4, 2016 07:39
cs4003 - 2
class Monitor {
String name;
public volatile boolean locked = false;
public Monitor(String name) {
this.name = name;
}
public String getName() {
return this.name;
@rosshadden
rosshadden / unity-sublime.sh
Created December 17, 2013 21:26
Open Unity3D scripts in Sublime Text, including line number support when clicking on errors. I wrote this for Unity running in wine in Linux to open the Linux-installed Sublime, but it would probably work on all platforms.
#!/usr/bin/env bash
# 1) Give this file +x permissions.
# 2) Replace MonoDevelop.exe with a symlink pointing to this file.
subl "$(echo $3 | sed 's|^Z:||' | sed 's|\\|/|g' | sed 's|;|:|')"
@rosshadden
rosshadden / cornerstone:controllers:index.js
Created October 3, 2013 14:51
Controller syntax experimenting for Cornerstone.
var services = app.util.loader.dirSync("services");
var routes = {
"/"(req, res, next) {
// Render the view found at /views/index.html.
res.view("index");
},
"/test": {
get(req, res, next) {
@rosshadden
rosshadden / checkClass.sh
Created July 24, 2013 03:06
Script that takes one argument (a class id) and tells you how many seats are available for the class at University of Cincinnati.
#!/bin/bash
curl 'https://webapps2.uc.edu/scheduleofclasses/Details.asmx/Class' -H 'Pragma: no-cache' -H 'Origin: https://webapps2.uc.edu' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Host: webapps2.uc.edu' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1568.0 Safari/537.36' -H 'Content-Type: application/json; charset=UTF-8' -H 'Accept: */*' -H 'Cache-Control: no-cache' -H 'X-Requested-With: XMLHttpRequest' -H 'Cookie: __qca=P0-1621544612-1365361687310; ASP.NET_SessionId=gnsrz1rul2nvx51h4f2zblzq; webapps2uceducookie=ey5hOkc7j+t/KpNyYpKoOeYlNKHEwOQcVbv8g/JMr5HSxFjEI92jFDEib/DGPIvDXNRCeVWiP7lgUQ==; CookiesChecked=true; .ASPXAUTH=6A0499BF7BCD661E80CA972504265E9A47B8E972104A357E8BB09E3EA29D7E91A9E83E9EC27F80EE8BD798A4785B2B7A5E13C21E5F19379EB2C9F0518CC9338B3043B731C82959DC8101524738A70257E92F0B9BC0773037CD1100817828E862321B5241746AFFB3234DA4B4E4A9AFD06BF8B85B; __RequestVerificationToken_L1N0dWRlbnRJQVBSZXZpZXc_=qhB91oG/zb+WOPt
@rosshadden
rosshadden / ES6-class-methods.js
Last active May 28, 2018 03:58
Dilemma in trying to obtain method list of child class from the parent constructor.
// Let's call this fileA.js.
class Controller {
constructor() {
// This is the only way I can figure out how to do what I need, but it feels shitty.
var routes = [];
for (var route in this) {
if (typeof this[route] === "function") {
routes.push(route);
}
}
@rosshadden
rosshadden / 1.py
Created February 27, 2012 19:05
Enigma
from enigma import *
machine = Enigma()
machine.setRotorPositions('A','A','A','A')
machine.setPlugboard({12:3,2:21,13:16,6:14,5:17,18:25,20:8,24:19,11:10,9:0,15:7,22:1,4:23})
result = machine.decrypt('gnzbhnlxjikohyymbfhmitoicdossllwinhybzr',True)
print(result)
@rosshadden
rosshadden / rotors.py
Created February 18, 2012 21:56
Rotors
rotors = [
[22,5,1,19,8,25,13,20,21,2,16,4,9,15,14,10,18,7,23,6,12,0,3,24,17,11],
[7,12,17,6,13,16,15,10,9,0,2,8,21,22,11,20,4,1,5,25,18,24,23,19,3,14],
[3,17,20,0,7,11,1,5,25,21,6,12,22,2,10,23,15,8,16,24,18,14,13,19,9,4],
[14,22,19,21,18,10,24,15,9,8,5,12,11,20,0,7,17,16,4,2,13,3,1,25,6,23]
]
inverseRotors = [[None] * 26] * 3
for r,rotor in enumerate(inverseRotors):
@rosshadden
rosshadden / Enigmorama.py
Created February 18, 2012 20:39
Enigmorama!
import math
################################
# VARIABLES
################################
code = 'gnzbhnlxjikohyymbfhmitoicdossllwinhybzr'
message2 = 'heythereross'
log = i = 1
r0 = r1 = r2 = r3 = 0