This file contains hidden or 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
import scala.util.continuations._ | |
import java.io.File | |
object Test2 | |
{ | |
sealed trait Iteration[+T] | |
case class Yield[+T](result: T, next: () => Iteration[T]) | |
extends Iteration[T] |
This file contains hidden or 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/python | |
# Based on diigo.py, which is copyright (c) 2008 Kliakhandler Kosta | |
# <[email protected]> and released under the GNU Public License. | |
# | |
# This hacked version is also released under the GNU Public License. | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. |
This file contains hidden or 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 'etc' | |
def as_user(user, &block) | |
# Find the user in the password database. | |
u = (user.is_a? Integer) ? Etc.getpwuid(user) : Etc.getpwnam(user) | |
# Fork the child process. Process.fork will run a given block of code | |
# in the child process. | |
Process.fork do | |
# We're in the child. Set the process's user ID. |
This file contains hidden or 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
puts("Caller PID = #{Process.pid}") | |
puts("Caller UID = #{Process.uid}") | |
as_user "bmc" do |user| | |
puts("In child process. User=#{user}, PID=#{Process.pid}, UID=#{Process.uid}") | |
end |
This file contains hidden or 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
class CallableHash < Hash | |
def initialize(h) | |
h.each do |k, v| | |
self[k] = v | |
end | |
@@methods = {} | |
end | |
def respond_to?(sym) | |
true |
This file contains hidden or 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
Rails::Initializer.run do |config| | |
# The following globals define the default SMTP configuration. To | |
# change the configuration in your environment, simply set these globals | |
# in your environment configuration (config/*.rb) file. | |
$smtp_address = 'smtpserver.example.com' | |
$smtp_domain = 'example.com' | |
$smtp_auth_type = :plain | |
$smtp_user = '[email protected]' | |
$smtp_password = 'secret' |
This file contains hidden or 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
# Override the SMTP settings, for local testing. | |
$smtp_address = 'mail.inside.ardentex.com' | |
$smtp_domain = 'inside.ardentex.com' | |
$smtp_auth_type = nil | |
$smtp_user = nil | |
$smtp_password = nil | |
$smtp_port = 25 |
This file contains hidden or 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 | |
# | |
# Fix an EPUB document generated by Pandoc to have a title page. | |
# | |
# Usage: fixepub epub_in epub_out cover_png | |
# | |
# Only supports PNG at the moment, but easily hacked to support JPEG. | |
# | |
# Requires these gems: | |
# |
This file contains hidden or 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
# Test of Goo.gl Python front-end available at | |
# http://code.google.com/p/python-googl/source/checkout | |
# | |
# Some kind of JSON parser must be installed. 'simplejson' works fine. | |
# | |
# See | |
# http://code.google.com/apis/urlshortener/v1/getting_started.html#shorten | |
# for Goo.gl API info. | |
import googl |
This file contains hidden or 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
# Test of Goo.gl Ruby gem. Install via: | |
# | |
# $ gem install googl | |
# | |
# See | |
# http://code.google.com/apis/urlshortener/v1/getting_started.html#shorten | |
# for Goo.gl API info. | |
require 'rubygems' | |
require 'googl' |
OlderNewer