Skip to content

Instantly share code, notes, and snippets.

View agoose77's full-sized avatar
🏠
Working from home

Angus Hollands agoose77

🏠
Working from home
View GitHub Profile
@longouyang
longouyang / gist:3688502
Last active April 23, 2022 20:22
Random combinations in Church (Buckles-Lybanon '77)
(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)))))
@vaughnd
vaughnd / gist:3759951
Created September 21, 2012 06:02
Bash script to run more than one process in parallel and kill all when exiting the script (via ctrl-c or kill)
#!/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
@hemenkapadia
hemenkapadia / Ubuntu 14.04 on Optimus Laptop.txt
Last active May 2, 2023 20:44
[Ubuntu 14.04 on Optimus Laptop] Setting up Ubuntu 14.04 with nvidia drivers and CUDA on Dell 7559 Optimus laptop #Ubuntu #Nvidia #CUDA #setup
### 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
@Reedbeta
Reedbeta / cool-game-programming-blogs.opml
Last active August 14, 2024 11:22
List of cool blogs on game programming, graphics, theoretical physics, and other random stuff
<?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"/>

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
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):
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active October 31, 2024 17:11
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

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.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).