Skip to content

Instantly share code, notes, and snippets.

View Ry4an's full-sized avatar

Ry4an Brase Ry4an

View GitHub Profile
@wolever
wolever / monkypatch_logging.py
Created September 14, 2014 21:21
Monkey patch for logging.LogRecord.getMessage so it will never, ever raise an exception
def monkeypatch_logging_getMessage():
""" Monkey patch logging.LogRecord.getMessage so it will never, ever raise an exception. """
from unstdlib import to_str
from logging import LogRecord
oldGetMessage = LogRecord.getMessage
def getMessage(self):
try:
return oldGetMessage(self)
except Exception as e:
@wolever
wolever / monkeypatch_queryset.py
Last active May 12, 2022 11:42
Monkeypatch Django 1.5's QuerySet adding a .first() method compatible with 1.6
def monkeypatch_queryset_first():
""" Monkeypatch QuerySet adding a `.first()` method which is compatible
with Django 1.6's `.first()`. """
from django.db.models.query import QuerySet
if hasattr(QuerySet, "first"):
import warnings
warnings.warn("QuerySet.first is already defined! "
"Monkey patch should be removed.")
return
def first(self):
@Ry4an
Ry4an / unloved-issue.py
Created July 7, 2014 01:34
nag least recently updated issue for this release
#!/usr/bin/python
import json
import pytz
import urllib2
import datetime
import dateutil.parser
import re
import sys
import humanize
@munificent
munificent / gist:9749671
Last active June 23, 2022 04:04
You appear to be creating a new IDE...
You appear to be advocating a new:
[ ] cloud-hosted [ ] locally installable [ ] web-based [ ] browser-based [ ] language-agnostic
[ ] language-specific IDE. Your IDE will not succeed. Here is why it will not succeed.
You appear to believe that:
[ ] Syntax highlighting is what makes programming difficult
[ ] Garbage collection is free
[ ] Computers have infinite memory
[ ] Nobody really needs:
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active February 25, 2024 13:47
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@wytten
wytten / agent
Last active January 3, 2016 21:19 — forked from anonymous/april_temp_sensor
Updated original april_temp_sensor to remove use of deprecated methods, to remove the use of pin2 for activating the lamp, and to use CSV format for communication with xively.com. Also added agent code taken from https://xively.com/dev/tutorials/electric_imp to which I have made trivial modifications.
const FEED_ID = "YOUR_FEED_ID";
const API_KEY = "YOUR_API_KEY";
// Accept CSV from device, then format request to and accept response from xively.com
device.on("data", function(feedCSV) {
server.log(feedCSV);
local xively_url = "https://api.xively.com/v2/feeds/" + FEED_ID + ".csv";
local request = http.put(xively_url, {"X-ApiKey":API_KEY, "Content-Type":"text/csv", "User-Agent":"Xively-Imp-Lib/1.0"}, feedCSV);
local response = request.sendsync();
if(response.statuscode != 200) {
@wolever
wolever / skeleton.sh
Created July 3, 2013 20:33
My bash script skeleton.
#!/bin/bash
IFS="`printf "\n\t"`"
set -eux
cd "$(dirname "$0")"
@Ry4an
Ry4an / irc-rant
Created May 10, 2013 14:12
My cranky-day rant about people /msg-ing in work IRC
People keep /MSG-ing me non-secret things in IRC, so I assume everyone's doing it w/ one another too. Everytime someone /msg-s me I ask them to bring it up in the main channel instead, but that's not getting the message across, so: STOP IT.
The whole point of IRC is that there's huge benefit in everyone overhearing things that they're not currently working on. This is why IRC is 1000x better for a tech group than IM. There's incredible value in making things like "Oh, I did that at my last job, consider looking at X" or "Didn't I see you did something with Y last month?" possible, and all of that gets flushed down the drain when you /msg.
Don't worry about the channel getting too chatty. I'm in some channels w/ 200+ members and it works just fine. Your IRC client will figure it out.
There might be no immediate need for [Alice] to hear [Bob] and I discussing the finer points of dynamo throughput settings, but there's no harm in it and if at the end of the month the bill knocks her socks off she's goin
@pepebe
pepebe / gist:2955410
Created June 19, 2012 17:25
Ubuntu: Convert psd files with imagemagick
Source: http://superuser.com/questions/360434/any-way-to-save-all-psd-layers-separately
Imagemagick will by default convert a psd to multiple images:
convert file.psd file.png
will result in file-0.png, file-1.png etc for each layer. If you wanted a single image, use the flatten switch:
convert file.psd -flatten file.png
Imagemagick is available on osx, windows and linux. And iOS somehow.
@zachwill
zachwill / gist:2001993
Created March 8, 2012 16:42
Reload Google Chrome from Vim
" Reload Google Chrome on Mac from Vim.
" Adapted from: https://github.com/gcollazo/BrowserRefresh-Sublime/
function! ChromeReload()
python << EOF
from subprocess import call
browser = """
tell application "Google Chrome" to tell the active tab of its first window
reload
end tell
tell application "Google Chrome" to activate