Skip to content

Instantly share code, notes, and snippets.

View adamwiggall's full-sized avatar
🏠
Working from home

Adam Wiggall adamwiggall

🏠
Working from home
View GitHub Profile
myNamespace.worldPeace = function() {
var worldProblems = document.getElementById('big_problems');
// if we don't have any problems just return
if (!worldProblems.length) return;
// if we got this far we have some solving to do
// so write some great code and restore peace to the world!
...
@adamwiggall
adamwiggall / matrix_pagination
Created August 5, 2011 00:55
Pagination Page x of x (using Matrix)
Page {if segment_3}{exp:simple_math calculate="{segment_3}/{rows_per_page}+1"}{if:else}1{/if} of {exp:simple_math calculate="ceil({gallery_images:total_rows}/{rows_per_page})"}
site URLs work like ...com/gallery/gallery-name/{n}
@adamwiggall
adamwiggall / Keep Directories
Last active December 20, 2015 18:38
Often you have a directory in a git repo that you want to share amongst developers, but you don't want the contents tracked. As git ignores empty directories, if you just .gitignore the directory completely it will never get added to the repo and shared. The example shows how to use this technique for the cache folder in an expressionengine inst…
From the command line
$ touch your/path/to/expressionengine/cache/.gitkeep
In your .gitignore file
your/path/to/expressionengine/cache/*
!your/path/to/expressionengine/cache/.gitkeep
@adamwiggall
adamwiggall / sublime keymap
Created February 12, 2014 18:33
Swap key bindings for pasting with indent and pasting without in Sublime Text
// Better indenting by swapping the indent command around
{ "keys": ["super+shift+v"], "command": "paste" },
{ "keys": ["super+v"], "command": "paste_and_indent" }
@adamwiggall
adamwiggall / Markdown Settings
Created July 16, 2014 13:49
Syntax specific setting in Sublime Text
{
// Which file extensions go with this file type?
"extensions":
[
"md",
"mdown",
"mdwn",
"mmd",
"txt"
],
defmodule Collatz do
def conjecture(int) when int < 2 do
raise ArgumentError, message: "Requires an integer value greater than 1"
end
def conjecture(int), do: conjecture(int, 0)
defp conjecture(1, 1), do: "Reduced to 1 in 1 step"
defp conjecture(1, steps), do: "Reduced to 1 in #{steps} steps"
(function() {
var mapThat;
mapThat = function() {
var geojson, map, markerLayer;
if (!$('#map').length) {
return;
}
map = mapbox.map('map');
class DateRange
attr_accessor :range, :format, :custom_start_date, :custom_end_date
def initialize(range, options = {})
@range = range ? range.to_s : options[:default].to_s
@format = options[:format]
@custom_start_date = options[:start_date].to_formatted_date(@format) if options[:start_date]
@custom_end_date = options[:end_date].to_formatted_date(@format) if options[:end_date]
end
def to_a
class DateRange
attr_accessor :range, :format, :custom_start_date, :custom_end_date
def initialize(range, options = {})
@range = range ? range.to_s : options[:default].to_s
@format = options[:format]
@custom_start_date = options[:start_date].to_formatted_date(@format) if options[:start_date]
@custom_end_date = options[:end_date].to_formatted_date(@format) if options[:end_date]
end
def to_a

Keybase proof

I hereby claim:

  • I am adamwiggall on github.
  • I am adamwiggall (https://keybase.io/adamwiggall) on keybase.
  • I have a public key ASCyidHqrNS5L7RZcMpdmrB3RdIwkcDWLKsPcVKGIvzJ0Qo

To claim this, I am signing this object: