Skip to content

Instantly share code, notes, and snippets.

View DylanFM's full-sized avatar

Dylan Fogarty-MacDonald DylanFM

View GitHub Profile
@toolmantim
toolmantim / 1 Readme.md
Created July 26, 2012 19:39
Minification with newlines using the Rails 3 asset pipeline

Retaining line numbers with the Rails asset pipeline

By default the Rails 3 asset pipeline uses the Uglifier gem to optimize and minify your Javascript. One of its many optimisations is to remove all whitespace, turning your Javascript into one very long line of code.

Whist removing all the newlines helps to reduce the file size, it has the disadvantage of making your Javascript harder to debug. If you've tried to track down Javascript errors in minified Javascript files you'll know the lack of whitespace does make life harder.

Luckily there is a simple solution: to configure Uglifier to add newlines back into the code after it performs its optimisations. And if you're serving your files correctly gzip'd, the newlines add only a small increase to the final file size.

You can configure Uglifier to add the newlines by setting the following in your Rails 3 config/production.rb file:

Don't go to Fishermans Wharf. Drive out to Santa Cruz, Muir Woods, Point Reyes, Napa and Sonoma.
If you want to spend 500USD on a meal then get a ticket to Saison Chef's Counter. Highly recommended.
Walk around Embarcadero. Check out Golden Gate Park. Do you like to ride bicycles?
Head to Umi and Tataki South for sushi. Head to Chez Maman and Papito. Piccino. Plow for brunch, be sure to have the potatoes.
Don't do brunch on the weekend though. You'll always have to wait. Weekdays are best.
@benschwarz
benschwarz / Readme.md
Created November 12, 2012 11:59
Use postmarkapp.com and YQL to deliver email

Howto:

  • Run an insert statement to YQL, storing your API Key with a use statement linking to this gist.
insert into yql.storage.admin (value) values ("
use 'https://raw.github.com/gist/5ceb77a28686513f16a7/cb17fcb095847f320426fb0fc5261d47cf62b0d8/postmark.xml' as postmark;
set api_key='YOUR KEY HERE' on postmark;
")
@ndarville
ndarville / business-models.md
Last active October 9, 2025 17:55
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
require 'redis'
# the heart of the message bus, it acts as 2 things
#
# 1. A channel multiplexer
# 2. Backlog storage per-multiplexed channel.
#
# ids are all sequencially increasing numbers starting at 0
#
class MessageBus::Message < Struct.new(:global_id, :message_id, :channel , :data)
@ghalimi
ghalimi / IRR.js
Created January 22, 2013 01:45
IRR Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
// Some algorithms have been ported from Apache OpenOffice:
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
@toolmantim
toolmantim / brunch_uglify.coffee
Last active December 13, 2015 18:58
Various configurations to ensure newlines are preserved in minified Javascript files. Fork it and add another language/framework/compressor combination!
# Brunch - http://brunch.io/
#
# Using uglify-js-brunch - https://github.com/brunch/uglify-js-brunch
#
# Use the following settings in your Brunch configuration file
exports.config =
plugins:
uglify:
output:
@toolmantim
toolmantim / application.html.erb
Created February 16, 2013 11:26
Pre-fetching your Rails asset hostname using dns-prefetch in your application's layout file
<!DOCTYPE html>
<html>
<head>
<title>App title</title>
<% if ActionController::Base.asset_host %>
<link rel="dns-prefetch" href="//<%= ActionController::Base.asset_host %>" />
<% end %>
# MAC manipulators
alias random_mac='sudo ifconfig en0 ether `openssl rand -hex 6 | sed "s/\(..\)/\1:/g; s/.$//"`'
alias restore_mac='sudo ifconfig en0 ether YOUR_ORIGINAL_MAC_ADDRESS_GOES_HERE'
@toolmantim
toolmantim / Gruntfile.js
Created May 12, 2013 00:18
If you're using SASS, Grunt and Bower you may wonder "How do I @import the CSS file from a bower component I just installed?" Well I'm afraid you're asking the wrong question—@import is really only designed to import SCSS files (for now). But there is hope! grunt-contrib-sass also supports concatenation, and to use it simply include the CSS file…
module.exports = function(grunt) {
grunt.initConfig({
// ...
sass: {
styles: {
files: {
'sass/styles.css': [
'components/normalize-css/normalize.css',