Discover gists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage is made of oranges and lemonade and lines starting with "##" | |
def usage | |
open(__FILE__).read.grep(/^## ?/).join.gsub(/^## ?/, '') | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=== configuring in projects/sample (/Users/wilson/code/cpp/vm/external_libs/llvm/projects/sample) | |
configure: running /bin/sh ./configure --prefix=/usr/local --cache-file=/dev/null --srcdir=. | |
configure: creating ./config.status | |
config.status: creating Makefile.common | |
config.status: executing setup commands | |
config.status: executing Makefile commands | |
/Users/wilson/code/cpp/vm/external_libs/llvm/autoconf/install-sh: ./Makefile does not exist. | |
config.status: executing lib/Makefile commands | |
/Users/wilson/code/cpp/vm/external_libs/llvm/autoconf/install-sh: ./lib/Makefile does not exist. | |
config.status: executing lib/sample/Makefile commands |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example of using rush to access files on multiple servers (as one collection) | |
nginx_confs = %w(www1 www2 www3).map { |n| Rush::Box.new(n)['/etc/nginx/nginx.conf'] } | |
nginx_confs.search(/access_log/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Use as TextMate command to convert | |
require 'iconv' | |
puts Iconv.iconv('utf-8', 'utf-16le', File.read(ENV['TM_FILEPATH'])).first |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc 'Clone a copy of all the required Merb repositories' | |
task 'merb:clone' do | |
if File.exists?("merb") then | |
puts("./merb already exists!") | |
exit | |
end | |
require("fileutils") | |
mkdir("merb") | |
cd("merb") | |
required_libraries.each do |r| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'resourceful' | |
require 'json' | |
gem 'dm-core', '>=0.9.3' | |
module DataMapper | |
module Adapters | |
class SsbeAdapter < AbstractAdapter | |
def initialize(name, uri_or_options) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'java' | |
require 'jsch-0.1.38.jar' | |
class SSH | |
include_package "com.jcraft.jsch" | |
def initialize(host, username, password) | |
@client = JSch.new | |
@session = @client.getSession(username, host, 22) | |
@session.setPassword(password) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public BookInfoJaxBImpl(BookInfo bookInfo) { | |
if(bookInfo==null) | |
throw new IllegalArgumentException("BookInfo passed into the constructor cannot be null."); | |
else | |
load(bookInfo); | |
} | |
private void load(BookInfo bookInfo) { | |
//load the values of BookInfo into this instance | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= popup_menu_view :action_menu do %> | |
<%= menu_item_view :outlet => true, :label => "Item A", :action => "MyApp.controller.itemAClicked" %> | |
<%= menu_item_view :outlet => true, :label => "Item B", :action => "MyApp.controller.itemBClicked" %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Securable | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
class Secured | |
def initialize(p, o) | |
@o = o | |
@o.class.methods_with_permissions(p) {|m| define_proxy_method(m)} | |
end | |