- Install homebrew if you don't have it already: http://mxcl.github.com/homebrew/
- Run
brew install vpnc --hybrid
- Check if you already have virtual tunnel interfaces, run
ls /dev/tun*
. If there are none, install "Tun Tap OSX" (see below) - Go to https://www.rz.uni-konstanz.de/angebote/e-mail/usermanager/ and login, then download both the certificate (you need the .pem file) and vpn profile
- Run
openssl x509 -in <certificateFile>.pem -noout -hash
- Rename
<certificateFile>.pem
to the output of (5) with.pem
as extension - Move the
.pem
certificate to a permanent location, e.g./etc/ssl/certs/
- Open
/usr/local/etc/vpnc/default.conf
in your favorite text editor, delete the contents - Run
pcf2vpnc /.pcf
and paste the output to your open text editor
In researching topics for RailsCasts I often read code in Rails and other gems. This is a great exercise to do. Not only will you pick up some coding tips, but it can help you better understand what makes code readable.
A common practice to organize code in gems is to divide it into modules. When this is done extensively I find it becomes very difficult to read. Before I explain further, a quick detour on instance_eval
.
You can find instance_eval
used in many DSLs: from routes to state machines. Here's an example from Thinking Sphinx.
class Article < ActiveRecord::Base
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
DATE=2012-06-01 | |
for version in `find $rvm_path/rubies/ -mindepth 1 -maxdepth 1 -type d -not -newermt $DATE | cut -d / -f 7`; do rvm remove $version; done |
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
1.9.3-p194-perf, rails, 10 unicorns | |
>siege -r 200 -c 10 -d 0 'http://localhost:9080/posts' | |
** SIEGE 2.72 | |
** Preparing 10 concurrent users for battle. | |
The server is now under siege.. done. | |
Transactions: 2000 hits | |
Availability: 100.00 % | |
Elapsed time: 117.59 secs |
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
var Comments = Backbone.Collection.extend({ | |
url: function() { | |
return this.baseUrl + '/comments'; | |
}, | |
initialize: function(bootstrapData, options) { | |
this.baseUrl = options.baseUrl; | |
} | |
}), | |
Posts = Backbone.Collection.extend({ |
- The best tutorials are in the introductory books. See below.
- Getting Started with Clojure - A detailed tutorial on getting a modern (as of Jan 2013) Clojure workflow going.
- Emacs Live is a nice development environment based on Emacs.
- Understanding The Clojure Development Ecosystem
- Clojure Docs Site is a community-driven doc site with good tutorials, and reference material going somewhat deeper than individual API docs.
- Functional Programming for the Rest of Us is a classic introduction to functional thinking
- [A comprehensive article on namespaces and different ways of requiring them](http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.
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
# naive implementation | |
class TwoWayDelegate | |
attr :_subject | |
def initialize(subject) | |
@_subject = subject | |
end | |
def inspect | |
"TwoWayDelegate <#{methods.sort}>" | |
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
class SignPendingOrdersService | |
def initialize(visit, user) # service context | |
@visit, @user = visit, user | |
end | |
def call # or execute | |
Order.for_visit(visit).pendings.each do |order| | |
order.activate! | |
OrderTemplate.find_or_create_template_for_order_and_record_template_usage!(order) | |
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
class ActiveRecord::Migrator | |
def migrate(&block) | |
current = migrations.detect { |m| m.version == current_version } | |
target = migrations.detect { |m| m.version == @target_version } | |
if target.nil? && @target_version && @target_version > 0 | |
raise UnknownMigrationVersionError.new(@target_version) | |
end | |
start = up? ? 0 : (migrations.index(current) || 0) |
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
# The MIT License (MIT) | |
# Copyright (c) 2014 Dave Clark | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: |