Skip to content

Instantly share code, notes, and snippets.

@duncansmart
duncansmart / progressive-ace.htm
Created March 28, 2013 23:29
Integrating ACE Editor in a progressive way
<textarea name="my-xml-editor" data-editor="xml" rows="15"></textarea>
...
<textarea name="my-markdown-editor" data-editor="markdown" rows="15"></textarea>
...
<script src="//d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js"></script>
<script>
// Hook up ACE editor to all textareas with data-editor attribute
$(function () {
@romansklenar
romansklenar / README.md
Last active July 11, 2023 23:12
Rails concerns

What is it?

Collection of concerns for your Rails application

Installation

Copy to your app/models/concerns directory

@madtrick
madtrick / gist:3917079
Created October 19, 2012 09:06
Warden strategy for Devise
module Devise
module Strategies
class RemoteAuthenticatable < Authenticatable
#
# For an example check : https://github.com/plataformatec/devise/blob/master/lib/devise/strategies/database_authenticatable.rb
#
# Method called by warden to authenticate a resource.
#
def authenticate!
#
@s-andringa
s-andringa / Locales.yml
Created September 19, 2012 10:09
Amsrb talk 18 sept - exceptions_app in Rails 3.2
# config/locales/en.yml
en:
exception:
show:
not_found:
title: "Not Found"
description: "The page you were looking for does not exists."
internal_server_error:
title: "Internal Server Error"
@troelskn
troelskn / app.rb
Last active August 12, 2021 17:25 — forked from dstrelau/app.rb
Gollum protected by HTTP Basic
require 'gollum/frontend/app'
require 'digest/sha1'
class App < Precious::App
User = Struct.new(:name, :email, :password_hash, :can_write)
before { authenticate! }
before /^\/(edit|create|delete|livepreview|revert)/ do authorize_write! ; end
helpers do
@jamiepenney
jamiepenney / bootstrap.rb
Created February 14, 2012 19:57
Form builder for Twitter Bootstrap v2 form elements
# This file goes in config/initializers
require 'bootstrap_form_builder'
# Make this the default Form Builder. You can delete this if you don't want form_for to use
# the bootstrap form builder by default
ActionView::Base.default_form_builder = BootstrapFormBuilder::FormBuilder
# Add in our FormHelper methods, so you can use bootstrap_form_for.
ActionView::Base.send :include, BootstrapFormBuilder::FormHelper
@jwo
jwo / registrations_controller.rb
Created September 30, 2011 23:11
API JSON authentication with Devise
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@gbbowers
gbbowers / railscast.bbcolor
Created July 26, 2011 01:01
Railscast bbcolor file I did a few years ago. Feel free to improve it and update for missing items, etc.
"Color:Background" = "rgb(11051,11051,11051)";
"Color:Background:Grep Replace Pattern" = "rgb(62915,62915,62915)";
"Color:Background:Grep Search Pattern" = "rgb(62915,62915,62915)";
"Color:CTagsIdentifier" = "rgb(48776,20456,15006)";
"Color:ColorAttributesSeparately" = 1;
"Color:Comment" = "rgb(26214,26214,26214)";
"Color:Comment:Markdown" = "rgb(43036,43036,43036)";
"Color:Foreground" = "rgb(59110,57825,56540)";
"Color:Foreground:Grep Replace Pattern" = "rgb(0,0,0)";
"Color:Foreground:Grep Search Pattern" = "rgb(0,0,0)";
@davejlong
davejlong / mysql client
Created February 1, 2011 15:06
How to setup the MySQL client and MySQLDump client on Mac OS x from MySQL Workbench
#MySQL Client
ln -s /Application/MySQL\ Workbench.app/Contents/Resources/mysql /usr/bin/mysql
#MySQL Dump
ln -s /Application/MySQL\ Workbench.app/Contents/Resources/mysqldump /usr/bin/mysqldump