This file contains hidden or 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
function styleFileUploader(fileInputId) { | |
var fileInput = $(fileInputId), | |
addFileField = fileInput.siblings('button'); | |
fileInput.hide(); | |
addFileField.on('click touchstart', function (e) { | |
fileInput.trigger('click').trigger('touchstart'); | |
}); |
This file contains hidden or 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
function rotateImage(path, degrees, callback) { | |
var canvas = document.createElement('canvas'), | |
ctx = canvas.getContext('2d'), | |
image = new Image(); | |
image.src = path; | |
image.onload = function () { | |
canvas.width = image.height; | |
canvas.height = image.width; | |
ctx.translate(image.width/2, image.width/2); |
This file contains hidden or 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
(function ($) { | |
'use strict'; | |
// Compat | |
MutationObserver = window.MutationObserver || | |
window.WebKitMutationObserver || | |
window.MozMutationObserver; | |
var body = $(document.body), | |
modalOverlay = $('<div>', {'id': 'modal-overlay'}).appendTo(body), |
This file contains hidden or 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/env python3 | |
from subprocess import call, check_output, CalledProcessError | |
top_ps = check_output('ps haxo pid,command k -pcpu | head -n 1', shell=True) | |
top_ps = str(top_ps, encoding='UTF-8') | |
top_pid, top_cmd = top_ps.strip().split(' ', 1) | |
try: | |
question = check_output([ |
This file contains hidden or 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
$ django-admin.py startproject myproject . | |
$ ./manage.py startapp myapp | |
$ tree . -d -L 2 | |
. | |
├── manage.py | |
├── myapp | |
│ ├── admin.py | |
│ ├── __init__.py | |
│ ├── models.py | |
│ ├── tests.py |
This file contains hidden or 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
# coding: utf-8 | |
import bitly_api | |
from django import template | |
from django.conf import settings | |
from django.core.exceptions import ImproperlyConfigured | |
register = template.Library() | |
try: |
This file contains hidden or 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 import forms | |
class HTML5Form(forms.Form): | |
def __init__(self, *args, **kwargs): | |
super(MyForm, self).__init__(*args, **kwargs) | |
for _, field in self.fields.items(): | |
if field.widget.is_required: | |
field.widget.attrs['required'] = 'required' |
This file contains hidden or 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
Show hidden characters
{ | |
"bold_folder_labels": true, | |
"caret_style": "phase", | |
"color_scheme": "Packages/Ciapre Color Scheme/CiapreBlack.tmTheme", | |
"create_window_at_startup": false, | |
"ensure_newline_at_eof_on_save": true, | |
"file_exclude_patterns": | |
[ | |
"*~", | |
"*.pyc", |
This file contains hidden or 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
<?php | |
/** | |
* Copyright (C) 2012 Rafael Canovas | |
* | |
* This program is free software: you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation, either version 3 of the License, or | |
* (at your option) any later version. | |
* | |
* This program is distributed in the hope that it will be useful, |
This file contains hidden or 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
function fooAdd(x) { | |
var y = 2; | |
return function() { | |
return x + y; | |
} | |
} | |
var fooClosure = fooAdd(5); | |
alert(fooClosure()); |
NewerOlder