Skip to content

Instantly share code, notes, and snippets.

@aheld
aheld / jira_metrics.rb
Created June 12, 2012 19:01
JIRA API quick and dirty calculations
require 'pp'
require 'rubygems'
require 'open-uri'
require "uri"
require "net/http"
require 'openssl'
require 'json'
require 'digest/sha1'
@aheld
aheld / APIProxyHandler.cs
Created November 15, 2012 20:22
.net http proxy hack to allow javascript in the browser to authenticate against IIS and have the server call out to antother server
/*
This allows a javascript app to hit a relative url such as
/Proxy/myapp.com/api/rest/2/issues
and then have the server make a call to
http://myapp.com/api/rest/2/issues
@aheld
aheld / Random Philly Addresses
Last active December 16, 2015 11:49
Random Philly addresses, python style You need to pip install names for this to work
import random
import names
streets = "Vine,Race,Cherry,Arch,John F Kennedy Boulevard,Market,Chestnut,Sansom,Walnut,Locust,Spruce,Pine,Lombard,South".split(',')
second = "suite,apartment,unit".split(',')
def gen2():
if random.randrange(100) <= 30:
return "%s #%s" % (random.choice(second), random.randrange(20))
else:
@aheld
aheld / main.java
Created July 14, 2013 19:48
Connecting to Microsoft Exchange using Java to download email messages
import microsoft.exchange.webservices.data.*;
import java.net.URI;
public class Main {
public static void main(String [] args) throws Exception {
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
ExchangeCredentials credentials = new WebCredentials("[email protected]","PASSWORD");
service.setCredentials(credentials);
service.setUrl(new URI("https://EXCHANGE_SERVER_API_DOMAIN/ews/exchange.asmx"));
@aheld
aheld / pdf extracter
Created September 24, 2013 18:41
Quick and Dirty way to extract names our out of a PDF file and into a CSV file. Inspired (copied) from http://thottingal.in/blog/2009/06/24/pdfbox-extract-text-from-pdf/
package com.aaronheld;
import org.apache.pdfbox.cos.COSDocument;
import org.apache.pdfbox.pdfparser.PDFParser;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.util.PDFTextStripper;
import java.io.File;
import java.io.FileInputStream;
def bray(n):
if n < 1: return 0
if n == 1: return 1
accumulator = 1 + (2 * n-2) # this is the same as 1 + 2 + 2 +2 ....
return accumulator + bray(n-1)
for n in range(10):
bray(n)
print("n=%3d: bray(n) = %s\t square(n): %5d" % (n,bray(n),n*n) )
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"Amateurs talk about tactics, but professionals study logistics."
- Gen. Robert H. Barrow, USMC
%
If you don't have time to do it right, when will you have time to do it over?
John Wooden
%
When you can measure what you are speaking about, and express it in numbers, you know something about it; but when you cannot measure it, when you cannot express it in numbers, your knowledge is of a meagre and unsatisfactory kind
-Lord Kelvin 1883
%
"Beautiful as that wonderful work of nature [Niagara] is, it would be more beautiful still if those waters fell upon turbine wheels every one of which was turning the wheels of industry."
@aheld
aheld / batchit.py
Last active June 10, 2016 21:02
simple batching of a generator
from pprint import pprint
from itertools import chain, islice
from time import sleep
from random import random
def make_req(x):
return {'id': x}