Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View sj26's full-sized avatar
🤹‍♂️

Samuel Cochran sj26

🤹‍♂️
View GitHub Profile
@sj26
sj26 / LICENSE.md
Last active March 8, 2024 18:31
Bash retry function

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit

@sj26
sj26 / README.md
Created January 19, 2012 07:41
Run MailCatcher in the background, always, on OS X

Place me.mailcatcher.plist into ~/Library/LaunchAgents, then run launchctl load ~/Library/LaunchAgents/me.mailcatcher.plist.

If you use pow, echo 1080 > ~/.pow/mailcatcher and go to http://mailcatcher.dev, otherwise use http://localhost:1080.

Currently pow doesn't seem to pass websockets through correctly. Looking into this.

@sj26
sj26 / com.sj26.TerminalAppearanceThemeChanger.plist
Last active February 5, 2024 10:37
Apple Terminal Default Window Settings Changer
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.sj26.TerminalAppearanceThemeChanger</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
@sj26
sj26 / session_id_middleware.py
Created April 21, 2012 05:24
Session ID middleware for Python
#!/usr/bin/env python
import base64
from Cookie import SimpleCookie
import hashlib
import hmac
import random
import string
require "uri"
# Parses an S3 URI for region, bucket and key
#
# Based on the java sdk:
#
# https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/AmazonS3URI.java
#
# Reference:
#
@sj26
sj26 / buildkite-automatic-sso.user.js
Last active October 19, 2023 00:18
I'm tired of clicking SSO buttons on Buildkite.com
// ==UserScript==
// @name buildkite-automatic-sso
// @description I'm tired of clicking SSO buttons on buildkite.com
// @match https://buildkite.com/*
// @run-at document-idle
// ==/UserScript==
if (document.title.match(/^Authorization Required:/)) {
document.querySelector("input[type=submit][value^='Sign in to your'], input[type=submit][value^='Continue with']").click();
}
@sj26
sj26 / nginx.conf
Last active August 30, 2023 19:10
Proxy mailcatcher with nginx including WebSockets
daemon off;
error_log stderr;
events {
worker_connections 1024;
}
http {
# As suggested in http://nginx.org/en/docs/http/websocket.html
map $http_upgrade $connection_upgrade {
@sj26
sj26 / slack-hide-install-alert.user.css
Last active August 25, 2023 00:21
Slack hide install alert user script
/* ==UserStyle==
@name slack-hide-install-alert
@description No, really, I don't want it.
@match https://app.slack.com/*
==/UserStyle== */
.p-workspace_banner__desktop-download-app {
display: none !important;
}
@sj26
sj26 / 0-readme.md
Created May 5, 2012 05:39 — forked from burke/0-readme.md
ruby-1.9.3-p194 cumulative performance patch.

Patched ruby 1.9.3-p194 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p194 with patches for boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.

Huge thanks to funny-falcon for the performance patches.

@sj26
sj26 / phpserialize.py
Created February 2, 2010 09:53
Python port of PHP serialize() and unserialize()
#!/usr/bin/python -u
"""
Python port of PHP serialize() and unserialize()
by Samuel Cochran <sj26@sj26.com>
I couldn't find a nice, fairly efficient implementation of serialize/unserialize for Python... so I wrote one. I didn't use str().partition because I wanted Python <2.5 compatibility.
TODO: Performance review. There's an awful lot of string copying. >.>