Skip to content

Instantly share code, notes, and snippets.

View craigcoles's full-sized avatar
:shipit:
Shippers gonna ship

Craig Coles craigcoles

:shipit:
Shippers gonna ship
View GitHub Profile
@jordelver
jordelver / gist:8863630
Created February 7, 2014 14:33
Middleman - Disable directory indexes for individual page

Middleman - Disable directory indexes for individual page

Add directory_index: false to the frontmatter of your page

--
directory_index: false
--
// javascripts/components/foo.js
export default function() {
console.log('foo');
}
@hshoff
hshoff / stars.scss
Created October 14, 2011 13:53
Airbnb - Star Rating SASS
// stars.scss
// compiles to stars.css
$starWidth: 44px;
$starOffset: 0 -43px;
$numStars: 5;
$steps: 2;
$total: $numStars * $steps;
@mixin filled($n: 0) {
@stephenway
stephenway / color-hacker.scss
Created April 2, 2012 19:58
Sass color-hacker
@function scale-to-adjust($start, $change) {
@if($change > 0) {
$end: $start + $change;
@return percentage(($end - $start)/(100 - $start));
} @else {
@return percentage($change / $start);
}
}
@function scale-key($key, $color) {
<article>
<h2>Sections</h2>
<p>The main page header of this guide is an <code>h1</code> element. Any header elements may include links, as depicted in the example.</p>
<p>The secondary header above is an <code>h2</code> element, which may be used for any form of important page-level header. More than one may be used per page. Consider using an <code>h2</code> unless you need a header level of less importance, or as a sub-header to an existing <code>h2</code> element.</p>
<h3>Third-Level Header</h3>
<p>The header above is an <code>h3</code> element, which may be used for any form of page-level header which falls below the <code>h2</code> header in a document hierarchy.</p>
<h4>Fourth-Level Header</h4>
<p>The header above is an <code>h4</code> element, which may be used for any form of page-level header which falls below the <code>h3</code> header in a document hierarchy.</p>
@daneden
daneden / dabblet.css
Created October 10, 2012 09:26
CSS Photo Album
/* CSS Photo Album */
/* Rebound of this shot by @daryl: http://drbl.in/fwwM */
* {
margin: 0;
padding: 0;
position: relative;
box-sizing: border-box;
}
@daviddarnes
daviddarnes / parallax-scrolling.js
Created October 20, 2015 08:48
Parallax scrolling with JavaScript
// Parallax header content
window.onscroll = function emParallax() {
if(window.pageYOffset>1) {
document.getElementById("parallax").style["-webkit-transform"] = "translateY("+(window.pageYOffset/3)+"px)";
} else {
document.getElementById("parallax").style["-webkit-transform"] = "translateY(0px)";
}
}
@benjaminreid
benjaminreid / breaking_bad.rb
Last active December 16, 2015 02:28
A Git hook (commit-msg) to append a Breaking Bad quote to end of your commit messages, obviously.
#!/usr/bin/env ruby
message_file = ARGV[0]
message = File.read(message_file)
def range_rand(min,max)
min + rand(max-min)
end
bads = [
"Yeah, bitch! Magnets!",
@sgb-io
sgb-io / .bash_profile
Created July 25, 2013 23:51
Peep Show essentials for terminal.
# Welcome message
open_green_escape="\033[36m"
open_yellow_escape="\033[31m"
close_escape="\033[0m"
# Some of my fave peep show quotes.
funny_quotes=(
'What if I lose it? Im not gonna do a poo am I, Jez?'
'For the worst thing that could possibly happen, this is actually going extremely well.'
'Is this a terrible idea? It cant be. Its in a film. They wouldnt put a terrible idea in a film, theyd get sued.'
@benhowdle89
benhowdle89 / app.js
Created November 1, 2016 10:51
Redirect non-HTTPS -> HTTPS in your Express app
const requireHTTPS = (req, res, next) => {
if(req.headers['x-forwarded-proto'] !== 'https' && process.env.NODE_ENV === 'production') {
var secureUrl = "https://" + req.headers['host'] + req.url
res.writeHead(301, { "Location": secureUrl })
res.end()
}
next()
}
app.use(requireHTTPS)