Skip to content

Instantly share code, notes, and snippets.

View sjsyrek's full-sized avatar

Steven Syrek sjsyrek

View GitHub Profile
@sjsyrek
sjsyrek / world-building-with-tom-harding.md
Last active February 7, 2021 21:14
World-Building in Haskell with Tom Harding
@sjsyrek
sjsyrek / validation.hs
Created January 3, 2020 13:55
Haskell validation example
import Data.Semigroup
import Data.Functor
import Control.Applicative
data Validation err a = Failure err | Success a
deriving Show
instance Functor (Validation err) where
fmap f (Success a) = Success (f a)
fmap _ (Failure e) = Failure e
import Data.Semigroup
import Data.Functor
import Control.Applicative
data Validation err a = Failure err | Success a
deriving Show
instance Functor (Validation err) where
fmap f (Success a) = Success (f a)
fmap _ (Failure e) = Failure e
@sjsyrek
sjsyrek / pedagogy.hs
Created May 5, 2017 09:08
Some Notes on Haskell Pedagogy - Code
{-# LANGUAGE InstanceSigs #-}
import Data.Monoid
import Test.QuickCheck
import Test.QuickCheck.Checkers
import Test.QuickCheck.Classes
data List a = EmptyList | ListElement a (List a)
deriving (Eq, Show)
@sjsyrek
sjsyrek / lazy-infinite-lists.js
Last active December 4, 2016 13:37
How I Implemented Lazy Infinite Lists in JavaScript with Proxy
// How I Used Proxy to Implement Lazy Infinite Lists in JavaScript
// Published on medium.com December 4, 2016 (http://bit.ly/2gVb1k5)
// Example code
// proxy example
class Secret {
constructor(msg) { this.info = msg }
}
@sjsyrek
sjsyrek / SheetThumbs.gs
Created February 14, 2015 00:26
Automatically insert thumbnails of Google Drive images directly into the cells of a Google Sheet using the =IMAGE(url) formula (not floating image overlays)
// Insert thumbnails of your Drive image files into a Google Sheet.
// Images are inserted directly into the cells of the sheet, not as those useless overlays that float around.
//
// This is set up to scan the first two columns of the active sheet. Column A will contain an =IMAGE(url) formula, which is calculated by finding the image thumbnail for the file referred to by column B.
// While this is simply the code I used for my own particular purpose, you can easily adapt it for your own needs. Please note that while an onEdit() version of this script would be cool, it will not work.
// Formulas cannot access most other Google Apps services, though you could probably use a data store if you felt ambitious enough.
// Note: the Drive Advanced API must be activated for this script to work.
//
// The script looks for files based on the pattern below: