Skip to content

Instantly share code, notes, and snippets.

@mysteriouspants
mysteriouspants / 000-README.md
Created November 7, 2012 17:08
HAML vs ERB vs SLIM on JRuby 1.7.0 Showdown!

Section of Introductions

This was all done on a rather nice iMac:

  • Intel Core i7 Sandy-Bridge 4-core chip
  • 12 GB of RAM
  • 1TB Spinning-disk hard drive
  • java version 1.6.0_37, build 1.6.0_37-b06-434-11M3909 "HotSpot" 64-bit VM "mixed mode" (whatever that's supposed to mean)
  • The excellent pre-chewed testing app at
@xerardoo
xerardoo / Mexico
Created November 3, 2014 20:29
Ciudades y Estados de Mexico
{
"mexico":{
"estado":[
{
"id":1,
"iso":"MX-AGS",
"capital":"Aguascalientes",
"nombre":"AGUASCALIENTES",
"municipios":{
"municipio":[
@clifff
clifff / C-large-1.in
Created April 21, 2013 16:33
Google Code Jam - Fair and Square Large Input 1
10001
1002001 1004006004002
14541 102030301
44944 1022325232202
1000001999901 1211124711121
2617287827163 4000008000005
1 101
1022325232201 1213326733121
44943 12345654321
42874 103045301
@tarcieri
tarcieri / gist:5483325
Last active December 16, 2015 19:10
The DHH Drinking Game

The @dhh Drinking Game

Take a drink whenever @dhh:

  1. Drops the f-bomb (or says "shit")
  2. Makes fun of Java (or Struts, Hibernate, etc)
  3. Mentions "frameworks should be extractions, not inventions"
  4. Mentions "constraints are liberating"
  5. Defends TurboLinks or the asset pipeline
  6. Mentions Basecamp
@eljojo
eljojo / humanize_seconds.rb
Created June 24, 2013 14:15
How to generate a human readable time range using ruby on rails
# modification of http://stackoverflow.com/questions/4136248/how-to-generate-a-human-readable-time-range-using-ruby-on-rails
def humanize_seconds secs, precision = 2
return unless secs
units = [[60, :second], [60, :minute], [24, :hour], [1000, :day]]
diffs = units.map do |count, name|
next if units.find_index([count, name]) > precision
if secs > 0
secs, n = secs.divmod(count)
pluralize(n.to_i, name.to_s) if n > 0
end
@xypaul
xypaul / tinymce-ember.js
Created May 14, 2014 06:32
TinyMCE 4 Ember Component
App.TinymceEditorComponent = Ember.Component.extend({
// Warning!!! only use tinyMCE not tinymce !!!
editor: null,
data: {},
watchData: true,
didInsertElement: function(){
var _this = this;
// The magic config - http://www.tinymce.com/wiki.php/Configuration
var config = {};

Integrating TinyMCE in an ember-cli app

TinyMCE is a javascript WYSIWYG editor that is highly configurable and has a ton of features and plugins. It integrates with jQuery and, with a bit of work, it can be integrated in your ember-cli app.

Step 1: Install TinyMCE:

bower install --save tinymce

Step 2: Import the required files into your app via broccoli. In order to do that you will need a plugin called broccoli-static-compiler:

@jjb
jjb / gist:950975
Created May 1, 2011 23:16
Using whenever with capistrano and bundler in multiple environments
We couldn’t find that file to show.
@matiasleidemer
matiasleidemer / paginate.rb
Last active January 8, 2018 14:34 — forked from be9/paginate.rb
kaminari + JSON API pagination helper
def paginate(scope, default_per_page = 20)
collection = scope.page(params[:page]).per((params[:per_page] || default_per_page).to_i)
current, total, per_page = collection.current_page, collection.total_pages, collection.limit_value
render json: [{
pagination: {
current: current,
previous: (current > 1 ? (current - 1) : nil),
next: (current == total ? nil : (current + 1)),
@kinopyo
kinopyo / sinatra_render_html.rb
Created October 21, 2011 07:13
How to render static HTML files in Sinatra.
require 'sinatra'
get '/' do
File.read(File.join('public', 'index.html'))
# or
# send_file File.join(settings.public, 'index.html')
end