A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
| (define (pn x) (for-each display (list x "\n"))) | |
| (define (! n) | |
| (let iter ((product 1) | |
| (counter 1)) | |
| (if (> counter n) | |
| product | |
| (iter (* counter product) | |
| (+ counter 1))))) |
| #!/bin/bash | |
| # kill all subshells and processes on exit | |
| trap "kill 0" SIGINT | |
| # start commands in subshells so all their spawn DIE when we exit | |
| ( process1 ) & | |
| ( process2 ) & | |
| wait |
| ### NOTE ### | |
| The below gist is converted to a blog post and available at below link. Refer that instead. | |
| http://hemenkapadia.github.io/blog/2016/11/11/Ubuntu-with-Nvidia-CUDA-Bumblebee.html | |
| #### Note about kernel versions #### | |
| Between kernel versions 4.2 and 4.4 there are different options that need to bet set | |
| to get this working. The same is highlighted below when necessary. I have not tested |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <opml version="1.0"> | |
| <head> | |
| <title>Graphics, Games, Programming, and Physics Blogs</title> | |
| </head> | |
| <body> | |
| <outline text="Tech News" title="Tech News"> | |
| <outline type="rss" text="Ars Technica" title="Ars Technica" xmlUrl="http://feeds.arstechnica.com/arstechnica/index/" htmlUrl="https://arstechnica.com"/> | |
| <outline type="rss" text="Polygon - Full" title="Polygon - Full" xmlUrl="http://www.polygon.com/rss/index.xml" htmlUrl="https://www.polygon.com/"/> | |
| <outline type="rss" text="Road to VR" title="Road to VR" xmlUrl="http://www.roadtovr.com/feed" htmlUrl="https://www.roadtovr.com"/> |
| class Deferred: | |
| def __init__(self, call, *args, **kwargs): | |
| self.call = getattr(call, 'func', call) | |
| self.args = args | |
| self.kwargs = kwargs | |
| def result(self): | |
| return self.call(*self.args, **self.kwargs) | |
| # Inspiration from http://matt.might.net/articles/implementation-of-recursive-fixed-point-y-combinator-in-javascript-for-memoization/ | |
| def y_comb(f): | |
| def outer(x): | |
| def inner(y): | |
| return (x(x))(y) | |
| return f(inner) | |
| return outer(outer) |
| from collections import deque, namedtuple | |
| from time import time | |
| from enum import auto, Enum | |
| from operator import itemgetter | |
| class Trap(Enum): | |
| SLEEP = auto() | |
| SPAWN = auto() | |
| WHOAMI = auto() |
| from collections import deque, namedtuple, defaultdict | |
| from time import time | |
| from types import coroutine | |
| from enum import auto, Enum | |
| from operator import itemgetter | |
| def async_contextmanager(func): | |
| class ctx: | |
| def __init__(self, *args, **kwargs): |
This is a compiled list of falsehoods programmers tend to believe about working with time.
Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.