Skip to content

Instantly share code, notes, and snippets.

moehlone / make_writable.js
Created Mar 17, 2016
Make JavaScript readonly propertys writable (example for overwriting navigator.userAgent; useful for unit tests -> browser detection)
View make_writable.js
* Creates a read/writable property which returns a function set for write/set (assignment)
* and read/get access on a variable
* @param {Any} value initial value of the property
function createProperty(value) {
var _value = value;
ustun / eslint-auto.el
Created Jan 12, 2016
run eslint --fix on emacs file save
View eslint-auto.el
;;; runs eslint --fix on the current file after save
;;; alpha quality -- use at your own risk
(defun eslint-fix-file ()
(message "eslint --fixing the file" (buffer-file-name))
(shell-command (concat "eslint --fix " (buffer-file-name))))
(defun eslint-fix-file-and-revert ()
Restuta /
Last active Jul 19, 2022
Sizes of JS frameworks, just minified + minified and gzipped, (React, Angular 2, Vue, Ember)

Below is the list of modern JS frameworks and almost frameworks – React, Vue, Angular, Ember and others.

All files were downloaded from and named accordingly. Output from ls command is stripped out (irrelevant stuff)

As-is (minified)

$ ls -lhS
566K Jan 4 22:03 angular2.min.js
kdzwinel / main.js
Last active Jul 31, 2022
List all undefined CSS classes
View main.js
This script attempts to identify all CSS classes mentioned in HTML but not defined in the stylesheets.
In order to use it, just run it in the DevTools console (or add it to DevTools Snippets and run it from there).
Note that this script requires browser to support `fetch` and some ES6 features (fat arrow, Promises, Array.from, Set). You can transpile it to ES5 here: .
Known limitations:
- it won't be able to take into account some external stylesheets (if CORS isn't set up)
- it will produce false negatives for classes that are mentioned in the comments.
paulirish /
Last active Aug 12, 2022
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
View react.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
cirocosta /
Created Jul 9, 2015
naive http server stress tester using cURL
#### Default Configuration
show_help() {
cat << EOF
richard-flosi / assertions-compareScreenshot.js
Created Aug 27, 2014
Nightwatch with Visual Regression testing
View assertions-compareScreenshot.js
// assertions/compareScreenshot.js
var resemble = require('resemble'),
fs = require('fs');
exports.assertion = function(filename, expected) {
var screenshotPath = 'test/screenshots/',
baselinePath = screenshotPath + 'baseline/' + filename,
resultPath = screenshotPath + 'results/' + filename,
diffPath = screenshotPath + 'diffs/' + filename;
somebox /
Last active Jul 18, 2016
graphite-redis : monitor redis statistics with graphite across several hosts
#!/usr/bin/env ruby
require 'socket'
# This script runs every minute, captures stats about redis
# and forwards them to graphite as counter values.
# Graphite/carbon settings
willurd /
Last active Aug 9, 2022
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000