Skip to content

Instantly share code, notes, and snippets.

View iansinnott's full-sized avatar

Ian Sinnott iansinnott

View GitHub Profile
@iansinnott
iansinnott / emmet-tab-expansion.php
Created September 7, 2013 14:40
I've included a description of what I hope this would do bellow, but I think the easiest way to solve this would just be to change the line of your code that includes the match() function. If I new regex this would probably be pretty easy to exclude the string 'php' from the match so that the function wouldn't run expansion if tab was hit after …
<html>
<head>
</head>
<body>
<!-- So when i'm in an html document like this and I want to start typing php, I will just type 'php' as bellow -->
<!-- The '_' marks where the cursor is when I hit the tab key -->
php_
<!-- Then I would want that to expand to the line bellow, placing the cursor in the newly opened php tag -->
# This function does three things:
# 1. Cretes a directory for $sitename
# 2. Creates a hosts entry for $sitename
# 3. Creates a virtual-hosts entry for $sitename
#
# Note: Be careful with this function if you aren't comfortable
# with editing these system files yourself. If you enter a url you
# actiually use, say google.com, then whenever you try to go to
# google.com your browser will be pointed to your local google site
# at $HOME/Sites/google.com
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box; }
body {
background: #fafafa;
font-family: 'Helvetica Neue'; }
.wrap {
@iansinnott
iansinnott / gulpfile.js
Last active July 9, 2016 19:37
A gulpfile for working with Jekyll
// gulpfile.js
var gulp = require('gulp'),
gutil = require('gulp-util'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
rename = require('gulp-rename'),
shell = require('gulp-shell'),
livereload = require('gulp-livereload'),
lr = require('tiny-lr'),
@iansinnott
iansinnott / init.lua
Last active August 29, 2015 14:03
Move windows around using Vim-style hotkeys
-- ~/.hydra/init.lua
-- This file requires boosh.lua, which can be found in my dotfiles:
-- https://github.com/iansinnott/dotfiles/tree/master/dotfiles/hydra
require "boosh"
-- The 'meta' key for window actions will be cmd+shift.
local meta = {"cmd", "shift"}
--- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
@iansinnott
iansinnott / boosh.lua
Created July 4, 2014 00:57
A Hydra extension for allowing windows to be moved around the screen and resized easily.
-- ~/.hydra/boosh.lua
ext.grid = {}
-- Bits of this file were taken from:
-- https://github.com/sdegutis/hydra/wiki/grid.lua
local function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
@iansinnott
iansinnott / docker_wrapper.sh
Last active March 20, 2016 12:29
Automatically set up boot2docker on a Mac whenever `docker` is called
#!/bin/bash
# A wrapper for the docker binary. Checks to make sure the docker host is
# set before executing docker commands.
docker() {
# Start the daemon if it's not running
if [ $(boot2docker status) != 'running' ]; then
echo 'Starting the Docker daemon.'
boot2docker start
@iansinnott
iansinnott / anagrams.js
Created March 13, 2015 06:02
Find anagrams in an array – JavaScript
/**
* Alphabet weight: The index + 1 of each letter in the alphabet. We build this
* dictionary to allow speedy lookup of the index of any letter in the alpabet.
* We use i + 1 in order to avoid the case where 'a' would have a weight of
* zero.
*/
var ALPHABET_WEIGHT = {};
[].forEach.call('abcdefghijklmnopqrstuvwxyz', function(letter, i) {
ALPHABET_WEIGHT[letter] = i + 1;
" When opening a buffer open to the last line where the cursor was when
" exiting. See :help last-position-jump for more.
" NOTE: This opens with the cursor in the correct spot, but does not
" automcatically open folds.
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
@iansinnott
iansinnott / read-file.js
Last active November 26, 2015 05:21
Asynchronously read the contents of a user-uploaded file. A Promise wrapper around the FileReader API. IE 10+.
/**
* Asynchronously read a file. This is simply a wrapper around the FileReader
* API, which is not great.
* @param {File|Blob} file to read
* @return {Promise}
*/
export const readFile = file => {
return new Promise((resolve, reject) => {
const reader = new FileReader();