Skip to content

Instantly share code, notes, and snippets.

@gregberns
gregberns / ListToListOfLists.txt
Last active November 29, 2018 07:21
List a -> Int -> Int -> List (List a)
//How can we do this imperitive process with Haskell/Purescript style functions?
//Examples
// > generateQuestions([1,2,3,4,5,6,7,8])(3)(2)
// [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]
// > generateQuestions([1,2,3,4,5])(2)(4)
// [ [ 1, 2 ], [ 3, 4 ], [ 5, 1 ], [ 2, 3 ] ]
@gregberns
gregberns / universe-css-getting-started.md
Last active November 20, 2018 16:03
Getting Started Guide to UniVerse MultiValue

UniVerse (CSS) - Getting Started

Get Connected

  1. Install Putty

  2. Connect to server over ssh

  3. Login with username then password

using System;
using System.Linq;
using System.Collections.Generic;
namespace DearCSharpYouLose {
public static class FuncExtension {
public static Func<A, C> Select<A, B, C>(this Func<A, B> f, Func<B, C> g) {
return a => g(f(a));
}
@gregberns
gregberns / haskell-course.hs
Created October 2, 2018 05:35
Intro Syntax for Haskell
{-# OPTIONS_GHC -fwarn-incomplete-patterns -Werror #-}
-- Show
-- p1 =
-- ...
-- method(f,f)
-- ...
-- p2 =
-- ...
@gregberns
gregberns / FunctionDeclaration.cs
Created September 17, 2018 15:35
C# Lambda Cheat Sheet
//Local Declaration
Func<string> returnsString = () => "";
Func<int, int> takesIntReturnsInt = i => i * 2;
//Class-Level Declaration
//Generic Params
@gregberns
gregberns / Cabal 2.2.0.0 Fails
Last active August 27, 2018 06:59
Cabal Install fails
Download `cabal-install-2.2.0.0-x86_64-apple-darwin-sierra.tar.gz`
Extract
Run:
Gregs-MacBook-Pro:downloads huck$ ./cabal --version
cabal-install version 2.2.0.0
compiled using version 2.2.0.1 of the Cabal library
Gregs-MacBook-Pro:downloads huck$ ./cabal install Cabal cabal-install
Warning: Parsing the index cache failed (Unknown encoding for constructor).
Trying to regenerate the index cache...
@gregberns
gregberns / mapFilterReduceOnObject.js
Created June 7, 2018 18:29
Implementation of Map, Filter, and Reduce on an Object to iterate through its keys
let map = (f, o) => {
//o must be an object
let keys = Object.keys(o);
let ret = {};
for (let i = 0; i <= keys.length - 1; i++) {
let key = keys[i];
let val = o[key];
ret[key] = f(val, key);
}
return ret;
@gregberns
gregberns / diamond.hs
Created May 20, 2018 17:45
Diamond Kata in Haskell - First Attempt
import Data.Traversable
main =
traverse print (genAll 'J')
-- [_,_,A,_,_]
-- [_,B,_,B,_]
-- [C,_,_,_,C]
-- [_,B,_,B,_]
-- [_,_,A,_,_]
@gregberns
gregberns / buildFeaturePreview-final.js
Created May 18, 2018 07:11
Refactor Spectacular - List to String
buildFeaturePreview(vehicle: IVehicle): string {
let mpg = this.shouldShowMpg(vehicle) ? `${vehicle.MPGCity} / ${vehicle.MPGHighway} MPG` : null;
let features = vehicle.HighlightedFeatures.map(feature => feature.description);
return [mpg,
...features]
.filter(isDefinedAndNotNull)
.join(', ')
'...';
}
@gregberns
gregberns / VSCode Setup.md
Last active June 26, 2018 20:27
How to set up VSCode with helpful features

VSCode

Linting TS Files

Install 'TSLint' plugin

Run this command:

npm install -g tslint typescript