Skip to content

Instantly share code, notes, and snippets.

View alkasm's full-sized avatar

Alexander Reynolds alkasm

View GitHub Profile
@alkasm
alkasm / events.py
Created February 6, 2021 10:37
Cooperative, event-driven, producer/consumer patterns
from collections import deque
import logging
import signal
from threading import Condition, Event, Thread
import time
logging.basicConfig(level=logging.INFO)
class Stop(Exception):
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active May 28, 2024 16:15
set -e, -u, -o, -x pipefail explanation
@svenevs
svenevs / README.md
Created October 26, 2017 16:18
Unofficial installation guide for librealsense with OpenMP support on OSX

Unofficial Installation Guide for librealsense on OSX

These instructions are for how to build librealsense on OSX with OpenMP support.

Install the Dependencies

Setup Brew (the OSX Package Manager)

@bradmontgomery
bradmontgomery / LICENSE.txt
Last active December 1, 2023 21:01
A python decorator that logs execution time.
Copyright 2020 Brad Montgomery
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
@vasanthk
vasanthk / System Design.md
Last active May 28, 2024 20:01
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@tswaters
tswaters / git-subdirectory-tracking.md
Last active May 28, 2024 19:04
Adding subdirectory of a remote repo to a subdirectory in local repo

This is way more complicated than it should be. The following conditions need to be met :

  1. need to be able to track and merge in upstream changes
  2. don't want remote commit messages in master
  3. only interested in sub-directory of another repo
  4. needs to go in a subdirectory in my repo.

In this particular case, I'm interested in bringing in the 'default' template of jsdoc as a sub-directory in my project so I could potentially make changes to the markup it genereates while also being able to update from upstream if there are changes. Ideally their template should be a separate repo added to jsdoc via a submodule -- this way I could fork it and things would be much easier.... but, it is what it is.

After much struggling with git, subtree and git-subtree, I ended up finding this http://archive.h2ik.co/2011/03/having-fun-with-git-subtree/ -- it basically sets up separate branches from tracking remote, the particular sub-directory, and uses git subtree contrib module to pull it all togther. Following are

// church numerals and lambda calculus in C++ using meta-template
// programming, everything evaluated at compile-time. This code should
// never be used in the real world. If I catch people using this for
// real-world code just because it's awesome I will track said people
// down and have a length discussion on why their existance is the
// reason I need to question the ethics of writing this code in the
// first place.
// all code is licensed under MIT under one condition, never actually
// use this code in real world programs, you can share it, and modify it
@miku
miku / withsqlite.py
Last active November 30, 2022 20:31
Simple sqlite3 context manager for Python.
#!/usr/bin/env python
import sqlite3
class dbopen(object):
"""
Simple CM for sqlite3 databases. Commits everything at exit.
"""
def __init__(self, path):
self.path = path
@thelinuxkid
thelinuxkid / subprocess_stream.py
Last active December 4, 2023 06:43
Get a Python subprocess' output without buffering. Normally when you want to get the output of a subprocess in Python you have to wait until the process finishes. This is bad for long running processes. Here's a way to get the output unbuffered (in real-time.)
import contextlib
import subprocess
# Unix, Windows and old Macintosh end-of-line
newlines = ['\n', '\r\n', '\r']
def unbuffered(proc, stream='stdout'):
stream = getattr(proc, stream)
with contextlib.closing(stream):
while True:
out = []
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 29, 2024 03:56
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname