Skip to content

Instantly share code, notes, and snippets.

View weotch's full-sized avatar
👋
Heya

Robert Reinhard weotch

👋
Heya
View GitHub Profile
@weotch
weotch / html5-video-notes.md
Last active December 25, 2015 07:29
Notes on HTML5 video
  • iOS (even iPad) won't autoplay
  • An element with background-attachment: fixed won't respect that property when it's over a video in webkit
  • IE10 will show a black image while it's loading unless you set a poster property
  • In IE9, loop only works if the video is also autoplay
  • If you try to play a video in IE10 before it's ready, you will see black for a bit. This is a bummer, because autoplay is probably turned on for IE9.
  • I had mixed results getting videos to autoplay on Android. And a fair amount of browser crashing. In fact, in the end, I just disabled video altogehter.
  • On iOS, I created a play button (just an a) link, that when clicked takes the video from display:none to display:block while triggering the .play() API on the video element. This made the video go fullscreen on iPhone and play inline on iPad.
  • How to detect the fullscreen close on iPhone: http://stackoverflow.com/a/12169341/59160
  • A newer article on the subj: http://www.sitepoint.com/essential-audio-and-video-events
@weotch
weotch / view.js
Created October 14, 2013 21:31
Backbone view template
define(function (require) {
// Dependencies
var $ = require('jquery')
, _ = require('underscore')
, Backbone = require('backbone')
;
// Setup view
var View = {};
@weotch
weotch / defaults.js
Created October 14, 2013 22:20
Example of setting defaults using underscore
function(options) {
options = _.defaults(options || {}, {
offset: 0,
hesitate: false
});
}
@weotch
weotch / umd.js
Created February 10, 2014 19:29
Example of implementing UMD spec
// Based on https://github.com/umdjs/umd/blob/master/returnExports.js
(function (root, factory) {
// AMD
if (typeof define === 'function' && define.amd) {
define([
'jquery'
, 'lodash'
], factory);
@weotch
weotch / view.js
Last active August 29, 2015 13:57
Example change handler function. Does a basic fade.
// Change the page
View.change = function(e, new_page) {
// Make sure old page has lower z-index and stop any trams.
// Note: calling set() invokes stop()
var old = this.$slides.eq(e.previous('page')).tram()
.set({'z-index': 1})
;
// Hide the old one after the transition is done. Don't use
@weotch
weotch / browser-refresh.json
Last active August 29, 2015 13:57
My sublime settings
[
{
"keys": ["super+shift+r"], "command": "browser_refresh", "args": {
"auto_save": true,
"delay": 0.0,
"activate_browser": true,
"browser_name" : "Google Chrome"
}
}
]
<?php
// Homepage feed
public function index($filter = null) {
// Tell Laravel where to find the mustache views for post
app('view')->addNamespace('js', public_path().'/js');
// Render the view
$this->layout->nest('content', 'gadget.index', array(
@weotch
weotch / .bash_profile
Last active April 13, 2016 15:28
.bash_profile
# Path
export PATH="~/.composer/vendor/bin:/usr/local/bin:/Applications/MAMP/bin/php/php5.5.26/bin:$PATH"
# Change prompt
export PS1="\[\e[0;36m\]\w \[\e[33m\]⇢\[\e[49m\] \[\e[m\]"
# Use atom as editor
export EDITOR='atom --wait'
export GIT_EDITOR='atom --wait'
@weotch
weotch / view.js
Created May 13, 2014 17:30
Basic backbone template
define(function (require) {
// Dependencies
var $ = require('jquery')
, _ = require('lodash')
, Backbone = require('backbone')
;
// Setup view
var View = {};
@weotch
weotch / header.html
Created June 18, 2014 19:24
Custom modernizr tests
<script src="/js/libs/modernizr.js"></script>
<script type="text/javascript">
var ua = navigator.userAgent;
Modernizr.addTest('retina', window.devicePixelRatio > 1);
Modernizr.addTest('webkit', navigator.userAgent.match(/AppleWebKit/i));
Modernizr.addTest('ipad', navigator.userAgent.match(/iPad/i));
Modernizr.addTest('iphone', navigator.userAgent.match(/iPhone/i));
Modernizr.addTest('ipod', navigator.userAgent.match(/iPod/i));
Modernizr.addTest('ios', Modernizr.ipad || Modernizr.ipod || Modernizr.iphone);
Modernizr.addTest('android', navigator.userAgent.match(/Android/i));