Skip to content

Instantly share code, notes, and snippets.

Avatar
👋
Coding

Zander Martineau mrmartineau

👋
Coding
View GitHub Profile
@premek
premek / mv.sh
Last active Jul 29, 2020
Rename files in linux / bash using mv command without typing the full name two times
View mv.sh
# Put this function to your .bashrc file.
# Usage: mv oldfilename
# If you call mv without the second parameter it will prompt you to edit the filename on command line.
# Original mv is called when it's called with more than one argument.
# It's useful when you want to change just a few letters in a long name.
#
# Also see:
# - imv from renameutils
# - Ctrl-W Ctrl-Y Ctrl-Y (cut last word, paste, paste)
@tkrotoff
tkrotoff / HowToTest.md
Last active Mar 28, 2020
How I structure my tests
View HowToTest.md

File structure

  • src/fooBar.js
  • src/fooBar.html
  • src/fooBar.scss
  • src/fooBar....
  • src/fooBar.test.js => npm run test
  • src/fooBar.test.e2e.js (if I have E2E tests - Puppeteer, Playwright...) => npm run test:e2e

Tests should not be separated from the source code (think autonomous modules).

@tomhicks
tomhicks / plink-plonk.js
Last active Aug 5, 2020
Listen to your web pages
View plink-plonk.js
@IanColdwater
IanColdwater / twittermute.txt
Last active Aug 13, 2020
Here are some terms to mute on Twitter to clean your timeline up a bit.
View twittermute.txt
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
@zephraph
zephraph / clean_node_modules.sh
Last active Apr 1, 2020
A shell script to clean up all node_modules in projects that haven't been touched in a couple weeks.
View clean_node_modules.sh
#!/bin/bash
DAYS_SINCE_LAST_CHANGE=14 # If a project hasn't been touched in this long its node_modules will be deleted
SEARCH_PATH="./Git" # Update this to the path where your code is stored
TOTAL_BYTES_REMOVED=0
Mb=1000000
Kb=1000
node_modules=$(find $SEARCH_PATH -name "node_modules" -type d -prune)
@Aidurber
Aidurber / cleanup.sh
Last active Jul 1, 2020
A handy script to clean up a mac thanks to - Gant Laborde's article: https://medium.freecodecamp.org/how-to-free-up-space-on-your-developer-mac-f542f66ddfb
View cleanup.sh
# Cleanup old node_modules
echo "Cleaning node_modules in projects older than 30 days"
find . -name "node_modules" -type d -mtime +30 | xargs rm -rf
echo "Done cleaning node_modules"
# Clean up homebrew
echo "Clean homebrew"
brew update && brew upgrade && brew cleanup
echo "Done cleaning homebrew"
@sarahbethfederman
sarahbethfederman / RichTextRenderer.js
Last active Feb 26, 2020
Using contentful with gatsby and react
View RichTextRenderer.js
import React from 'react';
import { Link as GatsbyLink } from 'gatsby';
import * as deepmerge from 'deepmerge';
import { INLINES, BLOCKS, MARKS } from '@contentful/rich-text-types';
import { documentToJSX } from './../scripts/documentToJSX';
import { getEntry } from './../scripts/getContentfulEntry';
const Link = ({ children, to, activeClassName, ...other }) => {
const internal = /^\/(?!\/)/.test(to);
@MoOx
MoOx / react-ui-kit-comparator.md
Last active Apr 16, 2020
Matrix of existing React ui kit (more than 200 download/week, more than 200 stars)
View react-ui-kit-comparator.md
View api-cheatsheet-array.md

Array<T>

Legend:

  • ✏️ method changes this.
  • 🔒 method does not change this.

Array<T>.prototype.*:

  • concat(...items: Array<T[] | T>): T[] 🔒 ES3
@Atinux
Atinux / async-foreach.js
Last active Aug 12, 2020
JavaScript: async/await with forEach()
View async-foreach.js
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
You can’t perform that action at this time.