Skip to content

Instantly share code, notes, and snippets.

View dtran320's full-sized avatar
๐ŸŒŠ
Come co-work with us virtually! https://www.flow.club

David Tran dtran320

๐ŸŒŠ
Come co-work with us virtually! https://www.flow.club
View GitHub Profile
@hotpaw2
hotpaw2 / RecordAudio.swift
Last active March 20, 2025 03:59
Swift Audio Recording class. Reads buffers of input samples from the microphone using the iOS RemoteIO Audio Unit API
//
// RecordAudio.swift
//
// This is a Swift class (updated for Swift 5)
// that uses the iOS RemoteIO Audio Unit
// to record audio input samples,
// (should be instantiated as a singleton object.)
//
// Created by Ronald Nicholson on 10/21/16.
// Copyright ยฉ 2017,2019 HotPaw Productions. All rights reserved.
@tasdikrahman
tasdikrahman / python_tests_dir_structure.md
Last active February 10, 2025 22:15
Typical Directory structure for python tests

A Typical directory structure for running tests using unittest

Ref : stackoverflow

The best solution in my opinion is to use the unittest [command line interface][1] which will add the directory to the sys.path so you don't have to (done in the TestLoader class).

For example for a directory structure like this:

new_project

โ”œโ”€โ”€ antigravity.py

@gaearon
gaearon / slim-redux.js
Last active September 7, 2025 15:41
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@dtran320
dtran320 / startup.py
Last active December 20, 2016 20:42
startup.py
def build_startup(team, product, market, cash):
while team and cash > 0:
while not fits(product, market):
apply_breadth_first_search() # Apply with heuristics
apply_depth_first_search()
@jhorman
jhorman / redis_semaphore.py
Last active August 27, 2025 01:22
Redis semaphore implemented in Python via zsets. Lock expiration is implemented by only scanning the zset for items within a time range.
from __future__ import absolute_import
from time import time, sleep
import uuid
class RedisSemaphore(object):
"""
Redis base semaphore. Supports timeouts of semaphore locks.
"""
@bradmontgomery
bradmontgomery / install-comodo-ssl-cert-for-nginx.rst
Last active March 20, 2025 17:17
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

"""
Connect4.py
Basic connect 4 game in Python
Work in progress
"""
import operator, numpy
Compile the Redis "notifications" branch on Github.
Start Redis with ./redis-server --notify-keyspace-events yes
Subscribe to all the events with:
redis-cli psubscribe '*'
In another terminal window, play with redis-cli: set, del, expire, ... Only a few already work.
@ndarville
ndarville / business-models.md
Last active September 19, 2025 07:49
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google