⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
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 random | |
def cocktail_shaker_sort(array): | |
smallest_array=[] | |
largest_array = [] | |
while len(array) > 0: | |
smallest_element = min(array) | |
smallest_element_index = array.index(smallest_element) | |
smallest_array.append(smallest_element) | |
array.pop(smallest_element_index) |
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
#delete all migrations and reset models.py to initial state | |
rm -r app/migrations/ | |
chmod +x manage.py | |
./manage.py flush | |
./manage.py schemamigration app --initial | |
./manage.py migrate app --fake | |
#after changing models.py | |
./manage.py schemamigration app --auto | |
./manage.py migrate app |
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 logging | |
def logger_factory(name, filename='default'): | |
logger = logging.getLogger(name) | |
logger.setLevel(logging.DEBUG) | |
if filename == 'default': | |
filename = name + '.log' | |
file_handler = logging.FileHandler(filename) | |
format = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s: %(message)s') | |
file_handler.setFormatter(format) |
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 retrieve_revision(commit_id, username, project, revision=None): | |
commit_url = 'https://api.github.com/repos/%s/%s/git/commits/%s' % ( | |
username, project, commit_id) | |
commit_json = None | |
if commit_json is None: | |
try: | |
commit_json = json.load(urllib.urlopen(commit_url)) | |
except IOError, 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
import time | |
import md5 | |
from functools import wraps | |
from bottle import ( | |
get, | |
abort, | |
request, | |
run | |
) |
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 md5 | |
import requests | |
from requests.auth import HTTPBasicAuth | |
class DigestClient(object): | |
def __init__(self, url, username, password): | |
self.url = url | |
self.username = username |
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
{% extends "base.html" %} | |
{% block content %} | |
<h2>Dry Cleaning Orders</h2> | |
{% url 'dry_cleaning_add' as add_dry_cleaning_url %} | |
<div class="btn-toolbar"> | |
<a href="{{ add_dry_cleaning_url }}"> | |
<button class="btn btn-primary">New Order</button> | |
</a> | |
</div> |
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
BASE_16 = 16 | |
HEXADECIMAL_CHARACTERS = [ | |
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, | |
'A', 'B', 'C', 'D', 'E', 'F', | |
] | |
DECIMAL_TO_HEXADECIMAL_MAPPING = { | |
x: HEXADECIMAL_CHARACTERS[x] | |
for x in range(len(HEXADECIMAL_CHARACTERS)) | |
} |
OlderNewer