This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import json | |
import pytz | |
import urllib2 | |
import datetime | |
import dateutil.parser | |
import re | |
import sys | |
import humanize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf import settings | |
from django.core.mail import EmailMultiAlternatives | |
from django.template.defaultfilters import striptags | |
def send_mail(subject, html_message, from_email, recipient_list, fail_silently=False, connection=None): | |
text_message = striptags(html_message) | |
recipient_list = getattr(settings, 'EMAIL_RECIPIENTS_OVERRIDE', recipient_list) | |
msg = EmailMultiAlternatives(subject, text_message, from_email, recipient_list, connection=connection) | |
msg.attach_alternative(html_message, "text/html") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
IFS="`printf "\n\t"`" | |
set -eux | |
cd "$(dirname "$0")" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
OlderNewer