Skip to content

Instantly share code, notes, and snippets.

View nmccready's full-sized avatar

nmccready nmccready

View GitHub Profile
@tansongyang
tansongyang / cartesian-product-lodash-fp.js
Last active October 8, 2023 23:45
An implementation of Cartesian product using lodash/fp
// Based on this gist: https://gist.github.com/ChrisJefferson/cb8db2a4c67a9506c56c
// JS Bin: https://jsbin.com/cefopi/edit?js,console
const cartesianProduct = (...rest) =>
_.reduce((a, b) =>
_.flatMap(x =>
_.map(y =>
x.concat([y])
)(b)
)(a)
)([[]])(rest);
@bahmutov
bahmutov / Docker shell commands.sh
Last active February 9, 2024 07:55
A personal cheat sheet for running local Node project in a Docker container
# See list of docker virtual machines on the local box
$ docker-machine ls
NAME ACTIVE URL STATE URL SWARM DOCKER ERRORS
default * virtualbox Running tcp://192.168.99.100:2376 v1.9.1
# Note the host URL 192.168.99.100 - it will be used later!
# Build an image from current folder under given image name
$ docker build -t gleb/demo-app .
@Restuta
Restuta / framework-sizes.md
Last active March 7, 2024 00:01
Sizes of JS frameworks, just minified + minified and gzipped, (React, Angular 2, Vue, Ember)

Below is the list of modern JS frameworks and almost frameworks – React, Vue, Angular, Ember and others.

All files were downloaded from https://cdnjs.com and named accordingly. Output from ls command is stripped out (irrelevant stuff)

As-is (minified)

$ ls -lhS
566K Jan 4 22:03 angular2.min.js
@apparentlymart
apparentlymart / Terraform-State-Ideas.md
Last active December 24, 2022 17:10
Terraform State Integrity Issues

Issues with Terraform State Management

The idea of "state" is the lynchpin of Terraform, and yet Terraform's workflow is fraught with gotchas that can lead to the loss or destruction of state. This doc is a set of notes about issues I've encountered, what caused them, and in many cases ideas about how to improve Terraform to avoid or reduce the chances of them.

Each of these scenarios has occured at least within my team. Each time one of these occurs it erodes people's confidence in Terraform, giving it a reputation for being fragile and unforgiving of errors. This this document is not written just to criticize but rather to identify ways in which the situation could be improved.

@mislav
mislav / poor_promise.js
Last active May 21, 2021 21:52
Poor man's Promise is a minimal but complete implementation of Promises/A+ spec.
(function(self){
if (self.Promise) return
// Implements https://promisesaplus.com
function isFunction(fn) {
return typeof fn == 'function'
}
// Values that should never be checked for presence of a `then` method
function simpleValue(fn) {
lazy val dotEnvFile = taskKey[String]("Defines the file to load environment variables from")
dotEnvFile := ".env"
// The task returns the loaded dotEnv file and a map of the loaded variables, in case it would need to be manipulated somewhere else
lazy val loadEnv = taskKey[(File, Map[String, String])]("""Loads the environment variables from file defined by task `dotEnvFile` (they must follow the format "export X=Y")""")
loadEnv := {
val logger = ConsoleLogger()
val sourceFileName = dotEnvFile.value
@u0d7i
u0d7i / disable_vim_auto_visual_on_mouse.txt
Last active February 27, 2024 14:08
Disable vim automatic visual mode on mouse select
Disable vim automatic visual mode on mouse select
issue: :set mouse-=a
add to ~/.vimrc: set mouse-=a
my ~/.vimrc for preserving global defaults and only changing one option:
source $VIMRUNTIME/defaults.vim
set mouse-=a
@bleathem
bleathem / gist:50b4dd2fd4377503eaad
Last active August 22, 2018 20:54
Creating an Rx.js Observable from a STOMP over Websocket source (with error handling)
// see: https://github.com/jmesnil/stomp-websocket
var client = Stomp.client('ws://...');
client.debug = undefined;
var live = Rx.Observable.create(function (observer) {
console.log('Connecting...')
client.connect(username, password, function(frame) {
console.log(frame.toString());
observer.onNext(frame);
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxfiles</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
@escapedcat
escapedcat / yourCtrl.js
Last active February 13, 2018 17:48
angular-google-maps directions service example
addresses = addressService.query();
addresses.$promise.then(function (result) {
console.log('task query done');
createWaypointsFromAddresses(addresses);
return uiGmapGoogleMapApi;
})
.then( function(maps) {