Skip to content

Instantly share code, notes, and snippets.

View phuphighter's full-sized avatar

Johnny Khai Nguyen phuphighter

View GitHub Profile
@jnunemaker
jnunemaker / authentication.rb
Created July 15, 2009 03:33
a starting point for authentication with mongomapper and rails
# include this in application controller
module Authentication
protected
# Inclusion hook to make #current_user and #signed_in?
# available as ActionView helper methods.
def self.included(base)
base.send :helper_method, :current_user, :signed_in?, :authorized? if base.respond_to? :helper_method
end
# Returns true or false if the user is signed in.
MongoMapper.connection = Mongo::Connection.new('localhost')
MongoMapper.database = 'solrtest'
class User
include MongoMapper::Document
has_many :lists
key :twit_id, Integer, :index => true, :unique => true
key :screen_name, String
key :name, String
key :location, String
# Hook our MongoMapper model into Solr
module MongoAdapter
class InstanceAdapter < Sunspot::Adapters::InstanceAdapter
def id
@instance.id
end
end
class DataAccessor < Sunspot::Adapters::DataAccessor
def load(id)
# Use at least one worker per core
worker_processes 16
# Help ensure your application will always spawn in the symlinked "current" directory that Capistrano sets up
working_directory "/var/www/apps/superfeedr.com/current"
# Listen on a Unix domain socket, use the default backlog size
listen "/tmp/unicorn.sock", :backlog => 1024
# Nuke workers after 30 seconds instead of 60 seconds (the default)
@mikhailov
mikhailov / installation.sh
Created November 23, 2010 15:18
nginx+passenger (real production config)
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
@0xjac
0xjac / private_fork.md
Last active November 4, 2024 10:29
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git