Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
#gem 'dm-core','= 0.10.1'
require 'dm-core'
require 'dm-validations'
DataMapper.setup :default, 'sqlite3::memory:'
class Parent
include DataMapper::Resource
property :id,Serial
if RUBY_VERSION < "1.9.0"
class String
def force_encoding(encoding)
return self
end
end
module Rack
class GoogleAnalytics
TRACKING_CODE = <<-EOCODE
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("{{ID}}");
#!/bin/sh
# Author: Carl Youngblood, 2010
# Based on http://www.novell.com/coolsolutions/feature/15380.html
### BEGIN INIT INFO
# Provides: bluepill
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'benchmark'
=> true
irb(main):003:0> Benchmark.bmbm do |x|
irb(main):004:1* x.report('Gem.clear_paths') { Gem.clear_paths }
irb(main):005:1> x.report("Gem.find_files('rubygems_plugin')") do
irb(main):006:2* Gem.clear_paths
irb(main):007:2> Gem.find_files 'rubygems_plugin'
require 'rubygems'
require 'yaml'
require 'json'
require 'rest_client'
@config = YAML.load_file 'twitter_login.yml'
#twitter_login.yml looks like
#:user: username
#:password: password
@twitter = RestClient::Resource.new('http://twitter.com',@config)
#-------------------------------------------------
# I hope I don't have to use cvs w/ capistrano again, but if I do
# this makes capistrano always checkout head of the cvs repo even
# if it is not in the same subdirectory as the code it checks out.
# ensure capistrano just pulls HEAD rather than
# trying to figure out the latest checkout.
require 'capistrano/recipes/deploy/scm'
require 'capistrano/recipes/deploy/scm/base'
require 'capistrano/recipes/deploy/scm/cvs'
class Capistrano::Deploy::SCM::Cvs < ::Capistrano::Deploy::SCM::Base
class Sprinkle::Installers::JRubyGem < Sprinkle::Installers::Gem
protected
def install_commands
"jruby -S #{super}"
end
end
module Sprinkle
module Verifiers
# = JRuby Verifiers

When making a new gem, should you use underscores or dashes in the name?

Well, there are ~12,000 gems(rubygems.org/ says 12,442) $ gem list -r | wc -l 12202 Of which ~6,000 have underscores or dashes in their name $ gem list -r | grep -e '-|_' -c 6022 dash has more than than underscore

require 'rubygems'
require 'json/pure'
require 'httparty'
module FB
class BaseClient
include HTTParty
end