This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git clone [email protected]:xxxxx/xxxx.git my-awesome-proj | |
Cloning into 'my-awesome-proj'... | |
ssh: connect to host github.com port 22: Connection timed out | |
fatal: Could not read from remote repository. | |
$ # This should also timeout | |
$ ssh -T [email protected] | |
ssh: connect to host github.com port 22: Connection timed out | |
$ # but this might work |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Parser = WebParser | DbParser | |
class ParseStrategy p where | |
parse :: p -> String -> String | |
instance ParseStrategy Parser where | |
parse WebParser s = "code for parsing web stuff goes here" | |
parse DbParser s = "code for parsing db stuff goes here" | |
fromDB = parse DbParser |
To see a working version of the code check out https://codesandbox.io/s/j497w26383 and open the console.
This file demonstrates a very basic List as an applicative functor for the purpose of demonstrating a simple list comprehension.
The idea for this was taken from: https://egghead.io/lessons/javascript-list-comprehensions-with-applicative-functors by https://twitter.com/drboolean
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Finally wrapped your head around Promises? Time to toss out all that knowledge and learn the functional alternative! | |
// Here's a super simple implementation of a Task "type" | |
const __Task = fork => ({fork}) | |
// Absurdly simple! All we're doing is using a function that returns some unknown value, by name, in an object. | |
// At this point "fork" is just a cute name though: what matters is how we use it. | |
// What makes Task a "Task" is that is that the "fork" value here... will be a higher-order function. | |
// Here's a usage example, already fully functional, already nearly as powerful as Promise! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple example, but the idea holds for more complex objects. | |
/* 1) Start with OO */ | |
// user.js | |
class User { | |
constructor(firstName, lastName, email) { | |
this.firstName = firstName | |
this.lastName = lastName |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Maybe = { | |
Just: value => ({ | |
value, | |
map: f => Just(f(value)), | |
toString: () => `Just(${value})` | |
}), | |
Nothing: (value = null) => ({ | |
value: null, | |
map: f => Nothing(null), | |
toString: () => `Nothing(${value})` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import is from './is-util'; | |
/** | |
* Either Monad class (from Functional Programming in JavaScript) | |
*/ | |
class Either { | |
constructor(value) { | |
this._value = value; | |
} | |
get value () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Observable } from 'rxjs'; | |
// Adapted from https://github.com/Reactive-Extensions/rx-node/blob/87589c07be626c32c842bdafa782fca5924e749c/index.js#L52 | |
export default function fromStream(stream, finishEventName = 'end', dataEventName = 'data') { | |
stream.pause(); | |
return new Observable((observer) => { | |
function dataHandler(data) { | |
observer.next(data); | |
} |
#GNU Screen Cheat Sheet
##Basics
- ctrl a c -> create new window
- ctrl a A -> set window name
- ctrl a w -> show all window
- ctrl a 1|2|3|… -> switch to window n
- ctrl a " -> choose window
- ctrl a ctrl a -> switch between window
- ctrl a d -> detach window
NewerOlder