Skip to content

Instantly share code, notes, and snippets.

@benknight
benknight / dabblet.css
Created August 10, 2012 18:28
HTML Email buttons that work in Outlook 2007+
/**
* HTML Email buttons that work in Outlook 2007+
*
* This is a really weird hacked up piece of crap but basically the technique is the containing element has some solid color background,
* and the inner <a> has a solid border which acts like padding which is the same color as the background color
*/
@Vestride
Vestride / encoding-video.md
Last active June 5, 2024 14:38
Encoding video for the web

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
@BenMorel
BenMorel / viewport-units-ios.scss
Last active March 11, 2022 13:15
SCSS mixin to support vh and vw units on all iOS Safari versions. Based on an idea by Patrick Burtchaell's: https://gist.github.com/pburtchaell/e702f441ba9b3f76f587
/**
* Fix for vw, vh, vmin, vmax on iOS 7.
* http://caniuse.com/#feat=viewport-units
*
* This fix works by replacing viewport units with px values on known screen sizes.
*
* iPhone 6 and 6 Plus cannot run iOS 7, so are not targeted by this fix.
* Target devices running iOS 8+ will incidentally execute the media query,
* but this will still produce the expected result; so this is not a problem.
@paulirish
paulirish / what-forces-layout.md
Last active June 26, 2024 20:47
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
@sruf
sruf / restore-files-from-sourcemap.js
Created November 7, 2016 20:13
Restore files from Sourcemap contents
/*
I needed a way to restore the actual files from a Sourcemap. This is the easiest way I could come up with.
To use, replace the content of map with your actual sourcemap -- however, be careful to check the paths, as this script might overwrite anything in its way.
*/
/*
MIT License
Copyright (c) 2016 Simon Ruf
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active June 27, 2024 09:17
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@mariocesar
mariocesar / api.js
Created September 26, 2017 04:21
Axios single configured instance
import axios from "axios";
const singleton = Symbol();
const singletonEnforcer = Symbol();
function readCookie(name) {
const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
return (match ? decodeURIComponent(match[3]) : null);
}
@GFoley83
GFoley83 / deferred-promise.ts
Created April 26, 2018 07:37
Deferred Promise for Typescript
/**
* A new instance of deferred is constructed by calling `new DeferredPromse<T>()`.
* The purpose of the deferred object is to expose the associated Promise
* instance APIs that can be used for signaling the successful
* or unsuccessful completion, as well as the state of the task.
* @export
* @class DeferredPromise
* @implements {Promise<T>}
* @template T
* @example
@huangzhuolin
huangzhuolin / deploy-create-react-app-with-nginx.md
Last active April 5, 2024 11:09
[Deploy create-react-app(react-router) with nginx] #react #nginx

Create-react-app

Create React apps with no build configuration.

Thanks to create-react-app. It's saves a lot of my time. I remember several months ago I had to setup a lot just for a react app, webpack, babel, test environment and so on... Fortunately, everything becomes easy now. Though you have many choices of start boiler plate, you worth trying this.

React router

If you are build a SPA with react, you probably use react-router.

@KRostyslav
KRostyslav / tsconfig.json
Last active June 23, 2024 17:44
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".