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
<!doctype html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
</head> | |
<body> | |
<p>Hello world</p> |
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
"""GitHub flavoured markdown: because normal markdown has some vicious | |
gotchas. | |
Further reading on the gotchas: | |
http://blog.stackoverflow.com/2009/10/markdown-one-year-later/ | |
This is a Python port of GitHub code, taken from | |
https://gist.github.com/901706 | |
To run the tests, install nose ($ easy_install nose) then: |
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
diff -r ae5f7638827e dbindexer/lookups.py | |
--- a/dbindexer/lookups.py Tue Sep 06 11:07:55 2011 +0200 | |
+++ b/dbindexer/lookups.py Tue Nov 15 17:48:56 2011 +0000 | |
@@ -48,10 +48,11 @@ | |
return lookup_type, value | |
def convert_value(self, value): | |
- if isinstance(value, (tuple, list)): | |
- value = [self._convert_value(val) for val in value] | |
- else: |
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
(eval-when-compile (require 'cl)); declare, first, rest | |
;;;; and-let*, based on Scheme's SRFI 2 | |
;; Contrived usage example: | |
;; (and-let* ((buffer-path (buffer-file-name)) | |
;; (file-name (file-name-directory))) | |
;; (message "You are visiting a file called %s in this buffer." | |
;; file-name)) | |
(defmacro and-let* (varlist &rest body) | |
"Equivalent to let*, but terminates early and returns nil if |
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 itertools import groupby | |
from operator import itemgetter | |
def group_pairs(iterable): | |
"""Given a sorted list of pairs, group by the first element in | |
each pair. | |
>>> group_pairs([('a', 1), ('a', 2), ('b', 3)]) | |
[('a', [1, 2]), ('b', [3])] |
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
import Control.Monad(forM_) | |
main = forM_ (take 100 fizzBuzzes) putStrLn | |
toFizzBuzz :: Integer -> String | |
toFizzBuzz x | |
| x `rem` 15 == 0 = "FizzBuzz" | |
| x `rem` 5 == 0 = "Buzz" | |
| x `rem` 3 == 0 = "Fizz" | |
| otherwise = show x |
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
$ mkdir example_project_2 | |
$ cd example_project_2 | |
$ git init | |
Initialized empty Git repository in /tmp/example_project_2/.git/ | |
$ nano README.md | |
$ more README.md | |
## vNEXT | |
$ git add README.md | |
$ git commit -m "initial commit" | |
[master (root-commit) 0014408] initial commit |
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.shortcuts import redirect, render_to_response | |
from django.template import RequestContext | |
from .forms import UserProfileForm | |
def my_view(request): | |
if request.method == "POST": | |
form = UserProfileForm(request.POST) |
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
(defun dwim-at-point () | |
"If there's an active selection, return that. Otherwise, get | |
the symbol at point." | |
(if (use-region-p) | |
(buffer-substring-no-properties (region-beginning) (region-end)) | |
(if (symbol-at-point) | |
(symbol-name (symbol-at-point))))) | |
;; todo: investigate whether we're reinventing the wheel, since query-replace-history already exists | |
(defvar query-replace/history nil) |
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
(defun --slice (list from &optional to) | |
"Return copy of LIST, starting from index FROM to index TO. | |
FROM or TO may be negative" | |
;; to defaults to the end of the list | |
(setq to (or to (length list))) | |
;; handle negative indices | |
(when (< from 0) | |
(setq from (mod from (length list)))) | |
(when (< to 0) | |
(setq to (mod to (length list)))) |