Skip to content

Instantly share code, notes, and snippets.

View stevewhitmore's full-sized avatar

Stephen Whitmore stevewhitmore

View GitHub Profile

Single line command to group many files into groups of however many. Useful for situations where there are directories with a very large amount of files:

i=0; for f in *; do d=dir_$(printf %03d $((i/100+1))); mkdir -p $d; mv "$f" $d; let i++; done

Running that command inside a directory with 1000 files will create 10 subdirectories with each containing 100 files. Each subdirectory will be names "dir_00{whatever iteration the loop is on".

Breakdown of command:

Including the CUSTOM_ELEMENTS_SCHEMA in the module allows the use of the web components in the HTML markup without the compiler producing errors

  • Defines a schema that allows an NgModule to contain the following:
    • Non-Angular elements named with dash case (-).
    • Element properties named with dash case (-).
  • Dash case is the naming convention for custom elements.

Reformat a USB

  1. Identify the volume
$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            3.4G     0  3.4G   0% /dev
tmpfs           695M  1.7M  693M   1% /run
/dev/nvme0n1p2  234G   19G  203G   9% /
@stevewhitmore
stevewhitmore / random-javascript-goodies.md
Last active April 6, 2020 12:08
Random JavaScript Goodies

Random JavaScript Goodies

Things I dont use often but come in handy.

// get font size of selected element
const a = document.querySelectorAll('nav ul li a')[0]
const fontSize = window.getComputedStyle(a, null).getPropertyValue('font-size');
console.log(fontSize); // "16px"
@stevewhitmore
stevewhitmore / gmail-smtp-bash.md
Last active April 23, 2021 22:59
To send mail via Gmail SMTP server
@stevewhitmore
stevewhitmore / handy-git-bits.md
Last active May 5, 2020 12:30
Handy git bits for those who forget

Handy Git Bits

How to merge feature branch to master branch (assuming you can push to master)

git checkout master
git pull origin master
git merge feature-branch
git push origin master
@stevewhitmore
stevewhitmore / forgotten-bash.md
Last active May 15, 2020 19:07
Random useful bash things

Find

find <directory> -iname <filename>                # find files
find <directory> -type d -iname <directory-name>  # find directory
find . -name "filename" -delete                   # delete all files with given name

Grep

@stevewhitmore
stevewhitmore / delete-all-node-modules.sh
Created November 15, 2019 04:52
Got a lot of node projects? Don't feel like searching for each and every node_modules folder so you can remove them when needed? This will save some time. Navigate to the directory your projects live in and run the command below.
find . -name "node_modules" -exec rm -rvf '{}' +