Skip to content

Instantly share code, notes, and snippets.

@gustavwennerblom
gustavwennerblom / gist:b17a6b8c12a6e10f88306ad3e42f26bd
Last active November 23, 2022 23:43
Adding prettier to a CRA project

Adding prettier to a CRA project

Previously, I've had some problem to reliaby configure code formatting with Prettier in VSCode, in the context of a create-react-app proejct. Today, it worked like a charm, and this is what I did.

Preconditions:

  • react-scripts: "3.1.1"
  • react: "^16.9.0"
  • react-dom: "^16.9.0"
  • Dirk Baeumer's ESLint VSCode extension installed and running
@fgerschau
fgerschau / keybindings.json
Created July 18, 2018 07:24
Keybindings for switching tabs in VSCode (open with ⌘K ⌘S)
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "cmd+0",
"command": "workbench.action.openLastEditorInGroup"
},
{
"key": "cmd+1",
"command": "workbench.action.openEditorAtIndex1"
},
# Echo number of GIT commits per year.
git log --pretty='format:%cd' --date=format:'%Y' | uniq -c | awk '{print "Year: "$2", commits: "$1}'
@JawsomeJason
JawsomeJason / _element.scss
Last active August 29, 2019 07:12
Sass Mixin to generate `@element` EQCSS Element Queries
/// Helper for EQCSS Element Queries `@element`
///
/// @author Jason Featheringham
/// @link https://gist.github.com/thejase/d2107285b6e10315dd6bc055115647fe Code source
/// @link http://elementqueries.com/ Plugin to parse EQCSS
/// @link https://gist.github.com/tomhodgins/6237039fa07c2e4b7acd1c8b0f9549a9 EQCSS syntax
///
/// @param {String} $scope (&) - Optional scope. Defaults to current context
/// @param {List} $conditions (()) - 1+ of Maps of EQCSS conditions
/// @content rules to enclose in element query
@Rich-Harris
Rich-Harris / service-workers.md
Last active April 21, 2024 16:24
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@stuarteberg
stuarteberg / show-git-branch-in-bash-prompt
Last active October 10, 2021 17:55
Code for your .bashrc file. Show current git branch on bash shell prompt....with color! (This was copied and modified from similar code you can find out there on the 'tubes.)
# Colors for the prompt
blue="\033[0;34m"
white="\033[0;37m"
green="\033[0;32m"
# Brackets needed around non-printable characters in PS1
ps1_blue='\['"$blue"'\]'
ps1_green='\['"$green"'\]'
ps1_white='\['"$white"'\]'
@ValeriiVasin
ValeriiVasin / color.js
Created December 11, 2012 19:25
Colorized output in nodejs
var color, i;
// Notice: octal literals are not allowed in strict mode.
function colorize(color, output) {
return ['\033[', color, 'm', output, '\033[0m'].join('');
}
for (i = 0; i < 100; i += 1) {
color = Math.random() > 0.9 ? 91 : 92; // 91 - red, 92 - green
process.stdout.write( colorize(color, '●') );
@tijn
tijn / git-lines-per-author.sh
Last active January 31, 2019 19:18
Produce a histogram with lines of code per author.
#!/bin/sh
git ls-tree -r HEAD | sed -Ee 's/^.{53}//' | \
while read filename; do file "$filename"; done | \
grep -E ': .*text' | sed -E -e 's/: .*//' | \
while read filename; do git blame --line-porcelain "$filename"; done | \
sed -n 's/^author //p' | \
sort | uniq -c | sort -rn