Skip to content

Instantly share code, notes, and snippets.

View iansheridan's full-sized avatar

Ian Sheridan iansheridan

View GitHub Profile
# ===========================================================
# as you can see this is the exact copy of What is is the
# Passnger user guide
require 'rubygems'
require 'merb-core'
Merb::Config.setup(
:merb_root => ::File.expand_path(::File.dirname(__FILE__)),
:environment => ENV['RACK_ENV']
NameVirtualHost xxx.example.com
<VirtualHost xxx.example.com>
ServerAdmin name@example.com
ServerName xxx.example.com
DocumentRoot /u/apps/example/current/public
RailsBaseURI /app1
RailsBaseURI /app2
RackBaseURI /sinatra1
# Optional more complicated strat for the database.yml
require 'ftools'
namespace :config do
task :build do
File.mkdir_p temp_config_dir
# this is the place to hook after when creating a config file
end
task :update do
# upload contents of temp_config_dir to #{release_path}/config
$('#image-select-all').click(function() {
$('#image-grid .image').each(function(){
$(this).trigger('selected');
});
console.log("clicked > image-select-all to trigger > click.selected")
console.log($('#image-grid .image'))
});
$('#image-select-none').click(function() {
$('#image-grid .image').each(function(){
$(this).trigger('unselected');
# output and array sorted
def ian_sort(a)
c = false # change
a[0...-1].each_with_index { |v, i|
if v > a[i+1] then
a[i], a[i+1] = a[i+1], a[i]
c = true
end
}
ian_sort(a) if c
class Keygroup
include DataMapper::Resource
has n, :keywords, :through => Resource
has n, :categories, :through => Resource
property :id, Serial
property :name, String
property :description, Text
property :created_at, DateTime
@iansheridan
iansheridan / role.rb
Created November 20, 2010 22:53
a user class with dynamic 'has role' methods
class Role
include DataMapper::Resource
has n, :users, :through => Resource
property :id, Serial
property :name, String
property :short_name, String
property :description, Text
property :created_at, DateTime
property :updated_at, DateTime
default_scope(:default).update(:order => [:id]) # set default order
@iansheridan
iansheridan / git-cheat-sheet.md
Created March 15, 2011 14:25
A cheat sheet for GIT

Setup

git clone <repo>

clone the repository specified by ; this is similar to "checkout" in some other version control systems such as Subversion and CVS

Add colors to your ~/.gitconfig file:

@iansheridan
iansheridan / article-result.html
Created May 16, 2011 20:28
Example of a way to move a DIV to anywhere in the DOM with jQuery
<div id="article">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla faucibus semper diam quis suscipit. Sed at eros et est scelerisque hendrerit. Nam sagittis tortor vel orci convallis vel tempor nisl suscipit. Fusce at mauris risus, a adipiscing mauris. Nunc nunc erat, luctus id suscipit sed, lacinia sed ligula. In imperdiet, metus nec mattis molestie, odio dui sollicitudin augue, at blandit velit enim vitae nisl. Maecenas id enim eu nunc luctus congue. Sed tempus tellus quis quam ultrices et aliquet arcu porta. Vivamus pretium ipsum sit amet nisl pulvinar consequat. Fusce elementum, lectus in lacinia ultrices, ante tellus euismod urna, gravida cursus augue est id lacus.
</p>
<p>
Quisque vestibulum pellentesque eros, a pharetra nibh elementum vestibulum. Mauris fringilla tortor sed dui egestas dictum. Sed ac velit eu sapien dapibus mollis. Vestibulum volutpat nunc at enim ultrices egestas congue purus gravida. In sed elit sed erat auctor sagittis id nec tellus. Proin iaculis lobortis lac
<%= javascript_include_tag 'jquery' %>
<script>
jQuery.noconflict();
</script>
<%= javascript_include_tag :defaults %>