Skip to content

Instantly share code, notes, and snippets.

Avatar

Trevor Muñoz trevormunoz

View GitHub Profile
@acdha
acdha / gist:f1f506b47a38574f3a5f
Last active Aug 29, 2015
Quick mock example showing how to simulate errors
View gist:f1f506b47a38574f3a5f
>>> from unittest import mock
>>> import json
>>> m_o = mock.mock_open()
>>> m_o.side_effect = OSError('Insufficient voltage')
>>> json.load(m_o('foo.json', 'rb'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/unittest/mock.py", line 896, in __call__
return _mock_self._mock_call(*args, **kwargs)
File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/unittest/mock.py", line 952, in _mock_call
@kennethreitz42
kennethreitz42 / flaskapp.py
Created Jun 9, 2012
My typical flask app base
View flaskapp.py
# -*- coding: utf-8 -*-
import os
from flask import Flask
from flask_heroku import Heroku
from flask_sslify import SSLify
from raven.contrib.flask import Sentry
from flask.ext.celery import Celery
@charliepark
charliepark / hatchshow.js
Created Jul 30, 2011
A jquery typography plugin.
View hatchshow.js
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8">
$(window).load(function(){
$().hatchShow();
});
jQuery.fn.hatchShow = function(){
$('.hsjs').css('display','inner-block').css('white-space','pre').each(function(){
var t = $(this);
t.wrap("<span class='hatchshow_temp' style='display:block'>");
var pw = t.parent().width();
You can’t perform that action at this time.