Skip to content

Instantly share code, notes, and snippets.

@beeftornado
beeftornado / app.coffee
Created November 16, 2013 00:14
Very rough, unoptimized, but functional plugin to Gridster.js that adds some responsiveness.
# Example to initialize gridster and handle resizing
# Module grid settings
WIDGET_BASE_DIMENSIONS_X = WIDGET_DESKTOP_X = 140
WIDGET_BASE_DIMENSIONS_Y = 20
WIDGET_CONTAINER_SELECTOR = '.widget-view'
WIDGET_MOBILE_CUTOFF_WIDTH = 768
NUM_WIDGETS = 15
$ ->
@beeftornado
beeftornado / _Library_LaunchDaemons_com.beeftornado.ipfw.plist
Last active March 5, 2016 09:43
Limiting time machine bandwidth on my OSX Mavericks machine
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST
1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.beeftornado.ipfw</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/ipfwstartup.sh</string>
@beeftornado
beeftornado / byobu-persist.rb
Last active May 17, 2022 18:46
Save byobu (a tmux wrapper) sessions to a shell script that can be run to restore the session.
#!/usr/bin/env ruby
# Modified version of https://github.com/geebee/tmux-persistence to work with byobu
# and work on OSX.
require 'fileutils.rb'
# Start - Configuration Variables
sessionDir = ENV['HOME']+"/.byobu-sessions"
maxStoredSessions = 5
@beeftornado
beeftornado / broken_socket.py
Last active April 21, 2020 22:55
Python simulate broken dns for unit tests
# # Broken Socket
""" A broken socket implementation.
Credits:
* [A. Jesse Jiryu Davis](http://emptysqua.re/blog/undoing-gevents-monkey-patching/)
Monkey patches the built in socket implmentation so that various exceptions are
raised. Useful for running unit tests to validate behavior when connections
@beeftornado
beeftornado / urllib2_retrieve_auth.py
Created June 4, 2014 00:09
Retrieving basic auth credentials from urllib2's HTTPPasswordMgr for the purpose or transparently transitioning over to requests module.
"""
Assuming you have this lovely gem somewhere else in your app from the old days
..sourcecode:: python
import urllib2
mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
for name, creds in services.items(): # dict of tuples: {name: (uri, user, pass)}
mgr.add_password(None, *creds)
def public(f):
'''
Decorator used to assign the attribute __public__ to methods.
'''
f.__public__ = True
return f
class Protected(object):
'''
Base class of all classes that want to hide protected attributes from
@beeftornado
beeftornado / api.py
Created June 4, 2014 19:28
API route prefixes with bottle. So you don't have to type @route('/api/name/blah') every time. You can just use @route('/blah')
# -*- coding: utf-8 -*-
# # Site API
# ## Imports
# Standard libs
# Third party libs
import bottle
from bottle import get, post, route
@beeftornado
beeftornado / rmtree.rb
Created July 16, 2014 22:41
Homebrew external command to remove a formula and its dependencies that are no longer used. Warning: Not all formulas declare all their dependencies.
# Install to /usr/local/Library/Homebrew/cmd/rmtree.rb
require 'keg'
require 'formula'
require 'shellwords'
module Homebrew
def rmtree
raise KegUnspecifiedError if ARGV.named.empty?
@beeftornado
beeftornado / sophos-anti-virus-home-edition91.rb
Last active July 27, 2018 15:29
sophos-anti-virus-home-edition91.rb
class SophosAntiVirusHomeEdition91 < Cask
module Utils
@@services = nil
def self.disable_sophos_services
# Stop any existing sophos or the install could hang
# Maybe it was only the permissions issue and not existing sophos, double check if needed
cmd = ['/usr/bin/sudo', '-E', '--', '/bin/launchctl', 'list'].join(' ')
@@services = `#{cmd}`
@@services.split.find_all{ |service| service.include? 'com.sophos' }.each do |service|
ohai "Stopping service #{service}..."
@beeftornado
beeftornado / nginx-conf
Last active January 18, 2024 19:54
Nginx reverse proxy for Sentry (github.com/getsentry/sentry). I removed some personal information and replaced it with <UPPERCASE> so look closely. Some key information in the sentry settings - SENTRY_URL_PREFIX, FORCE_SCRIPT_NAME, and ALLOWED_HOSTS. The rest of that is pretty standard.
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default ipv6only=on; ## listen for ipv6
root /usr/share/nginx/www;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name _;