Skip to content

Instantly share code, notes, and snippets.

View cgoldberg's full-sized avatar
☠️
¯\_(ツ)_/¯

Corey Goldberg cgoldberg

☠️
¯\_(ツ)_/¯
View GitHub Profile
@cgoldberg
cgoldberg / camel.pl
Created December 18, 2012 21:26
Perl Camel code - render 4 ascii camels from camel-styled source code.
#!/usr/bin/perl -w # camel code
use strict;
$_='ev
al("seek\040D
ATA,0, 0;");foreach(1..3)
{<DATA>;}my @camel1hump;my$camel;
my$Camel ;while( <DATA>){$_=sprintf("%-6
9s",$_);my@dromedary 1=split(//);if(defined($
_=<DATA>)){@camel1hum p=split(//);}while(@dromeda
@cgoldberg
cgoldberg / gource-multiple-repositories.sh
Last active March 25, 2024 19:35 — forked from derEremit/gource-multiple-repositories.sh
Generates gource video of multiple source code repositories.
#!/usr/bin/env bash
# Generates gource video out of multiple repositories.
# First, get a local branch/clone of each repository.
# Then, pass the repositories as command line arguments.
#
# Example:
# $ gource-multiple-repositories.sh /path/to/repo1 /path/to/repo2
@cgoldberg
cgoldberg / merge_junit_results.py
Last active January 10, 2024 19:19
Merge multiple JUnit XML results files into a single results file.
#!/usr/bin/env python
"""Merge multiple JUnit XML results files into a single results file."""
# MIT License
#
# Copyright (c) 2012 Corey Goldberg
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@cgoldberg
cgoldberg / geckodriver-install.sh
Last active August 18, 2023 10:20
download and install latest geckodriver for linux or mac (selenium webdriver)
#!/bin/bash
# download and install latest geckodriver for linux or mac.
# required for selenium to drive a firefox browser.
install_dir="/usr/local/bin"
json=$(curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest)
if [[ $(uname) == "Darwin" ]]; then
url=$(echo "$json" | jq -r '.assets[].browser_download_url | select(contains("macos"))')
elif [[ $(uname) == "Linux" ]]; then
url=$(echo "$json" | jq -r '.assets[].browser_download_url | select(contains("linux64"))')
@cgoldberg
cgoldberg / get_image_info.py
Last active August 18, 2023 02:05
validate and analyze dimensions of [PNG, JPG, GIF], image files in Python.
#!/usr/bin/env python
#
# Corey Goldberg, 2013
#
# Python 2.7
"""validate and analyze dimensions of image files. Supports: PNG, JPG, GIF."""
@cgoldberg
cgoldberg / metric_to_graphite.js
Last active July 20, 2023 10:12
send metric data to hosted graphite via HTTP POST.
/* send a metric to hosted graphite via HTTP POST (async). */
function sendMetricToGraphite(metricName, value) {
var apiKey = YOUR-API-KEY;
var url = "https://" + apiKey + "@www.hostedgraphite.com/api/v1/sink";
var request = new XMLHttpRequest();
request.open("POST", url, true);
request.send(metricName + " " + value);
};
@cgoldberg
cgoldberg / gource.sh
Created July 2, 2013 14:05
Gource - Mir development video
# install bzr and gource
# get a branch of Mir's trunk code
# create gource video
$ sudo apt-get install bzr gource
$ bzr branch lp:mir
$ cd mir
$ gource \
-s .06 \
@cgoldberg
cgoldberg / mailbox.py
Created November 26, 2012 18:33
MailBox class for processing IMAP email (Gmail from Python example)
#!/usr/bin/env python
"""MailBox class for processing IMAP email.
(To use with Gmail: enable IMAP access in your Google account settings)
usage with GMail:
import mailbox
@cgoldberg
cgoldberg / timer.py
Created June 16, 2012 23:06
Python Timer Class - Context Manager for Timing Code Blocks
#!/usr/bin/env python
#
# Python Timer Class - Context Manager for Timing Code Blocks
# Corey Goldberg - 2012
#
from timeit import default_timer
""""Create "The Matrix" of binary numbers scrolling vertically in your terminal.
original code adapted from juancarlospaco:
- http://ubuntuforums.org/showpost.php?p=10306676
Inspired by the movie: The Matrix
- Corey Goldberg (2013)
Requires: