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 / 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 / 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 / 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 / main.js
Last active March 13, 2016 12:23
Backbone routing example using require.js
// This our standard require js bootstrap file. It assumes you are using the
// require-jquery.js file that require.js provides
// Set the require.js configuration for the application
require.config({
// Base path used to load scripts
baseUrl: 'js/',
// Prevent caching during dev
urlArgs: "bust=" + (new Date()).getTime(),
@weotch
weotch / adding_tap_events_to_a_elements.md
Last active December 18, 2015 05:09
Adding tap events to <a> elements

Adding tap events to <a> elements

Stack

  • Hammer.js
  • jQuery
  • Underscore
  • Backbone

Problem

@weotch
weotch / scale.scss
Created May 16, 2013 18:31
Using a @mixin to help with responsive
.feature {
// Declare sizes that will be used to calculate different break points
$height: 460px;
$feature-image-width: 531px;
$feature-image-height: 382px;
$feature-right: 20px;
$h1-size: 39px;
$h2-size: 30px;
@weotch
weotch / view.js
Created April 29, 2013 23:03
Basic view creation
// Generates the gallery on the home page and allows
// user to paginate
define(function(require) {
// Dependencies
var $ = require('jquery'),
_ = require('underscore'),
Backbone = require('backbone');
// Init view
@weotch
weotch / steps.md
Last active December 16, 2015 04:28
benCoding.AlarmManager Module build steps
  1. Download https://github.com/benbahrenburg/benCoding.AlarmManager/archive/master.zip

  2. cd into the Module directory

  3. Run brew install ant android-ndk

  4. Edit build.properties to match your local enviornment. Mine looks like this:

     titanium.platform=/Users/reinhard/Library/Application Support/Titanium/mobilesdk/osx/3.0.2.GA/android
     android.platform=/Users/reinhard/Documents/Android SDK/platforms/android-8
     google.apis=/Users/reinhard/Documents/Android SDK/add-ons/addon-google_apis-google-8
     android.ndk=/usr/local/bin/
    
@weotch
weotch / Laravel 4: Service Providers and Facades.md
Last active December 15, 2019 01:55
Laravel 4: Service Providers and Facades

Lets look at how Facades work in Laravel 4 by investigating the flow of one of the facaded classes: URL. As in <?=URL::route('news')?>.

The logic flow

As you'll see in the summary, this isn't exactly described in the procedural order your app is executed. But I think it serves to explain what's going on.

  1. The app config has an aliases array. In there is: 'URL' => 'Illuminate\Support\Facades\URL'. If you look up that class, you'll see it just has this: protected static function getFacadeAccessor() { return 'url'; } and that it inherits from Illuminate\Support\Facades\Facade. We'll get back to this later.

  2. Lets now turn to how the app boots up. The /vendor/laravel/framework/src/Illuminate/Foundation/start.php bootstrap file calls registerAliasLoader() on an instance of Illuminate\Foundation\Application.

@weotch
weotch / info.md
Last active September 5, 2016 09:01
Adding Memcache and Redis to MAMP 2.1.3 (PHP 5.3.20)

Adding Memcache and Redis to MAMP 2.1.3 (PHP 5.3.20)

Not sure how long this will be good for, but here's an easy path to adding Memached and Redis support to MAMP 2.1.3. It depends on the fact that, right now, the Homebrew PHP project and MAMP are using the same versions of PHP. This assumes you have Homebrew and MAMP 2.1.3 installed. I'll just be describing the process for PHP 5.3.20.

  1. Make sure you've tapped homebrew-dupes and homebrew-php with: brew tap homebrew/dupes and brew tap josegonzalez/php.

  2. Install memcached and redis for PHP Homebrew: brew install php53-memcache and brew install php53-redis.

  3. Go into MAMP and navigate to: File menu > Edit Template > PHP > PHP 5.3.2.0 php.ini.