Skip to content

Instantly share code, notes, and snippets.

View brennv's full-sized avatar

Brennan Vincello brennv

View GitHub Profile
@brennv
brennv / pif.sh
Last active July 20, 2017 08:46
pif: A simple diff wrapper for pip
# Diff pip freeze after pip install or uninstall
# Example usage: pif install foo
pif() {
if [[ $@ == *'install'* ]]; then
r1=$(mktemp) && pip freeze > r1
pip "$@"
r2=$(mktemp) && pip freeze > r2
echo ' Pip freeze diff:'
diff r1 r2
rm -f r1 r2
@brennv
brennv / duckshift.py
Last active July 14, 2017 18:38
jump from the command line to the browser and search against specified sites
# Start a search against multiple sites from the command line
# Usage: python duckshift.py <search terms>
import sys
import subprocess
import webbrowser
try:
from urllib.parse import quote
except ImportError:
from urllib import quote # python 2
@brennv
brennv / trace.md
Last active May 19, 2017 19:25
Twitter -> Kafka -> RethinkDB: duplicate primary `id` trace

The fine folks at Datamountaineer have developed the stream-reactor making it easier to integrate data piplines with Kafka.

As a demo I'm streaming Twitter data to Kafka, and then from Kafka to RethinkDB.

Configs using Landoop's fast-data-dev environment:

Source: Twitter

name=TwitterSourceConnector
connector.class=com.eneco.trading.kafka.connect.twitter.TwitterSourceConnector
@brennv
brennv / app.py
Last active April 8, 2017 00:54
Session Interface example for url-based session max_age flip-flopping in Flask
from werkzeug.datastructures import CallbackDict
from flask.sessions import SessionInterface, SessionMixin
from itsdangerous import URLSafeTimedSerializer, BadSignature
from datetime import datetime, timedelta
class ItsdangerousSession(CallbackDict, SessionMixin):
def __init__(self, initial=None):
def on_update(self):
self.modified = True
CallbackDict.__init__(self, initial, on_update)
@brennv
brennv / gist:fb6e167d14f3718c6dc0bafbcd43b3df
Created August 3, 2016 07:03 — forked from ehazlett/gist:9241844
OpenShift Origin AWS

OpenShift Origin in AWS

This describes deploying and running OpenShift Origin in Amazon Web Services.

This is based upon the code and installer on 2014-02-26 so YMMV.

We will be using a VPC for deployment in us-east-1 and Route53 for DNS. I will leave the VPC setup as an exercise for the reader.

Prerequisites

  • AWS Account
  • VPC
@brennv
brennv / docker-compose.yaml
Last active July 5, 2016 19:46
Example local dev setup with arangodb
# Consider adding image: jwilder/nginx-proxy for managing routes
version: '2'
services:
arangodb:
image: arangodb/arangodb:3.0.0
ports:
- "8529:8529"
environment:
- ARANGO_NO_AUTH=1
app:
# Aggregate connection stats between source and destination apps
tshark -n -r example-file.pcap -T fields -e ip.src -e ip.dst -e tcp.dstport "tcp.flags == 0x0002" | sort | uniq -c | sort -nr
@brennv
brennv / rh-openshift-error-codes.txt
Created May 24, 2016 20:04 — forked from caruccio/rh-openshift-error-codes.txt
RedHat Openshift error codes (extracted from source files - grep+python). Neither comprehensive or 100% correct, but it is a start...
SHOW_APPLICATION:
404 Not Found:
101: "Application '#{id}' not found"
127: "Domain '#{domain_id}' not found"
UPDATE_CARTRIDGE:
404 Not Found:
163: "Cartridge '#{cartridge_name}' for application '#{app_id}' not found"
101: "Application '#{app_id}' not found for domain '#{domain_id}'"
import ephem
def is_daytime(city):
sun = ephem.Sun()
locale = ephem.city(city)
sun.compute(locale)
twilight = -12 * ephem.degree
is_sunlight = sun.alt > twilight
return is_sunlight
import os
import time
from datetime import datetime, timedelta
from tzlocal import get_localzone
def check_file_time_elpased(file_path):
ctime = time.ctime(os.path.getmtime(file_path))
last_updated = datetime.strptime(ctime), "%a %b %d %H:%M:%S %Y")
tz = get_localzone()
then = tz.normalize(tz.localize(last_updated))