Skip to content

Instantly share code, notes, and snippets.

@twinraven
twinraven / skew-new-feature-process.md
Last active February 3, 2021 09:31
Task process

Creating a new feature

Product owner writes a short brief, outlining:

  • What will this feature enable (Requirements)
  • How will this feature be presented to the user (Key features)
  • How will the user interact with it (User interactions)

Kick-off (all attend):

@twinraven
twinraven / classname.decorator.ts
Created August 2, 2017 11:38
Angular 2/4+ decorator for creating a dynamic classname binding on a component
/**
* Creates a dynamic classname on a component, bound to a property or @Input.
*
* @example
* @Input() @BindClassName({ prefix: '-theme-' }) theme: string;
*
* @example
* @BindClassName({ prefix: '-position-' }) position: string;
*/
@twinraven
twinraven / gist:4136424
Created November 23, 2012 16:42
HTML: HTML5 video with Flash fallback
<video width="640" height="360" controls>
<!-- mp4 must be first for iPad! -->
<source src="/library/videos/demo.mp4" type="video/mp4" /><!-- Safari / iOS video -->
<source src="/library/videos/demo.ogv" type="video/ogg" /><!-- Firefox / Opera / Chrome10 -->
<!-- fallback to Flash: -->
<object width="640" height="360" type="application/x-shockwave-flash" data="__FLASH__.SWF">
<!-- Firefox uses the `data` attribute above, IE/Safari uses the param below -->
<param name="movie" value="__FLASH__.SWF" />
<param name="flashvars" value="controlbar=over&amp;image=__POSTER__.JPG&amp;file=/library/videos/demo.mp4" />
<!-- fallback image. note the title field below, put the title of the video there -->
@twinraven
twinraven / gist:4130674
Created November 22, 2012 11:26
JS: GetDevicePixelWidth
/*! GetDevicePixelWidth | Includes: GetDevicePixelRatio | Author: Tyson Matanich, 2012 | License: MIT */
(function (window) {
window.getDevicePixelWidth = function (assumeLandscape) {
// Don't assume reorientation to landscape by default
assumeLandscape = assumeLandscape || false;
// Get the screen dimension
var screenWidth = (assumeLandscape == false || window.screen.width > window.screen.height) ? window.screen.width : window.screen.height;
// Increase size if window inner size is larger (Fix for multi display setups, especially IE)
@twinraven
twinraven / gist:4130671
Created November 22, 2012 11:25
JS: GetViewportWidth
/*! GetViewportWidth | Author: Tyson Matanich, 2012 | License: MIT */
(function (window) {
window.getViewportWidth = function () {
var width;
var document = window.document;
var documentElement = document.documentElement;
if (window.innerWidth === undefined) {
// IE6 & IE7 don't have window.innerWidth
width = documentElement.clientWidth;
}
@twinraven
twinraven / gist:4130668
Created November 22, 2012 11:24
JS: GetDevicePixelRatio
/*! GetDevicePixelRatio | Author: Tyson Matanich, 2012 | License: MIT */
(function (window) {
window.getDevicePixelRatio = function () {
var ratio = 1;
// To account for zoom, change to use deviceXDPI instead of systemXDPI
if (window.screen.systemXDPI !== undefined && window.screen.logicalXDPI !== undefined && window.screen.systemXDPI > window.screen.logicalXDPI) {
// Only allow for values > 1
ratio = window.screen.systemXDPI / window.screen.logicalXDPI;
}
else if (window.devicePixelRatio !== undefined) {
@twinraven
twinraven / gist:3973932
Created October 29, 2012 14:43
CSS: Hide element visually
.is-vishidden {
position: absolute;
overflow: hidden;
width: 1px;
height: 1px;
padding: 0;
border: 0;
clip: rect(1px, 1px, 1px, 1px);
}
@twinraven
twinraven / hideaddrbar.js
Created October 24, 2012 10:38 — forked from scottjehl/hideaddrbar.js
Javascript: Normalized hide address bar, iOS & Android
/*
* Normalized hide address bar for iOS & Android
* (c) Scott Jehl, scottjehl.com
* MIT License
*/
(function( win ){
var doc = win.document;
// If there's a hash, or addEventListener is undefined, stop here
if( !location.hash && win.addEventListener ){
@twinraven
twinraven / index.html
Created October 24, 2012 10:32
HTML: responsive boilerplate
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<title></title>
<meta charset="utf-8">
<meta name="description" content="">