This script enables you to launch your Rails application in production environment (port:80) with Nginx and Unicorn.
Please make sure that your Gemfile in your rails application includes unicorn.
# 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" |
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 |
;; 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) |
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' |
# _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, |
package main | |
import ( | |
"code.google.com/p/goweb/goweb" | |
"io/ioutil" | |
) | |
// dummy error struct for pretty json export | |
type ControllerError struct { | |
Error error |
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 |
/* 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() { |
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) {