Skip to content

Instantly share code, notes, and snippets.

View paularmstrong's full-sized avatar
🐈‍⬛
Codes with cats

Paul Armstrong paularmstrong

🐈‍⬛
Codes with cats
View GitHub Profile
@paularmstrong
paularmstrong / what-forces-layout.md
Created August 8, 2017 19:18 — forked from paulirish/what-forces-layout.md
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.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@paularmstrong
paularmstrong / memorySizeOfObject.js
Created March 16, 2017 17:03
calculate memory size of javascript object, it is not a accurate value!
function memorySizeOf(obj) {
var bytes = 0;
function sizeOf(obj) {
if(obj !== null && obj !== undefined) {
switch(typeof obj) {
case 'number':
bytes += 8;
break;
case 'string':
@paularmstrong
paularmstrong / memorySizeOfObject.js
Created March 16, 2017 17:03
calculate memory size of javascript object, it is not a accurate value!
function memorySizeOf(obj) {
var bytes = 0;
function sizeOf(obj) {
if(obj !== null && obj !== undefined) {
switch(typeof obj) {
case 'number':
bytes += 8;
break;
case 'string':
@paularmstrong
paularmstrong / ignore.txt
Last active August 26, 2016 00:52 — forked from dapperfu/pia.sh
.Spotlight*
.Trash*
.AppleDouble*
Thumbs.db
.DocumentRevisions*
.AppleDB*
.AppleDesktop*
.apdisk*
.TemporaryItems*
@paularmstrong
paularmstrong / Safari GC Repro
Last active March 30, 2016 16:33 — forked from alunny/bundle.js
Safari GC Issue: Normalizr + Lodash
.
@paularmstrong
paularmstrong / wordpress-nfd-to-nfc-filename-conversion.sh
Created November 11, 2015 17:49 — forked from dessibelle/wordpress-nfd-to-nfc-filename-conversion.sh
Two commands needed to perform UTF-8 NFD to NFC decomposition on all files in a directory, and uploading the resulting directory to a webserver. Useful for treating files created on a Linux server (NFC), downloaded to Mac OS X (NFD) and needing to be uploaded back to the original server (NFC). Must, naturally, be run on Linux or at least used on…
#!/usr/bin/env bash
convmv -f utf8 -t utf8 --nfc --replace --nosmart --no-test -r uploads/
rsync -avz -e ssh uploads/ username@host:mysite.com/public_html/wordpress/wp-content/uploads
#################################################################################
# start and stop the vpn from the command line from now on with these two commands
# or rename the aliases as you see fit.
#################################################################################
alias startvpn="sudo launchctl load -w /Library/LaunchDaemons/net.juniper.AccessService.plist; open -a '/Applications/Junos Pulse.app/Contents/Plugins/JamUI/PulseTray.app/Contents/MacOS/PulseTray'"
alias quitvpn="osascript -e 'tell application \"PulseTray.app\" to quit';sudo launchctl unload -w /Library/LaunchDaemons/net.juniper.AccessService.plist"
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
@paularmstrong
paularmstrong / install.sh
Created October 10, 2012 04:51 — forked from maggit/install.sh
Chef installer for OS X 10.8 Mountain Lion
#!/bin/bash
# This is the current stable release to default to, with Omnibus patch level (e.g. 10.12.0-1)
# Note that the chef-full template downloads 'x.y.z' not 'x.y.z-r' which should be a duplicate of the latest -r
release_version="10.12.0-1"
use_shell=0
# Check whether a command exists - returns 0 if it does, 1 if it does not
exists() {
if command -v $1 &>/dev/null
@paularmstrong
paularmstrong / clients.md
Created September 25, 2011 20:01 — forked from defunkt/clients.md
A list of Gist clients.

Gist Clients

Want to create a Gist from your editor, the command line, or the Services menu? Here's how.

Editor Support