Skip to content

Instantly share code, notes, and snippets.

View aezell's full-sized avatar
😶

Alex Ezell aezell

😶
View GitHub Profile
import os
import csv
import pprint
import re
import sys
import time
import calendar
import datetime
import requests
@zcourts
zcourts / gh-importer.py
Last active August 10, 2022 19:31 — forked from dasevilla/github-issue-to-phab-task.py
Copy GitHub issues to Phabricator
import json
import os
import sys
import requests
import envoy
GITHUB_TOKEN = os.environ.get('GITHUB_TOKEN')
if GITHUB_TOKEN is None:
raise Exception('Missing GITHUB_TOKEN from os.environ')
from sqlalchemy import engine
from sqlalchemy import event
class DbStats():
def __init__(self):
self.clear()
def clear(self):
self.total_queries = 0
self.total_time = 0
@kevinmcconnell
kevinmcconnell / threaded.py
Created March 28, 2014 02:40
Run some tasks in threads and wait until one of them returns something truthy (or until they all finish)
from threading import Thread, Semaphore
class FirstToReturn:
def __init__(self):
self._tasks = []
self._results = []
self._signal = Semaphore()
def run(self, fn, *args, **kwargs):
@briandailey
briandailey / gist:6604310
Created September 18, 2013 03:46
Hit explainshell.com for help.
function halpme() { curl -s "http://explainshell.com/explain/$1" --data-urlencode "args=${@:2}" -G | sed -n '/<table id="help"/,/<\/table>/p' | sed 's/ *//' | sed 's/<[^>]*>//g' | grep -v "^$" }
# EX:
# ~ ❯ halpme tar -xzf
# The GNU version of the tar archiving utility
# -x, --extract, --get
# extract files from an archive
# -z, --gzip, --gunzip --ungzip
# -f, --file ARCHIVE
# use archive file or device ARCHIVE
@binarymatt
binarymatt / loader.py
Created February 17, 2012 13:53
load arbitrary functions - note, on the fs test1 and test2 should be in the lib directory
import os, os.path
import lib
import types
def init():
#walk lib and import modules
module_set = set([os.path.splitext(module)[0] for module in os.listdir('lib') if not module.startswith('__init__')])
module_set = [m for m in module_set]
mods = __import__('lib',globals(), locals(), module_set, -1)
return mods, module_set
@ehazlett
ehazlett / transcribe.py
Created December 27, 2011 01:02
Logs Redis Pub/Sub messages to MongoDB
#!/usr/bin/env
#
# Requirements:
# argparse==1.2.1
# pymongo==2.1
# redis==2.4.10
import redis
import pymongo
import argparse
@bcambel
bcambel / mongo_pubsub.rb
Created November 16, 2011 14:08 — forked from octplane/mongo_pubsub.rb
Simple Pub/Sub system using MongoDB, capped collections and tailable cursors in ruby
require 'rubygems'
require 'mongo'
module MongoPubSub
QUEUES_COLLECTION = 'queues'
class EndSubscriptionException < Exception; end
class Publisher
def initialize(queue_name, mongo_connection)
# Initialize queue collection as a capped collection
if not mongo_connection[QUEUES_COLLECTION].collection_names.include?(queue_name)
@tekkub
tekkub / gist:1203061
Created September 8, 2011 10:02
Git aliases to prune merged branches
[alias]
prunelocal = !sh -c 'git branch -d `git branch --merged | grep -v "^*" | tr -d "\\n"`'
pruneorigin = !sh -c 'git push origin `git branch -r --merged | grep \"^ origin/\" | grep -v "/master$" | sed "s/origin./:/g" | tr -d "\\n"`'
@fffabs
fffabs / gist:550084
Created August 25, 2010 19:11
A basic Python wrapper for the new Forrst API
import urllib2
import simplejson
API_URL = 'http://api.forrst.com/api/'
VERSION = 'v1'
# Compose the base URL - maybe at __init__ ?
URL = API_URL + VERSION
class Forrst: