Skip to content

Instantly share code, notes, and snippets.

View joelcrocker's full-sized avatar

Joel Crocker joelcrocker

  • PagerDuty
  • Toronto, ON
View GitHub Profile
@ali1234
ali1234 / bb8.py
Created October 17, 2015 15:47
Control Sphero BB-8 from Linux.
#!/usr/bin/env python
# BB-8 Python driver by Alistair Buxton <[email protected]>
from bluepy import btle
import time
class BB8(btle.DefaultDelegate):
def __init__(self, deviceAddress):
@kacy
kacy / gist:2b9408af04c71fab686e
Last active June 16, 2020 20:22
CVE-2014-6271 fix for ubuntu bash
---
- hosts: all
user: root
sudo: true
tasks:
- name: update apt
command: apt-get update
- name: update bash
@guapodero
guapodero / scrollfollow.coffee
Last active December 30, 2015 04:09
Derived from http://isotope11.com/blog/make-a-snappable-cart-directive-with-angularjs Usage <div scrollfollow="45" id="scrollfollow1"> I stick to the viewport on scroll, 45 pixels from the top. I'll stay aligned to a grid like that of Bootstrap 3, leaving the normal page flow without creating a wake. You can also disable me with media queries an…
angular.module("ui-utils-too", []).
directive("scrollfollow", ["$window", ($window) ->
restrict: "A"
link: (scope, el, attrs) ->
window = angular.element($window)
parent = angular.element(el.parent())
currentOffsetTop = el[0].getBoundingClientRect().top
headerOffsetTop = scope.$eval(attrs.scrollfollow) || 5
# assumes width/padding in px
@joelcrocker
joelcrocker / group_tuples.py
Last active December 28, 2015 20:19
Tuple grouping function. Useful for collapsing tabular data from left to right. Uses toolz; see http://toolz.readthedocs.org/en/latest/ See usage.txt below for examples.
from toolz.itertoolz.core import reduceby
from toolz.dicttoolz.core import valmap
def group_tuples(tuples):
if len(tuples[0]) < 2:
return [t[0] for t in tuples]
result = reduceby(
lambda t: t[0],
lambda a, b: a + [b[1:]],
tuples,
@plentz
plentz / nginx.conf
Last active November 14, 2024 08:35
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@mikeyk
mikeyk / watch_wal-e.py
Created January 16, 2013 20:24
Watch_wal-e script
#! /usr/bin/env python
from boto.ses.connection import SESConnection
import os
import sys
import subprocess
import socket
TMPFILE = '/var/run/postgresql/last-wal-archive-error-file.tmp'
if __name__ == '__main__':
@bennylope
bennylope / LICENSE
Last active August 17, 2023 10:44
Django manage.py file that loads environment variables from a .env file per Honcho/Foreman
Copyright the authors of Honcho and/or Ben Lopatin
Licensed for reuse, modification, and distribution under the terms of the MIT license
@ruckus
ruckus / gist:2293434
Created April 3, 2012 16:36
Basic setup of WAL-E for continuous archiving and recovery

WAL-E needs to be installed on all machines, masters and slaves.

How to install WAL-E

Only one machine, the master, writes WAL segments via continuous archiving. The configuration for the master postgresql.conf is:

archive_mode = on
archive_command = 'envdir /etc/wal-e.d/env wal-e wal-push %p'
archive_timeout = 60
@asmallteapot
asmallteapot / nginx.conf
Created March 14, 2012 19:00
My default Nginx configuration for serving Django projects.
# file: /etc/nginx/sites-available/example.com
# nginx configuration for example.com
server {
listen 80;
server_name example.com;
access_log /srv/www/example.com/logs/access.log;
error_log /srv/www/example.com/logs/error.log;
# pass root to django
@kesor
kesor / profile_middleware.py
Last active March 16, 2021 15:37
Django cProfile middleware
from django.core.exceptions import MiddlewareNotUsed
from django.conf import settings
import cProfile
import pstats
import marshal
from cStringIO import StringIO
class ProfileMiddleware(object):
def __init__(self):
if not settings.DEBUG: