Skip to content

Instantly share code, notes, and snippets.

@chriskalmar
chriskalmar / kebabify.ts
Last active January 5, 2024 15:55
Kebab-ify: Update all files and folders in your project to kebab-case and update all imports accordingly
/**
* Copyright (c) 2023 - Chris Kalmar
*
* CAUTION: This script will modify your files and folders. Make sure you have a backup!
*
* This script will rename all files and folders in a directory to kebab-case.
* It will also update all import paths in all files to reflect the renamed paths.
* For now only `import` statements are supported.
*
* Usage:
@chriskalmar
chriskalmar / retro-console-log.js
Created August 8, 2020 21:23
Retro console.log
console.log(
'%c Retro!',
'font-weight: bold; font-size: 70px; color: #F9DA4D; text-shadow: 5px 5px 0 #F2AA45, 10px 10px 0 #ED6255, 15px 15px 0 #EA3E81'
);
@chriskalmar
chriskalmar / dockerify.sh
Last active March 12, 2021 23:20
Install docker on a new machine
#!/bin/bash
# run:
# bash <(curl -fsSL <url-to-gist>)
apt-get update \
&& apt-get upgrade -y
bash <(curl -fsSL https://get.docker.com )
curl -L https://github.com/docker/compose/releases/download/1.28.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose \
@chriskalmar
chriskalmar / git-alias.sh
Last active June 3, 2019 21:08
git aliases
# delete alias:
# git config --global --unset alias.aliasName
git alias lol 'log --oneline --graph --decorate'
git alias pullbase '!f() { branchName=${1-master}; git checkout $branchName && git pull && git checkout - && git rebase $branchName; }; f'
git alias basepush '!f() { branchName=$(git name-rev --name-only HEAD); echo Merge "$branchName" and push origin; read && git checkout - && read && git merge $branchName && read && git push origin && read && git branch -d $branchName; }; f'
#
@chriskalmar
chriskalmar / sync-digitalocean-hosts.sh
Last active December 17, 2019 11:19
sync your digitalocean servers to your `/etc/hosts` file
#!/bin/bash
# install doctl and hostess before use:
# https://github.com/digitalocean/doctl
# https://github.com/cbednarski/hostess
#
# brew install doctl
# brew install hostess
PREFIX=yourdomain
@chriskalmar
chriskalmar / reset-git.txt
Created August 12, 2017 11:30 — forked from jasonhinkle/reset-git.txt
Reset Git Credentials
# clear old credentials
git credential-osxkeychain erase
host=github.com
protocol=https
<enter>
# view existing credentials
git credential-osxkeychain get
host=github.com
<enter>
@chriskalmar
chriskalmar / sort-keys.js
Created June 26, 2017 21:26 — forked from leebyron/sort-keys.js
Sort values by key order performance
var keys = [];
var results = [];
var keyCount = 100;
var iterations = 10000;
//generate keys 0 to <keycount>
for (var i=0; i < keyCount; i++) {
keys.push(i);
results.push({ id: i })
}
@chriskalmar
chriskalmar / sort-keys.js
Created June 26, 2017 21:26 — forked from leebyron/sort-keys.js
Sort values by key order performance
var keys = [];
var results = [];
var keyCount = 100;
var iterations = 10000;
//generate keys 0 to <keycount>
for (var i=0; i < keyCount; i++) {
keys.push(i);
results.push({ id: i })
}
/**
* Created at 03/17/2017
* Developed by Jorge Cuesta <jorge.s.cuesta@gmail.com>
* Developed by Jeffrey Soriano <jeffreysoriano5@gmail.com>
*/
// ### Use cases
/*
keys & data -> result
@chriskalmar
chriskalmar / lang.js
Created March 7, 2017 11:36 — forked from mirontoli/lang.js
Get Language name based on iso 639-1 code
/**
* @author Anatoly Mironov (mirontoli)
* http://sharepointkunskap.wordpress.com
* http://www.bool.se
*
* http://stackoverflow.com/questions/3605495/generate-a-list-of-localized-language-names-with-links-to-google-translate/14800384#14800384
* http://stackoverflow.com/questions/10997128/language-name-from-iso-639-1-code-in-javascript/14800499#14800499
*
* using Phil Teare's answer on stackoverflow
* http://stackoverflow.com/questions/3217492/list-of-language-codes-in-yaml-or-json/4900304#4900304