Skip to content

Instantly share code, notes, and snippets.

@beeftornado
beeftornado / osx-for-hackers.sh
Last active August 30, 2015 05:01 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned. Also, please don't email me about this script, my poor inbox...
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
@beeftornado
beeftornado / raven.js.diff
Created July 27, 2015 23:24
Customizable auth string
diff --git a/src/raven.js b/src/raven.js
index 9dd5e14..88662d3 100644
--- a/src/raven.js
+++ b/src/raven.js
@@ -508,11 +508,20 @@ function each(obj, callback) {
}
+function getAuthParts() {
+ return [ 'sentry_version=4',
@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 _;
@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 / 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 / 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
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 / 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)
@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 / 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