Skip to content

Instantly share code, notes, and snippets.

Henry S hsavit1

Block or report user

Report or block hsavit1

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile

Keybase proof

I hereby claim:

  • I am hsavit1 on github.
  • I am henry_s ( on keybase.
  • I have a public key ASBehtOERO0XSzcL87y6jBqgpvrxRE2XOHqBxl2LZc4Z5Qo

To claim this, I am signing this object:

hsavit1 / connect.js
Created Jun 24, 2017 — forked from gaearon/connect.js
connect.js explained
View connect.js
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
hsavit1 /
Created May 5, 2017 — forked from chrismccord/
Phoenix 1.2.x to 1.3.0 Upgrade Instructions

If you want a run-down of the 1.3 changes and the design decisions behidn those changes, check out the LonestarElixir Phoenix 1.3 keynote:

To use the new project generator, you can install the archive with the following command:

$ mix archive.install

Bump your phoenix dep

Phoenix v1.3.0 is a backwards compatible release with v1.2.x. To upgrade your existing 1.2.x project, simply bump your phoenix dependency in mix.exs:

hsavit1 / head_tail.swift
Created Aug 7, 2016
Head and tail for Swift
View head_tail.swift
extension Array {
var match : (head: T, tail: [T])? {
return (count > 0) ? (self[0],Array(self[1..<count])) : nil
func map<A,B>(f: A -> B, arr: [A]) -> [B] {
if let (head,tail) = arr.match {
return [f(head)] + map(f, tail)
} else {
hsavit1 /
Last active Jul 29, 2016 — forked from andymatuschak/
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen conflate side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

hsavit1 / genserver.ex
Created Jul 28, 2016
Genserver Implementation
View genserver.ex
defmodule Server do
def start(callback_module, state \\ nil) do
parent = self
spawn fn ->
loop(callback_module, parent, state)
def loop(callback_module, parent, state) do
receive do
hsavit1 / process_msging.ex
Created Jul 28, 2016
Small example of process messaging in elixir
View process_msging.ex
defmodule Speaker do
def speak do
receive do
{:say, msg} ->
_other ->
speak # throw away the message
hsavit1 / possibly.ex
Created Jul 19, 2016 — forked from keathley/possibly.ex
Monads and Maybes in elixir
View possibly.ex
defprotocol Functor do
def fmap(data, func)
defprotocol Applicative do
def pure(data)
def run(wrapped_func, data)
defprotocol Monad do
hsavit1 / YouTubePlayerViaTVJS.swift
Created Jul 6, 2016 — forked from nickv2002/YouTubePlayerViaTVJS.swift
Swift code to play YouTube videos on AppleTV tvOS via a TVJS call using XCDYouTubeKit
View YouTubePlayerViaTVJS.swift
// Created by Nick Vance on 12/4/15.
// Copyright © 2015 ToWatchList. All rights reserved.
import AVKit
import XCDYouTubeKit
import TVMLKit
class YTPlayerViewController: AVPlayerViewController, AVPlayerViewControllerDelegate {
hsavit1 /
Created Jun 27, 2016 — forked from olomix/
Balanced binary tree in Python
#!/usr/bin/env python2.7
import random
import subprocess
class Node(object):
def __init__(self, key, value):
self.key = key
self.value = value
You can’t perform that action at this time.