Skip to content

Instantly share code, notes, and snippets.

View developit's full-sized avatar
🦊
write, the codes

Jason Miller developit

🦊
write, the codes
View GitHub Profile
@developit
developit / WTF IS JSX.md
Last active June 27, 2020 14:49
WTF IS JSX

Moved to my new blog: jasonformat.com/wtf-is-jsx

It's actually really straightforward. Take 1 minute and read this.

Pragma

You declare this per-file or per-function to tell your transpiler (eg: Babel) the name of a function that should be called (at runtime) for each node.

@NickBeeuwsaert
NickBeeuwsaert / PrintElement.js
Last active July 3, 2016 07:21
Chrome DevTools snippet to print out a element
/* Attempts to screen-shot a element onto a canvas */
var css = function(el, styles){
for (var style in styles) {
if(!styles.hasOwnProperty(style)) continue;
el.style[style] = styles[style];
}
return el;
};
var selectElement = function(callback){
var selection = document.createElement("div");
@NickCraver
NickCraver / Windows10-Setup.ps1
Last active February 6, 2025 04:09
(In Progress) PowerShell Script I use to customize my machines in the same way for privacy, search, UI, etc.
##################
# Privacy Settings
##################
# Privacy: Let apps use my advertising ID: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 0
# To Restore:
#Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 1
# Privacy: SmartScreen Filter for Store Apps: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost -Name EnableWebContentEvaluation -Type DWord -Value 0
@developit
developit / dom-recycler.js
Last active April 16, 2016 21:42
dom-recycler.js
/** Typed DOM node factory with reclaimation */
let recycler = {
collect(node) {
recycler.clean(node);
let name = node.nodeName,
list = recycler.nodes[name];
if (list) list.push(node);
else recycler.nodes[name] = [node];
},
create(nodeName) {
@developit
developit / bind-decorator.js
Created August 10, 2015 14:06
bind-decorator.js
/** Bind a method to lexical scope.
* @example
* class Foo {
* @bind
* bar() {
* assert.ok( this instanceof Foo );
* }
* }
*/
export default (target, key, { value: fn }) => ({
@ebidel
ebidel / object-observe-proxy-polyfill.js
Last active July 29, 2021 04:08
Object.observe() polyfill using ES6 Proxies (POC)
// An `Object.observe()` "polyfill" using ES6 Proxies.
//
// Current `Object.observe()` polyfills [1] rely on polling
// to watch for property changes. Proxies can do one better by
// observing property changes to an object without the need for
// polling.
//
// Known limitations of this technique:
// 1. the call signature of `Object.observe()` will return the proxy
// object. The original object needs to be overwritten with this return value.
@domenic
domenic / escape-vm.js
Created August 17, 2015 20:20
Escaping the vm sandbox
"use strict";
const vm = require("vm");
const sandbox = { anObject: {} };
const whatIsThis = vm.runInNewContext(`
const ForeignObject = anObject.constructor;
const ForeignFunction = ForeignObject.constructor;
const process = ForeignFunction("return process")();
const require = process.mainModule.require;
require("fs");
@paulirish
paulirish / what-forces-layout.md
Last active May 16, 2025 16:40
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
let behaviorA = {
greet(greeting) {
return greeting;
}
};
@mixes(behaviorA)
class Foo {
@gaearon
gaearon / slim-redux.js
Last active December 3, 2024 06:34
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {