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-
@ches
ches / subject_prefixes.rb
Created September 7, 2011 07:27
Hack ActionMailer to always prefix email subjects. Gotta be a better way.
ActionMailer::Base.class_eval do
def mail_with_prefix(headers={}, &block)
unless Rails.env.production?
headers[:subject] = "[#{Rails.env.upcase}] " + (headers[:subject] || '')
end
mail_without_prefix(headers, &block)
end
alias_method_chain :mail, :prefix
end
@ches
ches / snippet.sh
Created April 4, 2009 02:04
Bash alias to open Github page for project and active branch in current working directory.
# Bash alias to open Github page for project in current working directory.
# Will use the current active branch if it exists remotely, or falls back to master.
alias github='br=$(git branch --contains HEAD | sed -En "s/^\* //p"); if ! git ls-remote . | grep -q -e "refs/remotes/.*/${br}"; then br="master"; fi; open $(git config -l | sed -En "s%remote.origin.url=git(@|://)(github.com)(:|/)(.+/.+).git%https://\2/\4/tree/${br}%p")'
@ches
ches / gist:630625
Created October 17, 2010 07:23
.irbrc for logging goodies like SQL/Mongo queries to $stdout if in Rails 3 console
# .irbrc to log goodies like SQL/Mongo queries to $stdout if in Rails 3 console
if defined?(Rails) && Rails.respond_to?(:logger)
require 'logger'
Rails.logger = Logger.new($stdout)
if defined?(Mongoid)
Mongoid.logger = Rails.logger
end
end
@ches
ches / EventService.scala
Last active December 15, 2016 08:09
spray implicit allowing spray DateTimes to be deserialized from parameters directives
import spray.http.DateTime
import spray.httpx.unmarshalling._
/*
* Implicit allowing spray DateTimes to be deserialized from parameters directives.
*
* See: http://spray.io/documentation/1.2.2/spray-httpx/unmarshalling/
*/
// type FromStringOptionDeserializer[T] = Deserializer[Option[String], T]
#!/usr/bin/env ruby
require 'netrc'
require 'octokit'
org_name = ARGV[0]
unless org_name
abort "Usage #{$0} org_name"
end
@ches
ches / snippet.js
Last active December 20, 2015 21:08
analytics.js load routine annotated
// Create a queue, but don't obliterate an existing one!
var analytics = analytics || [];
(function () {
// A list of all the methods we want to generate queueing stubs for.
var methods = [
'identify', 'track', 'trackLink', 'trackForm', 'trackClick', 'trackSubmit',
'page', 'pageview', 'ab', 'alias', 'ready', 'group'
];
@ches
ches / ansible.rb
Created August 2, 2013 02:24
Ansible Homebrew formula. Might not be accepted, so alas, Gist. See https://github.com/mxcl/homebrew/pull/21602
require 'formula'
class Ansible < Formula
homepage 'http://www.ansibleworks.com/'
url 'http://ansibleworks.com/releases/ansible-1.2.2.tar.gz'
sha1 '41672bf49ccdfcfe09a3614171a80e979304e071'
head 'https://github.com/ansible/ansible.git', :branch => 'devel'
depends_on :python => ['paramiko', 'jinja2']
@ches
ches / gist:4770693
Created February 12, 2013 15:34
Date#step, a C method, does not like ActiveSupport::Duration
[2] pry(main)> Date.today.step(Date.tomorrow, 30.minutes).each { |time| puts time }
2013-02-12
TypeError: expected numeric
from (pry):2:in `step'
[3] pry(main)> show-source 30.minutes
From: /Users/ches/.rvm/gems/ruby-1.9.3-p327@REDACTED/gems/activesupport-3.2.11/lib/active_support/core_ext/numeric/time.rb @ line 39:
Owner: Numeric
Visibility: public
Number of lines: 3
@ches
ches / Itembase-Sandbox.postman_environment
Last active November 18, 2015 18:27
Postman collection and environment (variables) for the Itembase API, initially imported from their Swagger spec. Import both into Postman and configure the environment with real values for your credentials. You'll need an OAuth access token for the user you're testing with, set as the `bearer_token` variable. Or alternatively, set up Postman's b…
{
"id": "d8ee1407-d7e2-60a3-f905-61896360d6e3",
"name": "Itembase – Sandbox",
"values": [
{
"key": "api_version",
"value": "v1",
"type": "text",
"name": "api_version",
"enabled": true