Skip to content

Instantly share code, notes, and snippets.

@remino
remino / Gemfile
Created January 9, 2014 18:01
kramdown-rails: Use Kramdown (Markdown) in Rails 4
# Gemfile
gem 'kramdown'
@clarkdave
clarkdave / chef-insert-line-if-no-match.rb
Created June 13, 2013 11:12
[CHEF] Insert a line in a file if it doesn't already exist
line = '127.0.0.1 gateway.internal gateway'
file = Chef::Util::FileEdit.new('/etc/hosts')
file.insert_line_if_no_match(/#{line}/, line)
file.write_file
@dhm116
dhm116 / ie.shims.js
Created February 10, 2012 15:14
IE7/8 Javascript method shims
'use strict';
// Add ECMA262-5 method binding if not supported natively
//
if (!('bind' in Function.prototype)) {
Function.prototype.bind= function(owner) {
var that= this;
if (arguments.length<=1) {
return function() {
return that.apply(owner, arguments);
@carolineschnapp
carolineschnapp / gist:1904659
Created February 24, 2012 23:46
Client-side sorting for collections
<div id="reorder-drop-down" style="margin-top:10px; background-color:#e8e8e8; padding:10px; overflow:hidden">
<label style="display:inline; color: #777; font-size: 12px; font-weight: normal">Reorder this collection</label>
<select id="reorder-options" name="reorder-options">
<option value="alpha-asc"{% if collection.handle contains 'alpha-asc' %} selected="selected"{% endif %}>Alphabetically: A-Z</option>
<option value="alpha-desc"{% if collection.handle contains 'alpha-desc' %} selected="selected"{% endif %}>Alphabetically: Z-A</option>
<option value="best-selling"{% if collection.handle contains 'best-selling' %} selected="selected"{% endif %}>By Best Selling</option>
<option value="created-desc"{% if collection.handle contains 'created-desc' %} selected="selected"{% endif %}>By Created Date: Newest to Oldest</option>
<option value="created-asc"{% if collection.handle contains 'created-asc' %} selected="selected"{% endif %}>By Created Date: Oldest to Newest</option>
<optio
@westonruter
westonruter / gist:5475349
Last active August 12, 2021 07:00 — forked from markjaquith/gist:2653957
WordPress Fragment Caching convenience wrapper
<?php
/*
Usage:
cache_fragment_output( 'unique-key', 3600, function () {
functions_that_do_stuff_live();
these_should_echo();
});
*/
function cache_fragment_output( $key, $ttl, $function ) {
@coolaj86
coolaj86 / README.md
Last active September 6, 2021 20:20
Fastest uuid generator for node.js

Now published as @root/uuid

This is started out as a curiosity, pasted as a gist but now, years later, I've come back to it because there are too many of these uuid modules out there and they're too complicated.

This, however, is easy to read and understand (for me, at least). Even its tests are dependncy and build-step free.

node-uuid vs crazy-uuid vs fast-uuid

@wlangstroth
wlangstroth / deploy.rb
Last active September 11, 2021 13:15
Capistrano + Nginx + Unicorn + Sinatra on Ubuntu
require 'bundler/capistrano'
set :application, "net"
set :repository, "git@githost.com:net.git"
set :scm, :git
set :default_environment, {
'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH"
}
@ggl
ggl / htpasswd.pl
Last active October 18, 2021 21:51
htpasswd in perl, no need to install apache tools
#!/usr/bin/env perl
#
# htpasswd.pl
#
# Copyright (c) 2013, Gelu Lupas <gelu@devnull.ro>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
@twe4ked
twe4ked / input.scss
Created December 5, 2011 06:27
FREE! Sass (SCSS) mixin for including retina images (useful when developing for iOS).
@mixin background-image-retina($file, $type, $width, $height) {
background-image: url($file + '.' + $type);
@media (-webkit-min-device-pixel-ratio: 2), (-moz-min-device-pixel-ratio: 2) {
& {
background-image: url($file + '@2x.' + $type);
-webkit-background-size: $width $height;
}
}
}
@coolaj86
coolaj86 / json-to-yaml-litmus-test.md
Last active March 14, 2022 04:32
"Can you write code?" litmus test.

The Developer Litmus Test

I used to think that fizzbuzz was a stupid way to test if someone is a developer.

Screen Shot 2022-01-24 at 3 06 33 AM

Now I think that it's a good litmus test.

However, I think I've found a better one...