Skip to content

Instantly share code, notes, and snippets.

Brennan Holzer bholzer

View GitHub Profile
View matasano.scala
object Matasano {
def hexToBytes(hex: String): Array[Byte] = {
hex.replaceAll("[^0-9A-Fa-f]", "").sliding(2,2), 16).toByte)
def bytesToHex(bytes: Array[Byte]): String = {"%02x" format _).mkString
def encode64(b: Array[Byte]): String = {
View gist:9040346
var xpathObj = document.evaluate("//a[text()='Birmingham Mountain Radio']/@href/ancestor::h5[1]/following-sibling::div[contains(@class, 'userContent')]", document, null, XPathResult.ANY_TYPE, null)
var result = xpathObj.iterateNext();
while (result) {
if (result.textContent.indexOf('ticket')>=0 && (result.textContent.indexOf('win')>=0 || result.textContent.indexOf('free')>=0)) {
console.log('get dem tickets!');
result = xpathObj.iterateNext();
import java.awt.Color;
import java.util.*;
public class ColorUtilities {
public static Color getClosestColorFrom(List<Color> colorList, Color closestTo) {
double shortestDistance = Double.MAX_VALUE;
Color closestColor = closestTo;
for (Color color : colorList) {
if (!color.equals(closestTo)) {
double distance = (closestTo.getRed()-color.getRed())*(closestTo.getRed()-color.getRed())+
View a.js
//Set up modules
(function() {
'use strict';
angular.module('autoMailer', ['ui.router']);
angular.module('autoMailer.providers', []);
angular.module('autoMailer.directives', []);
angular.module('autoMailer.filters', []);
angular.module('autoMailer.controllers', []);
View gist:9864704
def import_contacts(file)
contact_file =['contact','.xlsx'], :encoding => 'ASCII-8BIT')
contacts = CSV.parse(
View gist:9864403
def import_contacts(file)
contacts = CSV.parse(
View a.html
<!DOCTYPE html>
<body bgcolor="cyan">
<h1>My First Program</h1>
<button onclick="X()"><p ID="Y">Hey You!</p></button>
<input type="text" value="Z" name="Z">
<button onclick="Q()"><p>..</p></button>
View gist:10306989
filename = "2009_shots.csv"
def readfile(fname):
'''Read the input file, return a list with all lines from the file'''
f = open(fname, 'r')
file_lines = f.readlines()
for i in range(0, len(file_lines)):
file_lines[i] = file_lines[i].strip()
return file_lines
View upload.js
$files.forEach(function ($file) {
console.log('Should request'); //This runs as many times as there are images
var filePromise = $'/api/images/upload').then(function (aws){ //This request runs only once
console.log(aws) //This also runs as many times as there are images, but aws is same EVERY TIME.
//Go on to upload file to S3
import sys
def main():
Scanner = Scanner("info.dat")
Boolean = Scanner.readbool()
String = Scanner.readstring()
Number = Scanner.readint() #no need to wrap this in int() since readint will do that automatically
if Boolean: #Here, you don't need to do == "True" because the readbool function automatically converts things correctly
You can’t perform that action at this time.