Skip to content

Instantly share code, notes, and snippets.

@jschoolcraft
jschoolcraft / spec_helper.rb
Created September 10, 2009 12:27
This is how I spec AuthLogic be9-acl9 using rspec
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
ENV["RAILS_ENV"] ||= 'test'
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
require 'spec/autorun'
require 'spec/rails'
require 'webrat'
require 'remarkable_rails'
require "email_spec/helpers"
require "email_spec/matchers"
@vvalgis
vvalgis / Capistrano tasks for starting unicorn.rb
Created May 7, 2010 08:13
Capistrano tasks for starting unicorn
set :rails_env, :production
set :unicorn_binary, "/usr/bin/unicorn"
set :unicorn_config, "#{current_path}/config/unicorn.rb"
set :unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid"
namespace :deploy do
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && #{try_sudo} #{unicorn_binary} -c #{unicorn_config} -E #{rails_env} -D"
end
task :stop, :roles => :app, :except => { :no_release => true } do
@mig
mig / init.el
Created January 18, 2011 21:00
Simple Emacs 24 configuration for Rails development
;; emacs configuration
(push "/usr/local/bin" exec-path)
(add-to-list 'load-path "~/.emacs.d")
(setq make-backup-files nil)
(setq auto-save-default nil)
(setq-default tab-width 2)
(setq-default indent-tabs-mode nil)
(setq inhibit-startup-message t)
@schleg
schleg / 01. Gemfile
Created May 26, 2011 17:26
Setup for Devise + Omniauth
gem 'pg'
group :development do
gem 'ruby-debug'
end
gem 'rake', '~> 0.8.7'
gem 'devise'
gem 'oa-oauth', :require => 'omniauth/oauth'
gem 'omniauth'
gem 'haml'
gem 'dynamic_form'
@fro
fro / gist:1683557
Created January 26, 2012 16:15
the_sortable_tree gem: erb version of partials
# _children.html.erb
<%= content_tag :ol, raw(children) %>
# _controls.html.erb
<%-
edit = link_to '', polymorphic_url(node, :action => :edit), :title => t('.edit_this'), :class => 'button edit'
if opts[:has_children]
delete = link_to('', url_for(node),
:title => t('.delete'),
:method => :delete,
@keikubo
keikubo / README.md
Created March 20, 2012 01:38
Nginx + Unicorn for Rails on Rackhub

Nginx + Unicorn for Rails on Rackhub

Description:

This script enables you to launch your Rails application in production environment (port:80) with Nginx and Unicorn.

Installation:

Please make sure that your Gemfile in your rails application includes unicorn.

@cmhobbs
cmhobbs / uploader.go
Created August 3, 2012 04:21
Handling multipart file uploads with goweb
package main
import (
"code.google.com/p/goweb/goweb"
"io/ioutil"
)
// dummy error struct for pretty json export
type ControllerError struct {
Error error
@gcaixeta
gcaixeta / gist:3498224
Created August 28, 2012 13:57
how to get the original picture-url from the linkedin gem api
c = LinkedIn::Client.new
c.authorize_from_access authentication.token, authentication.secret
c.search(fields: [{:people => [:picture_url]}]).people.all.first.try(:picture_url)
#or better
c.profile(:fields => ['picture-urls::(original)']).picture_urls.all.first
@tacone
tacone / gist:4534615
Last active December 11, 2015 02:58
How to manage structured data with Bootstrap typeahead.
/* bad indentation is NetBeans' fault, camelCase is Propel's fault */
var retrieveTeachers = function(query, process) {
// let them be json
var transformTeachers = function(teachers) {
return $.map(teachers, function(teacher) {
return {
id: teacher.Id,
FullName: (teacher.Name + ' ' + teacher.Surname),
// these functions allows Bootstrap typehead to use this item in places where it was expecting a string
toString: function() {
@tonyarnold
tonyarnold / mr-save-patterns.md
Last active October 21, 2023 00:55
Common save patterns for use with MagicalRecord

Common Save Patterns

Standard background save

Assuming that you don't care which NSManagedObjectContext is used, and you just want to make some changes and save them in the background, use the following method. 90% of the time, this is what you'll want.

NSManagedObjectSubclass *myObject = [NSManagedObjectSubclass MR_findFirst];

[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {