Skip to content

Instantly share code, notes, and snippets.

For each Ruby module/class, we have Ruby methods on the left and the equivalent
Clojure functions and/or relevant notes are on the right.
For clojure functions, symbols indicate existing method definitions, in the
clojure namespace if none is explicitly given. clojure.contrib.*/* functions can
be obtained from http://github.com/kevinoneill/clojure-contrib/tree/master,
ruby-to-clojure.*/* functions can be obtained from the source files in this
gist.
If no method symbol is given, we use the following notation:
@thisivan
thisivan / git_remote_branches.sh
Created April 28, 2009 02:41
Git: Track Remote Branches
# Create new remote branch
git push origin origin:refs/heads/new_branch_name
# Make sure everything is updated
git fetch origin
# Check your branch has been created
git branch -r
# Track a remote branch
@cgrand
cgrand / irclog.clj
Created May 22, 2009 19:57
An IRC logger which serves its archives over HTTP
(ns irclog
(:use net.cgrand.moustache)
(:use net.cgrand.enlive-html)
(:require [ring.httpcore :as hc])
(:import (org.jibble.pircbot PircBot)
(org.joda.time DateTime)
(org.joda.time.format ISODateTimeFormat)))
(defn yyyy-MM-dd [d] (-> (ISODateTimeFormat/date) (.print d)))
(ns compojure.openid
"Compojure OpenID wrapper around jopenid library."
(:use compojure.control)
(:use compojure.encodings)
(:use compojure.http)
(:use compojure.http.session)
(:import com.javaeedev.openid.OpenIdManager)
(:import javax.servlet.http.HttpServletRequest))
(defn- make-manager
@jnunemaker
jnunemaker / gist:217362
Created October 24, 2009 04:07 — forked from lukesutton/gist:107966
example of warden 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
@gus
gus / index.txt
Created November 30, 2009 21:55 — forked from toothrot/index.txt
Ruby/Clojure analogs
For each Ruby module/class, we have Ruby methods on the left and the equivalent
Clojure functions and/or relevant notes are on the right.
For clojure functions, symbols indicate existing method definitions, in the
clojure namespace if none is explicitly given. clojure.contrib.*/* functions can
be obtained from http://github.com/kevinoneill/clojure-contrib/tree/master,
ruby-to-clojure.*/* functions can be obtained from the source files in this
gist.
If no method symbol is given, we use the following notation:
@sanemat
sanemat / Advent_Calendar_2009.md
Created December 2, 2009 07:22
Advent Calendar 2009 lists
@draegtun
draegtun / Url.pm
Created December 15, 2009 14:48
URL in Perl with no strings attached!
package Url;
use Modern::Perl;
use Devel::Declare ();
use LWP::Simple ();
use base 'Devel::Declare::Context::Simple';
sub import {
my $class = shift;
my $caller = caller;
my $ctx = __PACKAGE__->new;
@abhijith
abhijith / swing.clj
Created December 21, 2009 18:43
miglayout swing clojure experiments
(ns swinger
(:import (java.awt BorderLayout Container Dimension))
(:import (javax.swing JButton JFrame JLabel JPanel JTextField JOptionPane JScrollPane JList ImageIcon JComboBox JSeparator JTable UIManager SwingUtilities AbstractButton JFileChooser JDialog JProgressBar JTabbedPane))
(:import (javax.swing.table AbstractTableModel))
(:import (java.awt.event MouseAdapter MouseListener KeyEvent))
(:import (java.awt Toolkit BorderLayout Dimension Color Dialog$ModalityType))
(:use (clojure.contrib
[miglayout :only (miglayout components)]
[swing-utils :only (add-action-listener add-key-typed-listener make-menubar)])))
@draegtun
draegtun / meta_perl6.pl
Created January 13, 2010 21:25
Perl6 metaprogramming example
#!/usr/bin/env perl6
# see:
# * http://transfixedbutnotdead.com/2010/01/13/anyone_for_metaprogramming/
# * http://transfixedbutnotdead.com/2010/01/14/anyone-for-perl-6-metaprogramming/
# * http://fingernailsinoatmeal.com/post/292301859/metaprogramming-ruby-vs-javascript
# * http://transfixedbutnotdead.com/2010/10/31/perl6-metaprogramming-update/
# below runs on Rakudo Star (2010.10 release).