Skip to content

Instantly share code, notes, and snippets.

#models/my_thing.rb
class MyThing < ActiveRecord::Base
belongs_to :user
acts_as_activity :user
end
#views/activities/_unhandled_item.html.haml
- case activity.item_type
- when 'MyThing'
="created a MyThing: #{link_to(activity.item.name, user_my_thing_path(activity.item.user, activity.item))}"
# Lets you define relations between ActiveRecord and Mongo objects
module MongoRelations
module InstanceMethods
# get an object representing the MongoMapper equivalent of this object
# for the purpose of access relations on the object
fattr(:mongo_obj) do
res = klass.mongo_class.new
my_id = id
res.class_eval do
#!/bin/bash
# Git status in git projects....
# in your .bashrc file:
# if [ -f ~/.prompt ]; then
# . ~/.prompt
# fi
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
@ryanb
ryanb / README.md
Created May 15, 2011 16:24 — forked from copiousfreetime/my-gh-issues.rb
My Github Issues

First install the required gems:

gem install octokit awesomeprint rainbow

Then run it to extract all of your open GitHub issues into files (with comments).

ruby my-gh-issues.rb
@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@grosser
grosser / resque_web.rb
Created September 13, 2011 15:08 — forked from skippy/resque_web.rb
Mountable resque-web for rails 3+ apps
# https://gist.github.com/1214052
require 'sinatra/base'
class ResqueWeb < Sinatra::Base
require 'resque/server'
use Rack::ShowExceptions
if CFG[:user].present? and CFG[:password].present?
Resque::Server.use Rack::Auth::Basic do |user, password|
user == CFG[:user] && password == CFG[:password]
@darwinrc
darwinrc / warden_lotus.md
Last active August 29, 2015 14:24
Warden implementation in Lotus

apps/web/application.rb

controller.prepare do
        use YourApp::WardenImpl::WebManager
        include YourApp::WardenImpl::WardenHelper
        authentication_via :web_strategy
        auth_failure_to "/login"
        before :authenticate!    # run an authentication before callback
      end
@mikeslattery
mikeslattery / runimage.sh
Last active January 13, 2022 16:51
Run containers as if they are locally installed tools
#!/bin/bash
# Run containers as if they are locally installed tools.
# This is useful for images such as "python" or "maven".
# Edit the "image" variable and place in your ~/bin directory.
# For "Docker Desktop for Windows" under these environments:
# * WSL: if /c is mounted to C: and run from a dir under /c, but /tmp and $HOME volumes should be removed.
# * Msys/GitBash: but /tmp volume should be removed.
# * Cygwin: Will not work as-is due to path differences.