Skip to content

Instantly share code, notes, and snippets.

@CoffeeAndCode
CoffeeAndCode / browserify.js
Created August 20, 2014 20:03
running Exorcist with Grunt Browserify after bundle creation
// This will create a readable stream that we can pipe our bundle to Exorcist with
var stream = require('stream');
var grunt = require('grunt');
var exorcist = require('exorcist');
var createSourceMap = function(err, src, next) {
var mapfile = grunt.template.process('<%= folders.output %>/<%= filenames.js %>.map');
var s = new stream.Readable();
s._read = function noop() {};
@CoffeeAndCode
CoffeeAndCode / idonethis_import.rb
Created June 11, 2014 12:01
Import to Day One app from idonethis csv export
require 'cgi'
require 'csv'
require 'open3'
def readfile(file)
data = {}
CSV.foreach(file) do |row|
date = row[0]
text = row[1]
@CoffeeAndCode
CoffeeAndCode / Guardfile
Created February 25, 2013 04:46
Mocking web requests when running specs in Guard only. If you run them through rspec (without setting the RSPEC_ENV environment variable to "guard") it will make the full web request.
guard 'rspec', :env => {'RSPEC_ENV' => 'guard'} do
# ...
end
@CoffeeAndCode
CoffeeAndCode / example.com-deploy
Created January 22, 2013 17:29
Amazon S3 user policy that allows the user to list the S3 buckets in the account, but only manage the files in the "example.com" bucket. Full post located at http://jonknapp.com/2013/01/deploying-jekyll-to-s3/
{
"Statement": [
{
"Action": [
"s3:ListAllMyBuckets"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::*"
},
{
@CoffeeAndCode
CoffeeAndCode / image.js
Last active December 11, 2015 01:48
Files used by High Resolution Images post at http://jonknapp.com/2013/01/high-resolution-images/
(function (window, devicePixelRatio, $, View, _) {
'use strict';
// I don't recommend adding objects on the window object, but it was quick.
window.ImageView = View.extend({
// Array of images that we will attempt to load.
// Images will be in priority order.
images: null,
@CoffeeAndCode
CoffeeAndCode / gist_tag.rb
Last active December 10, 2015 20:28 — forked from BinaryMuse/gist_tag.rb
I forked the original (https://gist.github.com/803483#file-gist_tag-rb) since I was having issues with Markdown / Jekyll trying to parse the <noscript> content and completely screwing it up. Removed the <noscript> tags and instead I hide the content with js once the page loads.
require 'cgi'
require 'digest/md5'
require 'net/https'
require 'uri'
module Jekyll
class GistTag < Liquid::Tag
def initialize(tag_name, text, token)
super
@text = text
@CoffeeAndCode
CoffeeAndCode / .profile
Last active December 10, 2015 19:08
Show if a Vagrant server is "on" or "off" in the command prompt if in a folder with a Vagrantfile. Code for http://jonknapp.com/2013/01/vagrant-status-in-the-command-line/
#
# Colors
#
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NORMAL="\[\033[0m\]"
DARK_PURPLE="\[\033[1;34m\]"
#
@CoffeeAndCode
CoffeeAndCode / image_path_tag.rb
Created January 5, 2013 03:24
Jekyll plugin to return <img> markup by only passing in the image filename and optional alt text. Image path is "/images/:year/:slug/:filename".
module Jekyll
class ImagePathTag < Liquid::Tag
@alt = nil
@url = nil
IMAGE_URL = /((https?:\/\/|\/)?(\S+))/i
IMAGE_URL_WITH_ALT = /((https?:\/\/|\/)?(\S+))(\s+)"(.*?)"/i
def initialize(tag_name, markup, tokens)
super