Skip to content

Instantly share code, notes, and snippets.

Andy Holland AMHOL

Block or report user

Report or block AMHOL

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Promise.php
<?php namespace AMH;
use Exception;
use Jeremeamia\SuperClosure\SerializableClosure;
use Symfony\Component\Process\PhpProcess;
class PromiseValueException extends Exception {}
class Promise
{
@AMHOL
AMHOL / gist:10000063
Created Apr 6, 2014
config/templating.php
View gist:10000063
<?php
return [
'extensions' => [
'functions' => [
'url' => function($app) {
return function($name, $params) use ($app) {
return $app->getContainer()->resolve('\Autarky\Routing\RouterInterface')
->getRouteUrl($name, $params);
};
}
@AMHOL
AMHOL / angular_ie_cors.md
Created Jun 17, 2014
Angular JS IE CORS fix - if you control the API server
View angular_ie_cors.md

-- CORS FIX - IF YOU CONTROL THE API SERVER

Add the following somewhere in your application config

app.run([
  '$window',
  function($window) {
    if ( !$window.location.origin ) {
      $window.location.origin = $window.location.protocol + "//" + $window.location.hostname + ($window.location.port ? ':' + $window.location.port : '');
View ex.rb
require 'transproc/all'
require 'json'
json = <<-EOS
{
"links": {
"self": "http://example.com/posts",
"next": "http://example.com/posts?page[offset]=2",
"last": "http://example.com/posts?page[offset]=10"
},
@AMHOL
AMHOL / Category drop-down
Created Nov 8, 2012
Create recursive category drop-down navigation by assigning data('children') to navigation li and calling elem.createDropdownFromChildren
View Category drop-down
(($) ->
$.fn.createDropdownFromChildren = ($level) ->
$elem = $(@)
# if element has children data
unless @data("children") is "undefined"
@bind
# MOUSE ENTER
mouseenter: ->
clearTimeout $(document).data("dd-timeout")
View config initializers date_time_formats.rb
Date::DATE_FORMATS[:default] = '%d/%m/%Y'
# if you want to change the format of Time display then add the line below
Time::DATE_FORMATS[:default]= '%d/%m/%Y %H:%M:%S'
# if you want to change the DB date format.
Time::DATE_FORMATS[:db]= '%d/%m/%Y %H:%M:%S'
View error_presenter.rb
# gem install i18n
require 'i18n'
require 'delegate'
class ErrorPresenter < SimpleDelegator
attr_reader :root_key
private :root_key
def initialize(root_key, model)
@root_key = root_key
@AMHOL
AMHOL / jquery.placeholder-fallback.js
Created Dec 18, 2012
HTML5 placeholder fallback for browsers that don't support it, implemented in jQuery. NOTE: This will not work for elements added to the DOM after initial load
View jquery.placeholder-fallback.js
// Function to test for attribute support
function elSupportsAttr(el, attr) {
return attr in document.createElement(el);
}
// does input support placeholder? if not, add fallback
if ( !elSupportsAttr('input', 'placeholder') ) {
$(document).ready(function() {
// everything with placeholder attr
$('[placeholder]').each(function() {
$(this).val($(this).attr('placeholder'));
@AMHOL
AMHOL / gist:4633484
Created Jan 25, 2013
Javascript get host
View gist:4633484
window.location.protocol + '//' + window.location.hostname + (!!window.location.port ? ':' + window.location.port : '')
@AMHOL
AMHOL / gist:5327827
Created Apr 6, 2013
Library for building dependencies with ActiveResource
View gist:5327827
module ResourceHas
def self.included base
unless base.ancestors.include? InheritedResources::Base
raise '%s must inherit from InheritedResources::Base to implement ResourceHas' % base.name
end
base.extend(ClassMethods)
base.append_before_filter :__build_relations
end
## Class methods
module ClassMethods
You can’t perform that action at this time.