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 / gist:1959748
Created March 2, 2012 17:16
Running PHP scripts from CLI on Heroku
# Add this config
$ heroku config:add LD_LIBRARY_PATH=/app/php/ext:/app/apache/lib
# Login to Heroku CLI
$ heroku run bash
# The second argument here is the path to your script
~ $ ~/php/bin/php -f ~/www/index.php
@weotch
weotch / gist:4127482
Created November 21, 2012 20:34
Using modulo
<?
foreach($whatever as $i => $item) {
if ($i%3 === 0) //Open the ul
// Show the li like normal
if ($i%3 === 2 || count($whatever) - 1 === $i) // Close the ul
}
@weotch
weotch / .bash_profile
Created April 2, 2013 15:53
Adding MAMP's PHP to your PATH. Your profile may be ~/.bash_profile or ~/.profile.
PATH="/usr/local/sbin:/usr/local/bin:/usr/local/share/python:~/bin:/usr/local/share/npm/bin:/Applications/MAMP/bin/php/php5.3.6/bin:$PATH"
export PATH
@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.

@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 / 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 / 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 / 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 / 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 / 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(),