Skip to content

Instantly share code, notes, and snippets.

View Lochlan's full-sized avatar

Lochlan McIntosh Lochlan

View GitHub Profile

Perl Complaints of the Day

  1. Only lambdas can be closures, not named subroutines.

  2. The idiomatic way of getting a list’s length is to assign it to a scalar.

    my @coolList = (1, 2, 3);
    my $coolListLength = @coolList;
@Lochlan
Lochlan / trigger-change-file-input
Created February 23, 2015 07:48
This is how you trigger a `change` event on `<input type="file">` with JavaScript — useful for testing!
// vanilla JS
var event = document.createEvent("UIEvents");
event.initUIEvent("change", true, true);
document.querySelector('input[type=file]').dispatchEvent(event);
// jQuery
$('input[type=file]').trigger('change');
@Lochlan
Lochlan / index.html
Created October 20, 2014 21:03
HTML5 Page Boilerplate
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="description" content="HTML5 Webpage">
<title>HTML5 Webpage</title>
</head>
<body>
</body>
@Lochlan
Lochlan / gist:5672127e09a50841bcb5
Created September 29, 2014 02:44
Preferences.sublime-settings
{
"draw_white_space": "all",
"font_size": 9,
"ignored_packages":
[
"Vintage"
],
"tab_size": 4,
"translate_tabs_to_spaces": true,
"detect_indentation": true
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no">
<title>Tarot.com: Undergoing Maintenance</title>
<style type="text/css">
@font-face {
font-family: 'Jenna Sue';
font-style: normal;
@Lochlan
Lochlan / backToTop.js
Last active August 29, 2015 14:05
Backbone BackToTopView
define([
'jquery',
'underscore',
'backbone',
], function ($, _, Backbone) {
'use strict';
var BackToTopView = Backbone.View.extend({
initialize: function (options) {
_(this.options).extend(options);
@Lochlan
Lochlan / namespace-input.scss
Last active August 29, 2015 14:02
CSS "namespacing"
// ----
// Sass (v3.3.8)
// Compass (v1.0.0.alpha.19)
// ----
// CSS "namespacing"
namespaceFoo {
@at-root {
&-bar {
content: 'bar';
@Lochlan
Lochlan / SassMeister-input-HTML.html
Created June 17, 2014 07:46
Sass: @extend and child selectors
<div class="parent">
parent
<div class="child">child</div>
<div class="child-foo">child-foo</div>
</div>
@Lochlan
Lochlan / SassMeister-input.scss
Created June 17, 2014 00:01
Generated compound selectors in Sass 3.3
// ----
// Sass (v3.3.8)
// Compass (v1.0.0.alpha.19)
// ----
@mixin element-compound($selector) {
$elements: a, p, div;
@each $el in $elements {
@at-root #{$el + $selector} {
@extend #{$selector};