Skip to content

Instantly share code, notes, and snippets.

@zinovyev
zinovyev / tt
Last active July 19, 2023 14:25
Create directory and file paths recursively
#! /usr/bin/env bash
# Create file or directory with parent directories
# For a more detalied description please take a look at:
# https://zinovyev.net/blog/create-files-and-directories-with-parent-directories
HELP_MESSAGE=$(cat <<EOM
Create files or directories with underlying path
Usage Examples:
@gagarine
gagarine / fish_install.md
Last active May 3, 2024 08:11
Install fish shell on macOS Mojave with brew

Installing Fish shell on MacOS (Intel and M1) using brew

Fish is a smart and user-friendly command line (like bash or zsh). This is how you can instal Fish on MacOS and make your default shell.

Note that you need the https://brew.sh/ package manager installed on your machine.

Install Fish

brew install fish

@william8th
william8th / .tmux.conf
Last active April 30, 2024 17:03
Tmux open new pane in same directory
# Set the control character to Ctrl+Spacebar (instead of Ctrl+B)
set -g prefix C-space
unbind-key C-b
bind-key C-space send-prefix
# Set new panes to open in current directory
bind c new-window -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
@przbadu
przbadu / react-on-docker.md
Last active December 16, 2023 13:44
Setup Docker for React development

STEP 2: setup docker to run react app (dev and production) configuration: https://gist.github.com/przbadu/929fc2b0d5d4cd78a5efe76d37f891b6

Setup Docker for React development

Because we are using Docker, we are not going to install node, npm, create-react-app in our development machine, not even for generating create-react-app scaffold.

For this purpose I am using 2-step docker configuration:

  • In first step, we will create a simple docker container, that does only one thing, install create-react-app
const Reader = f =>
({
 run: f,
 map: g => Reader(x => g(f(x))),
 chain: g => Reader(x => g(f(x)).run(x))
})
Reader.of = x => Reader(() => x)
// function application
@nmcgann
nmcgann / pub-sub.js
Created February 10, 2017 16:38
Simple JS Pub-Sub implementation. Synchronous or Asynchronous.
/*
* Simple Publish / subscribe events routine.
*
* Used to extend an object with the subscribe and publish methods.
* The return value of subscribe has a remove method that can be used
* to unsubscribe.
*
* Modifies the object directly.
*/
var $$ = $$ || {}; //This is the utility functions object used elsewhere.
@bastibe
bastibe / cd.fish
Created January 23, 2017 15:08
A fish function to automatically activate a venv called ".env" in the current git root
#!/bin/env fish
function cd -d "change directory, and activate virtualenvs, if available"
# first and foremost, change directory
builtin cd $argv
# find a parent git directory
if git rev-parse --show-toplevel >/dev/null ^/dev/null
set gitdir (realpath (git rev-parse --show-toplevel))
else
@HereChen
HereChen / convert-image-to-base64.js
Last active March 29, 2022 11:31
convert image to base64
/**
* version1: convert online image
* @param {String} url
* @param {Function} callback
* @param {String} [outputFormat='image/png']
* @author HaNdTriX
* @example
convertImgToBase64('http://goo.gl/AOxHAL', function(base64Img){
console.log('IMAGE:',base64Img);
})
@tonymtz
tonymtz / gist:d75101d9bdf764c890ef
Last active December 29, 2023 00:40
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@donnut
donnut / currying.md
Last active October 28, 2023 17:58
TypeScript and currying

TypeScript and currying

In functional programming you often want to apply a function partly. A simple example is a function add. It would be nice if we could use add like:

var res2 = add(1, 3); // => 4

var add10To = add(10);
var res = add10To(5); // => 15