Skip to content

Instantly share code, notes, and snippets.

View wayneseymour's full-sized avatar
💭
ABC...always be coding :)

Tre' wayneseymour

💭
ABC...always be coding :)
View GitHub Profile
@wayneseymour
wayneseymour / bash_strict_mode.md
Created February 1, 2023 11:13 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation
@wayneseymour
wayneseymour / git-ssh-error-fix.sh
Created March 15, 2022 10:41 — forked from Tamal/git-ssh-error-fix.sh
Solution for 'ssh: connect to host github.com port 22: Connection timed out' error
$ 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
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
// 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!
@wayneseymour
wayneseymour / fp_arch.js
Created September 20, 2020 16:29 — forked from DrBoolean/fp_arch.js
OO => FP architecture refactor
// 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
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})`
@wayneseymour
wayneseymour / fp-either-monad.js
Created June 11, 2020 16:00 — forked from mrosata/fp-either-monad.js
Functional JavaScript Monad Classes - (Maybe Just Nothing) - (Either Left Right) (IOMonad) and my type checking utils
import is from './is-util';
/**
* Either Monad class (from Functional Programming in JavaScript)
*/
class Either {
constructor(value) {
this._value = value;
}
get value () {
@wayneseymour
wayneseymour / rxjs-from-stream.js
Created May 15, 2020 17:22 — forked from QuentinRoy/rxjs-from-stream.js
Transform a node stream into an rxjs Observer
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);
}
@wayneseymour
wayneseymour / screen.md
Created April 9, 2020 16:21 — forked from fredrick/screen.md
GNU Screen Cheat Sheet

#GNU Screen Cheat Sheet

##Basics

  • ctrl a c -> cre­ate new win­dow
  • ctrl a A -> set win­dow name
  • ctrl a w -> show all win­dow
  • ctrl a 1|2|3|… -> switch to win­dow n
  • ctrl a " -> choose win­dow
  • ctrl a ctrl a -> switch between win­dow
  • ctrl a d -> detach win­dow