Instantly share code, notes, and snippets.

View screenshot.js
var casper = require('casper').create({
viewportSize: {
width: 1920,
height: 1080
},
verbose: true,
logLevel: 'debug'
});
var utils = require('utils');
View field.html
{% load crispy_forms_field %}
<{% if tag %}{{ tag }}{% else %}div{% endif %} id="div_{{ field.auto_id }}" class="form-group{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if form_show_errors%}{% if field.errors %} has-error{% endif %}{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
{% if field.label and form_show_labels %}
<label for="{{ field.id_for_label }}" class="control-label {{ label_class }}{% if field.field.required %} requiredField{% endif %}">
{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
</label>
{% endif %}
<div class="controls {{ field_class }}">
{% crispy_field field %}
View pre-commit.sh
#!/bin/sh
GREP_COLOR='4;5;37;41'
EXIT_STATUS=0
cd "$( dirname "$( dirname "$( dirname ${BASH_SOURCE[0]} )" )" )"
commitcheck () {
FILES=$1
FORBIDDEN=$2
View gist:f4b72503e714e4db00a0
$ mongo
> show dbs #optional
> use edxapp
> show collections #optional
> db.modulestore.find({'_id.category':'html'}).snapshot().forEach( function (e) {
e.definition.data.data = e.definition.data.data.replace(/http\:\/\/docs\.google\.com/g, '//docs.google.com');
db.modulestore.save(e);
})
# A more complex replace
View gist:75927abacecabde58903
class NormalizeData(object):
SERIALIZABLE_TYPES = [str, int, bool, float, list, dict, type(None)]
def __init__(self, element):
self.element = element
def execute(self):
if isinstance(self.element, dict):
self.iterate_dict()
View gist:556e4e031ec490f58e15

In your js:

;(function () {
    window.lcms = window.lcms || {}
    window.lcms.initSomething = function (config) {
        doStuffWith(config.var_name)
        $.ajax(config.whatever_url)
    }
}).call(this);
View gist:2c699837044898ec6227
pyvenv-3.4 ~/venv/myvenv --without-pip
. ~/venv/myvenv/bin/activate
curl -O https://bootstrap.pypa.io/ez_setup.py
python ez_setup.py
easy_install pip
View views.py
from django.http import HttpResponse
def django_file_download_view(request):
filepath = '/path/to/file.xlsx'
with open(filepath, 'r') as fp:
data = fp.read()
filename = 'some-filename.xlsx'
response = HttpResponse(mimetype="application/ms-excel")
response['Content-Disposition'] = 'attachment; filename=%s' % filename # force browser to download file
response.write(data)
View gist:8064060
# localhost:3000
NoMethodError in Home#index
Showing /Users/editor/Dropbox/www.b2plus.tv/app/views/home/index.html.slim where line #2 raised:
undefined method `poster' for nil:NilClass
Extracted source (around line #2):
View gist:7000836
/Applications/Inkscape.app/Contents/Resources/bin/inkscape image.svg --export-png=image.png