Skip to content

Instantly share code, notes, and snippets.

View stangirala's full-sized avatar
🙃

Sarma stangirala

🙃
View GitHub Profile
@stangirala
stangirala / nvda.txt
Created October 8, 2024 20:58
Copy of a data file for an example
Table of Contents
UNITED STATES
SECURITIES AND EXCHANGE COMMISSION
Washington, D.C. 20549
____________________________________________________________________________________________
FORM 10-K
☒ ANNUAL REPORT PURSUANT TO SECTION 13 OR 15(d) OF THE SECURITIES EXCHANGE ACT OF 1934
For the fiscal year ended January 28, 2024
OR
☐ TRANSITION REPORT PURSUANT TO SECTION 13 OR 15(d) OF THE SECURITIES EXCHANGE ACT OF 1934
public class Main {
public static void main(String[] args) {
Histogram histogram = new Histogram();
histogram.sample(0);
histogram.sample(10.0);
}
}
@stangirala
stangirala / maybe_monad_without_bind.hs
Last active August 8, 2018 23:25
Maybe Monad Without Bind
module Example where
data Possible a = None | Some a
-- Possible is the type, None and Some are the values associated with it
binder :: Possible a -> (a -> Possible b) -> Possible b
binder None _ = None
binder (Some a) f = f a
instance (Show a) => Show (Possible a) where
show (None) = "None"
@stangirala
stangirala / cqrs.py
Created June 26, 2017 03:41
A very simple cqrs batch processing template
import uuid
import datetime as dt
from functools import reduce
class Datagram(object):
def __init__(self, val=0):
self.val = val
def op(self, other):
return Datagram(self.val+other.val)
@stangirala
stangirala / karabiner.json
Created September 29, 2016 00:58
karabiner-elements config for macOS sierra
{
"profiles": [
{
"name": "Default profile",
"selected": true,
"simple_modifications": {
"caps_lock": "escape",
"f1": "mute",
"f2": "volume_down",
"f3": "volume_up",
def map(intValue):
store = {}
store[computeBin(intValue)] += 1
print _, store
def reduce(_, *stores):
_store = {}
for store in stores:
for k, v in store:
_store[k] += v
def map(intValue):
print intValue, 1
def reduce(*args):
store = {}
for intValue, count in args:
store[computeBin(intValue)] += count
@stangirala
stangirala / monoid.py
Last active September 19, 2016 02:34
A monoid in python
from collections import defaultdict
class Monoid():
def __init__(self, zero, foldOp, liftFunctor=None):
self.store = defaultdict(zero)
self.liftFunctor = liftFunctor
self.foldOp = foldOp
self.zero = zero
def fold(self, key, vals):
@stangirala
stangirala / eqc_statem.md
Created September 18, 2016 06:08 — forked from zeeshanlakhani/eqc_statem.md
Andrew Stone's Great eqc_statem notes

Testing Stateful Code

So far, all the properties we have written have tested stateless code. Stateless code is made up of pure functions and is inherently easier to test than stateful code with side effects. The chief problem with testing stateful code is that the input to output mapping depends on the current state of the program. Previous operations can cause the same function to return different output given the same input. Therefore, in order to test stateful code, our tests must maintain some state of their own. This state is known as the model state and is updated as part of the testing process.

@stangirala
stangirala / gist:10f1e8b523f8c5d83966
Created March 14, 2016 03:05 — forked from debasishg/gist:8172796
A collection of links for streaming algorithms and data structures
  1. General Background and Overview