Skip to content

Instantly share code, notes, and snippets.

View rossshannon's full-sized avatar

Ross Shannon rossshannon

View GitHub Profile
@rossshannon
rossshannon / router.php
Created July 8, 2018 20:08
How to serve PHP files with .html file extensions using the built-in PHP server
<?php
$requestedAbsoluteFile = dirname(__FILE__) . $_SERVER['REQUEST_URI'];
if (!preg_match('/\.html|\.php$/', $requestedAbsoluteFile)) {
header('Content-Type: '.mime_content_type($requestedAbsoluteFile));
return false;
}
include_once $requestedAbsoluteFile;
@rossshannon
rossshannon / form_elements_builder.rb
Created January 18, 2016 00:10
Custom FormBuilder subclass to enable simple Ladda-enabled form buttons in Rails
class FormElementsBuilder < ActionView::Helpers::FormBuilder
# This is added to the normal form builder options, by adding
# <%= form_for(resource, as: resource_name, url: registration_path(resource_name), builder: FormElementsBuilder) do |f| %>
# then call it like this: <%= f.ladda_submit_button "Sign up" %>
def ladda_submit_button(label, *args)
options = args.extract_options!
behaviour = options[:behaviour] || 'expand-left'
@template.content_tag("button", {class: "ladda-button submit", 'data-style' => behaviour }) do
@template.content_tag("span", label.to_s.humanize, class: 'ladda-label')
### Keybase proof
I hereby claim:
* I am rossshannon on github.
* I am rossshannon (https://keybase.io/rossshannon) on keybase.
* I have a public key whose fingerprint is 87FC 879F B364 1FCF B69C 879A 1563 46E6 237D 744A
To claim this, I am signing this object: