Skip to content

Instantly share code, notes, and snippets.

@rosko
rosko / what-forces-layout.md
Created April 25, 2024 21:49 — 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.

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
@rosko
rosko / onWindowFocus.js
Created July 8, 2021 01:12 — forked from tannerlinsley/onWindowFocus.ts
A utility function to detect window focusing without false positives from iframe focus events
const state = {
added: false,
interval: false,
inFrame: false,
callbacks: []
}
export default function onWindowFocus(cb) {
state.callbacks.push(cb)
start()
@rosko
rosko / README.md
Last active April 28, 2025 13:56
GunDB and JSON

To put JSON to Gun

gun.putJSON(json);

To get JSON from Gun

gun.open(() => {
@rosko
rosko / ChartLegend.js
Created August 3, 2016 19:16
Legend for rumble-charts
'use strict';
var React = require('react'),
_ = require('lodash'),
styler = require('react-styler');
var ChartLegend2 = React.createClass({
displayName: 'ChartLegend2',
@rosko
rosko / dev.js
Last active June 8, 2016 18:53
blessed
const blessed = require('blessed');
const {execFile} = require('child_process');
const screen = blessed.screen({
smartCSR: true
});
screen.title = 'my window title';
var box = blessed.box({
@rosko
rosko / README.md
Last active August 29, 2015 14:20 — forked from oodavid/README.md

Backup MySQL to Amazon S3

This is a simple way to backup your MySQL tables to Amazon S3 for a nightly backup - this is all to be done on your server :-)

Sister Document - Restore MySQL from Amazon S3 - read that next

1 - Install s3cmd

this is for Centos 5.6, see http://s3tools.org/repositories for other systems like ubuntu etc

@rosko
rosko / README.md
Last active August 29, 2015 14:20 — forked from oodavid/README.md

Restore MySQL from Amazon S3

This is a hands-on way to pull down a set of MySQL dumps from Amazon S3 and restore your database with it

Sister Document - Backup MySQL to Amazon S3 - read that first

1 - Set your MySQL password and S3 bucket, make a temp dir, get a list of snapshots

# Set our variables

export mysqlpass="ROOTPASSWORD"

@rosko
rosko / devshelf.sh
Created January 21, 2014 00:30 — forked from robhrt7/devshelf.sh
#!/bin/bash
#
# description: DevShelf service
# processname: node
# pidfile: /var/run/devshelf.pid
# logfile: /var/log/devshelf.log
#
# Based on https://gist.github.com/jinze/3748766
#
# To use it as service on Ubuntu:
@rosko
rosko / console.object.js
Last active January 3, 2016 15:18
Function for object debugging
window.console.object = function (obj, options) {
var defaultOptions = {
'label': 'obj',
'consoleFunction': 'log',
'showArguments': true,
'exclude': [],
'meterTime': false
};