Skip to content

Instantly share code, notes, and snippets.

View ahopkins's full-sized avatar

Adam Hopkins ahopkins

View GitHub Profile
@ahopkins
ahopkins / extract_emails_from_text.py
Created November 17, 2016 00:35 — forked from dideler/example.md
A python script for extracting email addresses from text files. You can pass it multiple files. It prints the email addresses to stdout, one address per line. For ease of use, remove the .py extension and place it in your $PATH (e.g. /usr/local/bin/) to run it like a built-in command.
#!/usr/bin/env python
#
# Extracts email addresses from one or more plain text files.
#
# Notes:
# - Does not save to file (pipe the output to a file if you want it saved).
# - Does not check for duplicates (which can easily be done in the terminal).
#
# (c) 2013 Dennis Ideler <[email protected]>
@ahopkins
ahopkins / flatten.py
Created January 29, 2017 22:24
Recursively flatten an arbitrary number of nested iterators.
l = [1, 2, 3, [4, 5, 6, [9, 8, 7, [12, 11, 10], 13, 14], 15, 16], 17, 18]
def flatten(input):
""" Flatten nested iterators. Looks specifically for lists, tuples, and sets, and returns them sorted"""
# Prepare the ourput variable
output = []
# Look for wheter an input is a list, tuple, or set

Keybase proof

I hereby claim:

  • I am ahopkins on github.
  • I am admhpkns (https://keybase.io/admhpkns) on keybase.
  • I have a public key whose fingerprint is F7EB FB5E 0003 E06F 64DE 76AC E8D8 907B 4272 FA55

To claim this, I am signing this object:

@ahopkins
ahopkins / sanic_feed.py
Last active September 28, 2019 21:08
Websocket feed using Sanic
from sanic import Sanic
import json
import asyncio
app = Sanic(__name__)
feeds = {}
class Feed(object):
for i in {1..100}; do curl -o /dev/null -s -w '%{time_total}\n' <URL>; done;
import Ember from 'ember';
export default Ember.Controller.extend({
appName: `Ember's Route Hook Order`,
queryParams: ['foo'],
foo: null,
actions: {
clearLog() {
Ember.$('.log-item').remove();
@ahopkins
ahopkins / # Sanic websocket feeds v1.md
Last active November 15, 2021 12:03
Sanic Websocket Feed

Sanic Websockets Feeds v1

This is an outdated version

See latest

@ahopkins
ahopkins / configure.sh
Created February 19, 2018 07:33 — forked from alexellis/configure.sh
Kubernetes-weave-ubuntu.sh
#!/bin/sh
sudo apt-get update \
&& sudo apt-get install -qy docker.io
sudo apt-get update \
&& sudo apt-get install -y apt-transport-https \
&& curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
@ahopkins
ahopkins / dictobj.py
Created March 10, 2018 23:36
DictObj
class DictObj(dict):
def __init__(self, **kwargs):
dict.__init__(self, **kwargs)
self.__dict__ = self
obj = DictObj(a=1)
print(obj.a) # 1
print(obj.get('a')) # 1
print(obj) # {'a': 1}
@ahopkins
ahopkins / progress.py
Created April 9, 2018 07:41 — forked from vladignatyev/progress.py
Python command line progress bar in less than 10 lines of code.
# The MIT License (MIT)
# Copyright (c) 2016 Vladimir Ignatev
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the Software
# is furnished to do so, subject to the following conditions:
#