Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Brian Njenga brayoh

🎯
Focusing
View GitHub Profile
@brayoh
brayoh / ThinkAboutMonads.md
Created Jan 10, 2020 — forked from cscalfani/ThinkAboutMonads.md
How to think about monads
View ThinkAboutMonads.md

How to think about Monads

Initially, Monads are the biggest, scariest thing about Functional Programming and especially Haskell. I've used monads for quite some time now, but I didn't have a very good model for what they really are. I read Philip Wadler's paper Monads for functional programming and I still didnt quite see the pattern.

It wasn't until I read the blog post You Could Have Invented Monads! (And Maybe You Already Have.) that I started to see things more clearly.

This is a distillation of those works and most likely an oversimplification in an attempt to make things easier to understand. Nuance can come later. What we need when first learning something is a simple, if inaccurate, model.

This document assumes a beginner's knowledge of pure functional programming and Haskell with some brief encounters of Monads, e.g. [Functors, Applicatives, And

@brayoh
brayoh / serverless.yml
Created Oct 21, 2019 — forked from codecitizen/serverless.yml
A serverless.yml file configuring a AWS ElastiCache redis instance that is accessible by all AWS Lambda functions deployed by this serverless function.
View serverless.yml
service: my-service
provider:
name: aws
runtime: nodejs8.10
stage: ${opt:stage, 'dev'}
environment:
REDIS_HOST:
"Fn::GetAtt": [ElasticCacheCluster, RedisEndpoint.Address]
functions:
@brayoh
brayoh / get_element_width_and_height.js
Created Apr 11, 2019
Get the width and height of an dom element in react
View get_element_width_and_height.js
class GenericHeightAndWidth extends Component {
state = {
elementWidth: 0,
elementHeight: 0
};
componentDidMount() {
const elementWidth = document.getElementById('element_id').clientWidth; // get element width
const elementHeight = document.getElementById('element_id').clientWidth; // get element height
View keybase.md

Keybase proof

I hereby claim:

  • I am brayoh on github.
  • I am brayoh (https://keybase.io/brayoh) on keybase.
  • I have a public key ASB_XARbgKJ9t6_MJzSe3yAAQMe-N0Md3fRQiyxHMpJhdQo

To claim this, I am signing this object:

@brayoh
brayoh / introrx.md
Created Apr 12, 2018 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
View introrx.md
@brayoh
brayoh / class-change.js
Created Jan 13, 2018
code snippet for changing an element class name(s)
View class-change.js
addClass(el, clas, callback) {
if (el) {
const contains = el.classList.contains(clas);
if (contains) {
// dont add the class again
} else {
el.classList.add(clas);
}
@brayoh
brayoh / bump_version.sh
Created Aug 31, 2017
Script for semantic versioning and tagging your app releases in git
View bump_version.sh
#!/bin/bash
# works with a file called VERSION in the current directory,
# the contents of which should be a semantic version number
# such as "1.2.3"
# this script will display the current version, automatically
# suggest a "minor" version update, and ask for input to use
# the suggestion, or a newly entered value.
View PR.md

What does this PR do?

Description of Task to be completed?

How should this be manually tested?

Any background context you want to provide?

What are the relevant pivotal tracker stories?

View tmux.conf
# use to ctrl + a
set -g prefix C-a
set-option -g history-limit 100000
### COLOUR (Solarized 256)
#### COLOUR (Solarized 256)
# default statusbar colors
#set-option -g status-bg colour235 #base02
#set-option -g status-fg colour136 #yellow
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname