Skip to content

Instantly share code, notes, and snippets.

@ches
ches / .ctags
Last active July 16, 2018 22:10 — forked from mfwarren/.ctags
my .ctags syntax file for Groovy language (exuberant-ctags)
--langdef=groovy
--langmap=groovy:.groovy
--regex-groovy=/^[ \t]*package[ \t]+([a-zA-Z0-9.-_]+)/\1/p,package/
--regex-groovy=/^[ \t]*(private|public)?[ \t]*(abstract|final|static)?[ \t]*class[ \t]+([A-Za-z0-9_]+)/\3/c,class/
--regex-groovy=/^[ \t]*(private|public)?[ \t]*interface[ \t]+([A-Za-z0-9_]+)/\2/i,interface/
--regex-groovy=/^[ \t]*(private|public)?[ \t]*trait[ \t]+([A-Za-z0-9_]+)/\2/t,trait/
--regex-groovy=/^[ \t]*(private|public)?[ \t]*enum[ \t]+([A-Za-z0-9_]+)/\2/e,enum/
--regex-groovy=/^[ \t]*[(abstract|final|static) \t]*((def|void|byte|int|short|long|float|double|boolean|char|[A-Z][a-zA-Z0-9_]*)[ \t]+)?([a-zA-Z0-9_]+\(.*\))[ \t]+/~\3/m,package method/
--regex-groovy=/^[ \t]*public[ \t]+[(abstract|final|static) \t]*((def|void|byte|int|short|long|float|double|boolean|char|[A-Z][a-zA-Z0-9_]*)[ \t]+)?([a-zA-Z0-9_]+\(.*\))[ \t]+/+\3/m,public method/
--regex-groovy=/^[ \t]*protected[ \t]+[(abstract|final|static) \t]*((def|void|byte|int|short|long|float|double|boolean|char|[A-Z][a-zA-Z0-9_]*)[ \t]+)?([a-
#!/usr/bin/env ruby
require 'netrc'
require 'octokit'
org_name = ARGV[0]
unless org_name
abort "Usage #{$0} org_name"
end
@ches
ches / embedded_callbacks.rb
Created December 30, 2010 13:22 — forked from zerobearing2/embedded_callbacks.rb
bubble down callbacks to embedded associations with mongoid
# encoding: utf-8
module Mongoid #:nodoc:
module Associations #:nodoc:
module EmbeddedCallbacks
# bubble callbacks to embedded associations
def run_callbacks(kind, *args, &block)
# now bubble callbacks down
self.associations.each_pair do |name, meta|
if meta.association == Mongoid::Associations::EmbedsMany
@ches
ches / gist:718234
Created November 27, 2010 20:20 — forked from jpemberthy/gist:349242
Very simple taggable behavior for Mongoid
# Basic tagging system for mongoid documents.
# jpemberthy 2010
#
# class User
# include Mongoid::Document
# include Mongoid::Document::Taggable
# end
#
# @user = User.new(:name => "Bobby")
# @user.tag_list = "awesome, slick, hefty"
@ches
ches / gist:243611
Created November 26, 2009 19:09 — forked from lukesutton/gist:107966
basic example of Warden authentication with Sinatra
Warden::Manager.serialize_into_session{|user| user.id }
Warden::Manager.serialize_from_session{|id| User.get(id) }
Warden::Manager.before_failure do |env,opts|
# Sinatra is very sensitive to the request method
# since authentication could fail on any type of method, we need
# to set it for the failure app so it is routed to the correct block
env['REQUEST_METHOD'] = "POST"
end
@ches
ches / environment.rb
Last active September 3, 2015 19:45 — forked from webmat/environment.rb
A little `config.github_gem` helper for back in the day when Rails used `config.gem`-style dependencies.
# Neater Github gem dependencies for Rails
module GithubGem
def github_gem(gem_name, opts={})
lib_name = gem_name.split('-', 2)[1]
self.gem gem_name, {:lib => lib_name, :source => 'http://gems.github.com'}.merge(opts)
end
end
Rails::Initializer.run do |config|
@ches
ches / lighter.rb
Last active August 30, 2015 11:14 — forked from macournoyer/lighter.rb
A tiny little command-line Campfire client using the Tinder gem.
# Lighter -- Campfire from the command line
# usage: ruby lighter.rb subdomain "Main Room" macournoyer@gmail
require "rubygems"
require "tinder"
require "readline"
require "highline/import"
class Lighter
def initialize(room)
@room = room