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
% mkdir -p demodir/derp | |
% cat > demodir/derp/testing.py <<EOT | |
heredoc> print 'this is a test' | |
heredoc> EOT | |
% cat > demo.py <<EOT | |
heredoc> from demodir.derp import testing | |
heredoc> EOT |
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/sh | |
params="" | |
first=1 | |
for int in "$@"; do | |
if [ $first -eq 1 ]; then | |
first=0 | |
else | |
params="$params -c" | |
fi |
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
try: | |
# for Python 2.x | |
from Queue import Queue | |
except ImportError: | |
# for Python 3.x | |
from queue import Queue | |
from threading import Thread, Event | |
import random | |
import sys |
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
/******************************************************* | |
* SerialServoControl Sketch | |
* Written by Ryan Owens for SparkFun Electronics | |
* 7/15/11 | |
* Tweaked by Josh VanderLinden for himself | |
* 9/21/11 | |
* | |
* This sketch listens to serial commands and uses the data | |
* to set the position of two servos. | |
* |
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
$ python test_enumerate.py | |
3 function calls in 8.030 CPU seconds | |
Ordered by: standard name | |
ncalls tottime percall cumtime percall filename:lineno(function) | |
1 0.000 0.000 8.030 8.030 <string>:1(<module>) | |
1 8.030 8.030 8.030 8.030 test_enumerate.py:5(test_enumerate) | |
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} |
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
import uuid | |
from django.db import models | |
from django.contrib.auth.models import User | |
from cumulus.storage import CloudFilesStorage | |
cloudfiles_storage = CloudFilesStorage() | |
# Create your models here. | |
class Upload(models.Model): |
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
import os | |
from django.core.signals import post_delete | |
from articles.models import Attachment | |
def cleanup_filesystem(sender, instance): | |
"""Removes attached files from the filesystem""" | |
try: | |
os.unlink(instance.attachment.path) |
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
# ---- some file that is processed early in Django's execution (like a urls.py or __init__.py file) | |
from product.models import ProductManager | |
def deal_o_day(self): | |
"""Determines which product is the current Deal of the Day""" | |
return self.filter(stuff_in_stock__gt=0, foo=bar) | |
ProductManager.deal_o_day = deal_o_day |
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
""" | |
Tests the difference in speed in the following scenarios: | |
* Selecting all records from a SQLite database and doing processing using | |
regular Python functions (test_python) | |
* Calling a Python function in the SQL statement itself and returning all | |
results (test_sqlite) | |
""" | |
from hashlib import sha1 |
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
" Allows you to do ":b ", type the beginning of some open buffer's name, and hit <Tab> to see/select possible matches | |
set wildcharm=<Tab> wildmenu wildmode=full | |
function! BufSel(pattern) | |
let bufcount = bufnr("$") | |
let currbufnr = 1 | |
let nummatches = 0 | |
let firstmatchingbufnr = 0 | |
while currbufnr <= bufcount | |
if(bufexists(currbufnr)) |