Skip to content

Instantly share code, notes, and snippets.

@nathansmith
nathansmith / npm.bat
Last active July 18, 2017 15:15
Force specific NPM version to be used, in a locked-down Windows environment.
@echo npm.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
@echo off
"c:\program files\nodejs\X.X.X\node" --max_old_space_size=4096 "c:\program files\nodejs\X.X.X\node_modules\npm\bin\npm-cli.js" %1 %2 %3 %4 %5 %6 %7 %8 %9
@echo
@nathansmith
nathansmith / email_about_react.md
Last active September 21, 2016 01:57
This is an email I sent to a friend from church, about React.
@runspired
runspired / .bash_profile
Last active February 6, 2023 14:56
Make Alfred / Spotlight ignore node_modules and bower_components
alias nom='npm cache clean && rm -rf node_modules && mkdir node_modules && touch node_modules/.metadata_never_index && npm install'
alias bom='bower cache clean && rm -rf bower_components && mkdir bower_components && touch bower_components/.metadata_never_index && bower install'
@paulirish
paulirish / what-forces-layout.md
Last active May 20, 2024 17:15
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@boennemann
boennemann / README.md
Last active March 30, 2021 23:00
Pushing new releases of a legacy version with semantic-release

If you have a package where a lot of people are still using a legacy version of it you might want to keep pushing (security-)fixes to that "branch".

Let's say the "latest" version of your package is "5.4.0", but there is as significant amount of people still using "4.7.4" – the last version you released before doing "5.0.0".

You found a critical bug in "5.4.0" and push it as out as "5.4.1", but it applies to "4.7.4" as well and so you want to do "4.7.5".

Assuming you have semantic-release already set up, you can follow these steps to get that "4.7.5" legacy support release out.

  1. Go to the relevant commit: git checkout v4.7.4
  2. Create a new branch from it: git checkout -b 4.x (You can choose any branch name, just make sure to use the same in step 3)
@davidhund
davidhund / pragmatic-touch-icons.md
Last active September 4, 2020 15:42
Pragmatic Touch Icons

NOTE I'm trying to find the most optimal fav/touch icon setup for my use-cases. Nothing new here. Read Mathias Bynens' articles on re-shortcut-icon and touch icons, a FAQ or a Cheat Sheet for all the details.

I'd like to hear how you approach this: @valuedstandards or comment on this gist.

The issue

You have to include a boatload of link elements pointing to many different images to provide (mobile) devices with a 'favicon' or 'touch icon':

![Touch Icon Links](https://o.twimg.com/2/proxy.jpg?t=HBj6AWh0dHBzOi8vcGhvdG9zLTYuZHJvcGJveC5jb20vdC8yL0FBRGFGY1VRN1dfSExnT3cwR1VhUmtaUWRFcWhxSDVGRjNMdXFfbHRJWG1GNFEvMTIvMjI3OTE2L3BuZy8xMDI0eDc2OC8yL18vMC80L1NjcmVlbnNob3QlMjAyMDE1LTA0LTE0JTIwMTYuNTYuMjYucG5nL0NNejBEU0FCSUFJZ0F5Z0JLQUkvNGR1eDZnMzZmYnlzYWI3

# Has your OS/FS/disk lost your data?
# cd to the directory containing your project repositories and run the command
# below. (It's long; make sure you get it all.) It finds all of your git repos
# and runs paranoid fscks in them to check their integrity.
(set -e && find . -type d -and -iname '.git' | while read p; do (cd "$(dirname "$p")" && (set -x && git fsck --full --strict)); done) && echo "OK"
# I have 81 git repos in my ~/proj directory and had no errors.
@Atlas48
Atlas48 / template-ex.json
Last active August 29, 2015 14:04
DnD 3.5e character sheet data encoding template
{
name:{
charname:"Zutash Zutashin",
playername:"Jan Serps"
},
details:{
clarrace:{
class:{
primary:"bard",
secondary:"fighter"
@nathansmith
nathansmith / cache.js
Last active September 27, 2018 15:47
Example of self-clearing cache using window.localStorage
// Set up "namespace."
var APP = APP || {};
// `Shared settings.
//----------------------------------------------------------------------------------------------------
APP.config = APP.config || {};
// How long to keep cache, in minutes.
APP.config.cache_duration = APP.config.cache_duration || 15;
@thoop
thoop / .htaccess
Last active January 27, 2024 14:07
Official prerender.io .htaccess for Apache.
# Change YOUR_TOKEN to your prerender token
# Change http://example.com (at the end of the last RewriteRule) to your website url
<IfModule mod_headers.c>
RequestHeader set X-Prerender-Token "YOUR_TOKEN"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On