Skip to content

Instantly share code, notes, and snippets.

View arniebradfo's full-sized avatar

James Bradford arniebradfo

View GitHub Profile
@svarlamov
svarlamov / typeform-countries-list.txt
Last active May 10, 2024 22:44
Typeform Global Countries List (Dropdown, Multiple Choice, Legal)
United States
United Kingdom
China
Canada
United Arab Emirates
Australia
Andorra
Afghanistan
Antigua and Barbuda
Anguilla
@paulirish
paulirish / what-forces-layout.md
Last active July 22, 2024 06:32
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
@darthmaim
darthmaim / event.js
Created August 20, 2015 09:27
Trigger native javascript event
function triggerNativeEvent( element, eventName ) {
// check if element is a jQuery object
if( element instanceof $ ) {
element = element[0];
}
// trigger event
if( element.dispatchEvent ) {
var event = document.createEvent( 'Events' );
event.initEvent( eventName, true, false );
@abynim
abynim / Sketch Plugin Snippet - Managing Files.js
Last active April 30, 2024 10:02
Sketch Plugin functions for working with files.
var writeTextToFile = function(text, filePath) {
var t = [NSString stringWithFormat:@"%@", text],
f = [NSString stringWithFormat:@"%@", filePath];
return [t writeToFile:f atomically:true encoding:NSUTF8StringEncoding error:nil];
}
var readTextFromFile = function(filePath) {
var fileManager = [NSFileManager defaultManager];
if([fileManager fileExistsAtPath:filePath]) {
return [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
@trepmal
trepmal / editor_plugin.js
Created October 3, 2011 23:17
WordPress: TinyMCE button that wraps selection in given tag
// http://tinymce.moxiecode.com/wiki.php/API3:class.tinymce.Plugin
(function() {
tinymce.create('tinymce.plugins.WRAP', {
/**
* Initializes the plugin, this will be executed after the plugin has been created.
* This call is done before the editor instance has finished its initialization so use the onInit event
* of the editor instance to intercept that event.
*