Skip to content

Instantly share code, notes, and snippets.

View rickcnagy's full-sized avatar

Rick Nagy rickcnagy

View GitHub Profile
@gregburek
gregburek / rateLimitDecorator.py
Created December 7, 2011 01:51
Rate limiting function calls with Python Decorators
import time
def RateLimited(maxPerSecond):
minInterval = 1.0 / float(maxPerSecond)
def decorate(func):
lastTimeCalled = [0.0]
def rateLimitedFunction(*args,**kargs):
elapsed = time.clock() - lastTimeCalled[0]
leftToWait = minInterval - elapsed
if leftToWait>0:
@jboner
jboner / latency.txt
Last active November 19, 2024 11:10
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@rickcnagy
rickcnagy / gitmaster.sh
Last active December 19, 2015 10:39
Git reset to match master
git stash && git fetch origin && git reset --hard origin/master
@frehulfd
frehulfd / WKInterfaceController+Reactive.h
Last active April 16, 2020 02:00
WKInterfaceController+Reactive
@import WatchKit;
#import <ReactiveCocoa/ReactiveCocoa.h>
@interface WKInterfaceController (Reactive)
@property (nonatomic, readonly) RACSignal *activatedSignal;
@property (nonatomic, readonly) RACSignal *deactivatedSignal;
@property (nonatomic, readonly) RACSignal *didPresentControllerSignal;
@property (nonatomic, readonly) RACSignal *didPushControllerSignal;
@ex
ex / zebra.pro
Created February 4, 2016 19:50
Prolog solution of the Zebra Puzzle
exists(A, list(A, _, _, _, _)).
exists(A, list(_, A, _, _, _)).
exists(A, list(_, _, A, _, _)).
exists(A, list(_, _, _, A, _)).
exists(A, list(_, _, _, _, A)).
rightOf(R, L, list(L, R, _, _, _)).
rightOf(R, L, list(_, L, R, _, _)).
rightOf(R, L, list(_, _, L, R, _)).
rightOf(R, L, list(_, _, _, L, R)).
@btroncone
btroncone / ngrxintro.md
Last active November 5, 2024 12:20
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

Comprehensive Introduction to @ngrx/store

By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

@wxkeith
wxkeith / README.md
Last active September 19, 2022 04:33

WeatherFlow Widget for Scriptable

Requirements

  • You're running iOS/iPadOS 14.
  • You've installed Scriptable (https://scriptable.app).
  • You own a WeatherFlow weather station.

Installation