Skip to content

Instantly share code, notes, and snippets.

View im-sad's full-sized avatar
🌈
its okay to be gay

Andrew im-sad

🌈
its okay to be gay
View GitHub Profile
@davidtheclark
davidtheclark / isElementInViewport.js
Created May 4, 2013 02:00
JavaScript: Is element in viewport?
/*
No jQuery necessary.
Thanks to Dan's StackOverflow answer for this:
http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport
*/
function isElementInViewport(el) {
var rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@pongstr
pongstr / shorthand-javascript-techniques.md
Last active June 22, 2022 20:09
Shorthand Coding Techniques. Original post by @samdeering http://www.sitepoint.com/shorthand-javascript-techniques/

Javascript Shorthand Coding Techniques

My (@pongstr) opinion about shorthand coding techniques

Shorthand code is not really a replacement for normal coding but it is very handy and useful in some cases. There are tons of opinions and debates around this but, again it all comes down what is necessary for your codebase and using it responsibly.

@juanbrujo
juanbrujo / sass-maps-index-iterator.css
Created August 4, 2015 13:49
sass-maps loop with index iterator
/**
* output from sass-maps-index-iterator.scss
*/
li:nth-of-type(1):before {
content: "english - hello";
}
li:nth-of-type(2):before {
content: "spanish - hola";
}
@ymatuhin
ymatuhin / checkWebpSupport.js
Last active May 8, 2021 13:20
Check WebP Support in browser
function checkSupport(fn) {
var html = document.documentElement,
WebP = new Image();
WebP.onload = WebP.onerror = function() {
isSupported = (WebP.height === 2);
if (isSupported) {
if (html.className.indexOf('no-webp') >= 0)
html.className = html.className.replace(/\bno-webp\b/, 'webp');
@VinnyFonseca
VinnyFonseca / addeventlistener-multiple-events.js
Last active January 12, 2023 16:08
addEventListener multiple events
['change', 'keyup', 'paste', 'input', 'propertychange', 'every_other_event_you_want'].forEach(eventType => {
[...document.querySelectorAll('SELECTOR')].forEach(element => {
element.addEventListener(eventType, (event) => {
console.log(event);
// Your callback here
}, false);
});
});
@neretin-trike
neretin-trike / pug.md
Last active July 25, 2024 15:54
Туториал по HTML препроцессору Pug (Jade)
@KRostyslav
KRostyslav / tsconfig.json
Last active July 22, 2024 16:00
tsconfig.json с комментариями.
// Файл "tsconfig.json":
// - устанавливает корневой каталог проекта TypeScript;
// - выполняет настройку параметров компиляции;
// - устанавливает файлы проекта.
// Присутствие файла "tsconfig.json" в папке указывает TypeScript, что это корневая папка проекта.
// Внутри "tsconfig.json" указываются настройки компилятора TypeScript и корневые файлы проекта.
// Программа компилятора "tsc" ищет файл "tsconfig.json" сначала в папке, где она расположена, затем поднимается выше и ищет в родительских папках согласно их вложенности друг в друга.
// Команда "tsc --project C:\path\to\my\project\folder" берет файл "tsconfig.json" из папки, расположенной по данному пути.
// Файл "tsconfig.json" может быть полностью пустым, тогда компилятор скомпилирует все файлы с настройками заданными по умолчанию.
// Опции компилятора, перечисленные в командной строке перезаписывают собой опции, заданные в файле "tsconfig.json".