Skip to content

Instantly share code, notes, and snippets.

ie = Dir.glob('/Users/scmac/Desktop/ChrisWeeg/ruby/identical/Enhanced/*')
ir = Dir.glob('/Users/scmac/Desktop/ChrisWeeg/ruby/identical/Raw/*')
junk = "abcdefghijklmnopqrstuvwxyzABCDEFGHILKLMNOPQRSTUVWXYZ"
ie.each {|x| x.delete! junk}
ir.each {|x| x.delete! junk}
ie.each {|x| x.delete! "/"}
ir.each {|x| x.delete! "/"}
#!/usr/bin/env jython
# This is a Jython Servlet wrapper for FITS <http://code.google.com/p/fits/>
#
# INSTALL:
# Set the FITS_HOME variable to the location of the FITS package
#
# Some JARs may need to be moved into the endorsed folder (./common/endorsed)
# like jaxon, jdom, saxon, saxpath, and xerces.
#
@anarchivist
anarchivist / bookmarks_controller.rb
Created January 29, 2011 18:01
Blacklight workaround BookmarksController for Postgres
require_dependency( 'vendor/plugins/blacklight/app/controllers/bookmarks_controller.rb')
class BookmarksController < ApplicationController
def collection
user_id = current_user ? current_user.id : nil
assocations = nil
conditions = ['user_id = ?', user_id]
if params[:a] == 'find' && ! params[:q].blank?
q = "%#{params[:q]}%"

I have a Rails 3 application; we can consider it a blog system. All content is stored in Nodes. I am using a specifically tailored route to allow Nodes to have clean URLs.

= form_for [:admin, @node] do                        # => generated URL is /admin/nodes or /admin/nodes/4d1a44571d41c821eb000006
= link_to 'all nodes', nodes_path                    # => generated URL is /
= link_to @node.title, node_path(@node.to_path)      # => generated URL is /about or /about/people or /4d1a44571d41c821eb000006
= link_to 'all nodes (admin view)', admin_nodes_path # => generated URL is /admin/nodes
= link_to 'add', new_admin_node_path                 # => generated URL is /admin/nodes/new
= link_to 'edit', edit_admin_node(@node)             # => generated URL is /admin/nodes/4d1a44571d41c821eb000006/edit
= link_to 'delete', [:admin, @node], :confirm => 'Are you sure?', :method => :delete

=> generated URL is /admin/nodes/4d1a44571d41c8

## /config/initializers/dynamic_job.rb
require 'heroku'
# base class for all jobs that you wish to automatically scale and go down in Heroku
class DynamicJob
#set a cap on maximum number of users ever - just in case.
MAX_CONCURRENT_WORKERS = 100
def initialize