Skip to content

Instantly share code, notes, and snippets.

View epogue's full-sized avatar
Caffeinated

Elliott Pogue epogue

Caffeinated
View GitHub Profile
@rafaelss
rafaelss / Gemfile
Created May 20, 2010 22:18 — forked from rmanalan/.gems
rack static site
source "http://rubygems.org"
gem 'rack-contrib', :git => 'git://github.com/rack/rack-contrib.git'
gem 'rack-rewrite'
@epogue
epogue / app-template.rb
Created March 22, 2012 17:55
Rails 3 app template
require 'open-uri'
run "rm public/index.html"
run "rm .gitignore"
rake "db:migrate"
file ".gitignore", <<-CODE
#{URI.parse("https://raw.github.com/github/gitignore/master/Rails.gitignore").read}
*.sublime-workspace
CODE
@elliotjaystocks
elliotjaystocks / Art direction in Harmony
Created May 3, 2012 14:33
Art direct your blog posts in Harmony by inserting this loop into the <head> and injecting any extra CSS or JSS you might need by creating a field in your post template called 'injected_code'.
{% if item.root? %}
{{ 'blog' | item_from_path | assign_to: 'blog' }}
{% for post in blog.recent_posts.1 %}
<!-- Injected code from the latest blog post -->
{{ post.data.injected_code }}
{% endfor %}
@rlivsey
rlivsey / modal.js.coffee
Created May 24, 2012 09:56
Ember.js modal
MB.ModalHeaderView = Ember.View.extend({
classNames: ["modal-header"]
contentBinding: "parentView.content"
titleBinding: "parentView.title"
defaultTemplate: Ember.Handlebars.compile("""
<a href="#" {{action close target="view.parentView"}} class="close">x</a>
<h3>{{view.title}}</h3>
""")
})
@orderedlist
orderedlist / labels.scss
Created July 9, 2012 18:42
Simple Label Colors with SCSS
$start-color:#2B73A2;
$number: 12;
@for $i from 1 through $number {
.label-#{$i} {
color:adjust_hue($start-color, ($i - 1) * (360 / $number));
}
}
@tmcw
tmcw / index.html
Created October 17, 2012 13:21
MapBox.js + Retina
<!DOCTYPE html>
<html>
<head>
<script src='http://api.tiles.mapbox.com/mapbox.js/v0.6.6/mapbox.js'></script>
<link href='http://api.tiles.mapbox.com/mapbox.js/v0.6.6/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
@balazsbohonyi
balazsbohonyi / businessDays.js
Created August 8, 2013 18:55
Adding/Subtracting Business Days in Javascript (extends the native Date Javascript object)
Number.prototype.mod = function(n) {
return ((this%n)+n)%n;
}
// support for adding/subtracting business days for Javascript dates
Date.prototype.addBusinessDays = function(days) {
days = parseInt(days);
var wks = Math.floor(days/5);
var dys = days.mod(5);
var dy = this.getDay();
@fversnel
fversnel / SmartSortable.js
Created December 30, 2014 11:36
React SmartSortable
var cloneWithProps = React.addons.cloneWithProps;
var SmartSortable = React.createClass({
getDefaultProps: function() {
return {component: "ul", childComponent: "li"};
},
render: function() {
var props = jQuery.extend({}, this.props);
@petehunt
petehunt / React sortable
Created December 9, 2013 22:30
Here's an example of React + jQuery UI sortable. The key thing to note is that we have the render() method do absolutely nothing and use componentDidUpdate() + React.renderComponent() to proxy updates through to the children. This lets us manage the DOM manually but still be able to use all the React goodies you know and love.
<html>
<head>
<title>Test</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://fb.me/react-0.5.1.js"></script>
<script src="http://fb.me/JSXTransformer-0.5.1.js"></script>
</head>
@attenzione
attenzione / boolean_value.rb
Last active June 11, 2020 08:22
Ruby: casting to boolean value
class BooleanValue
# https://github.com/rails/rails/blob/master/activemodel/lib/active_model/type/boolean.rb
FALSE_VALUES = [
false, 0,
"0", :"0",
"f", :f,
"F", :F,
"false", :false,
"FALSE", :FALSE,
"off", :off,