Skip to content

Instantly share code, notes, and snippets.

Avatar
💜
the beat goes on

englishextra englishextra

💜
the beat goes on
View GitHub Profile
@Ewpratten
Ewpratten / hosts-yt-ads
Last active Apr 27, 2021
youtube ads hosts file
View hosts-yt-ads
This project has been moved to a GitHub repository to allow Pull Requests.
See: https://github.com/Ewpratten/youtube_ad_blocklist
@Aymkdn
Aymkdn / loadExt.js
Last active Feb 26, 2021
To load JS and CSS files with vanilla JavaScript
View loadExt.js
// long version
function loadExt(files, after) {
var _this=this;
_this.files = files;
_this.js = [];
_this.head = document.getElementsByTagName("head")[0];
_this.after = after || function(){};
_this.loadStyle = function(file) {
var link = document.createElement("link");
link.rel = "stylesheet";
@thegitfather
thegitfather / vanilla-js-cheatsheet.md
Last active May 6, 2021
Vanilla JavaScript Quick Reference / Cheatsheet
View vanilla-js-cheatsheet.md
@englishextra
englishextra / ie8Events.js
Created Mar 20, 2016 — forked from chriswrightdesign/ie8Events.js
Polyfill for IE8 Javascript Event Listeners
View ie8Events.js
(function() {
if (!Event.prototype.preventDefault) {
Event.prototype.preventDefault=function() {
this.returnValue=false;
};
}
if (!Event.prototype.stopPropagation) {
Event.prototype.stopPropagation=function() {
this.cancelBubble=true;
};
@micahjon
micahjon / loadScript.js
Last active Nov 5, 2017
Promise-based Asynchronous Script Loader
View loadScript.js
/**
* Loads javascript file by url and saves reference to it by name, so it's not loaded again
* @param {string} name Name of js library
* @param {string} url Url to js library
* @return {promise} Resolves when library is loaded
*
* Based on example by Brad Berger: https://bradb.net/blog/promise-based-js-script-loader/
* Extended w/ global variable to keep track of previously loaded scripts.
* Removed support for loading several independent scripts at once via Promise.all()
*
@certainlyakey
certainlyakey / library.scss
Last active Apr 29, 2021
URL-encode color SASS function / convert color to hex SASS function
View library.scss
//does not work with colors containing alpha
@function encodecolor($string) {
@if type-of($string) == 'color' {
$hex: str-slice(ie-hex-str($string), 4);
$string:unquote("#{$hex}");
}
$string: '%23' + $string;
@return $string;
}
@SleepWalker
SleepWalker / swipe.js
Created Sep 30, 2015
A simple swipe detection on vanilla js
View swipe.js
var touchstartX = 0;
var touchstartY = 0;
var touchendX = 0;
var touchendY = 0;
var gesuredZone = document.getElementById('gesuredZone');
gesuredZone.addEventListener('touchstart', function(event) {
touchstartX = event.screenX;
touchstartY = event.screenY;
@cletusw
cletusw / .eslintrc
Last active Mar 28, 2021
ESLint Reset - A starter .eslintrc file that resets all rules to off and includes a description of what each rule does. From here, enable the rules that you care about by changing the 0 to a 1 or 2. 1 means warning (will not affect exit code) and 2 means error (will affect exit code).
View .eslintrc
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"defaultParams": false, // enable default function parameters
"forOf": false, // enable for-of loops
"generators": false, // enable generators
"objectLiteralComputedProperties": false, // enable computed object literal property names
@davidhund
davidhund / feature-detect flexbox.js
Last active Oct 17, 2019
The simplest feature-detect for flexbox?
View feature-detect flexbox.js
/*
* Trying to feature-detect (very naive)
* CSS Flexbox support.
* - Only most modern syntax
*
* Is this nonsense?
*/
(function NaiveFlexBoxSupport(d){
var f = "flex", e = d.createElement('b');
@jacrook
jacrook / font_variables.scss
Last active Sep 26, 2020
Sass Css Font Stack Variables
View font_variables.scss
//////////////////////////////////////////////////////////////
// Font Variables (http://cssfontstack.com/)
//////////////////////////////////////////////////////////////
//
// Serif font-stacks
//
$baskerville-font-stack: "Big Caslon", "Book Antiqua", "Palatino Linotype", Georgia, serif !default;