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 kill-back-to-indentation (arg) | |
| "Ignore ARG. Kill lines backwards to the first whitespace character." | |
| (interactive "p") | |
| (let ((start (point))) | |
| (back-to-indentation) | |
| (kill-region start (point)))) | |
| (global-set-key (kbd "C-c DEL") 'backward-kill-to-start-of-line) | |
| ;;; Example (Python): (The cursor is $) |
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
| test = [['A'], ['B'], ['C']] | |
| class ValueDescriptor(object): | |
| def __init__(self): | |
| self.value = None | |
| def __get__(self, obj, objtype): | |
| return self.value |
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 collections | |
| test = [['A'], ['B'], ['C']] | |
| class ValueDescriptor(object): | |
| def __init__(self): | |
| self.value_store = collections.defaultdict(lambda: None) |
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
| (custom-set-faces | |
| ;; custom-set-faces was added by Custom. | |
| ;; If you edit it by hand, you could mess it up, so be careful. | |
| ;; Your init file should contain only one such instance. | |
| ;; If there is more than one, they won't work right. | |
| '(rainbow-delimiters-depth-1-face ((t (:foreground "dark orange")))) | |
| '(rainbow-delimiters-depth-2-face ((t (:foreground "deep pink")))) | |
| '(rainbow-delimiters-depth-3-face ((t (:foreground "chartreuse")))) | |
| '(rainbow-delimiters-depth-4-face ((t (:foreground "deep sky blue")))) | |
| '(rainbow-delimiters-depth-5-face ((t (:foreground "yellow")))) |
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
| """ | |
| Simple message-passing closure objects example similar to SICP 3.1.1 | |
| """ | |
| def make_account(balance): | |
| # In Python 2.x we have to close over a mutable variable, so we are using | |
| # obj.__setitem__(...) assignment rather than regular assignment which | |
| # attempts to create a new variable within the current scope when each | |
| # closure is initially compiled. Otherwise cannot assign the balance value |
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
| >>> account("deposit")(25) | |
| Traceback (most recent call last): | |
| File "<stdin>", line 1, in <module> | |
| File "closure_objects.py", line 3, in deposit | |
| balance = balance + amount | |
| UnboundLocalError: local variable 'balance' referenced before assignment |
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
| average :: Float -> Float -> Float | |
| average x y = (x + y) / 2 | |
| sqrtImprove :: Float -> Float -> Float | |
| sqrtImprove guess x = average guess (x / guess) | |
| sqrtStream :: Float -> [Float] | |
| sqrtStream x = 1.0 : (map (\guess -> (sqrtImprove guess x)) (sqrtStream x)) | |
| main :: IO () |
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
| (define (remove-at index list) | |
| (map car (filter (lambda (x) (if (= (- (cdr x) 1) index) false true)) | |
| (map cons list (iota (length list) 1))))) | |
| (define (random-shuffle lst) | |
| (sort lst (lambda (x y) (equal? 0 (random 2))))) | |
| (define (make-random-bit-mask size num-ones) | |
| (if (< size num-ones) | |
| (error "Invalid size -- MAKE-RANDOM-BIT-MASK" size num-ones) |
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 python | |
| # -*- coding: utf-8 -*- | |
| """ | |
| celery_speed | |
| ~~~~~~~~~~~~ | |
| Simple tool to see how fast a celery queue in Redis is being consumed. | |
| Usage: | |
| celery_speed --redis-host REDIS_HOST --queue-name QUEUE_NAME |
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
| Project/Task | % Time Estimation Error | |
|---|---|---|
| MID-2215 | 216% | |
| MID-2213 | 39.20% | |
| MID-2214 | 34.40% | |
| MID-2258 | 32.90% | |
| MID-2079-PP | 86.00% | |
| MID-2079-LO | 63.10% | |
| MID-2079-PE | -15.30% | |
| MID-2079-PR | 18.00% | |
| PWS-43 | 116% |