(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| require 'csv' | |
| module DownloadService | |
| OPEN_MODE = "w+:UTF-16LE:UTF-8" | |
| BOM = "\xEF\xBB\xBF" #Byte Order Mark | |
| def student_list | |
| File.open("#{file_name}.tsv", OPEN_MODE) do |f| | |
| csv_file = CSV.generate({:col_sep => "\t"}) do |csv| | |
| # header row |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| #!/bin/bash | |
| # -------------------------------------------------------------------------------------------- | |
| # Installs Ruby using rbenv/ruby-build on the Raspberry Pi (Raspbian) | |
| # | |
| # Run from the web: | |
| # bash <(curl -s https://gist.githubusercontent.com/blacktm/8302741/raw/install_ruby_rpi.sh) | |
| # -------------------------------------------------------------------------------------------- | |
| # Set the Ruby version you want to install |
| module Features | |
| module MailHelpers | |
| def last_email | |
| ActionMailer::Base.deliveries[0] | |
| end | |
| # Can be used like: | |
| # extract_token_from_email(:reset_password) | |
| def extract_token_from_email(token_name) |
| # Gitlab 5.1: https://github.com/gitlabhq/gitlabhq/blob/5-1-stable/doc/install/installation.md | |
| # Set up an AWS EC2 Ubuntu 12.04 LTS Server. | |
| # Use ap-southeast-1b: spot pricing is smoother | |
| # Log in as ubuntu@ | |
| sudo apt-get -y update | |
| sudo apt-get -y upgrade | |
| # Install the required packages. |
| #!/bin/sh | |
| # thin This shell script takes care of starting and stopping | |
| # thin daemon from rbenv shared install | |
| # | |
| # chkconfig: 2345 85 15 | |
| # description: thin is an Ruby web server | |
| # config: /etc/sysconfig/thin | |
| ### BEGIN INIT INFO |
I'm a fan of MiniTest::Spec. It strikes a nice balance between the simplicity of TestUnit and the readable syntax of RSpec. When I first switched from RSpec to MiniTest::Spec, one thing I was worried I would miss was the ability to add matchers. (A note in terminology: "matchers" in MiniTest::Spec refer to something completely different than "matchers" in RSpec. I won't get into it, but from now on, let's use the proper term: "expectations").
Let's take a look in the code (I'm specifically referring to the gem, not the standard library that's built into Ruby 1.9):
# minitest/spec.rb
module MiniTest::Expectations| require 'bigdecimal' | |
| require 'csv' | |
| require 'pp' | |
| class Stats | |
| include Enumerable | |
| def initialize(array) | |
| standardize_array(array) | |
| end |
| begin | |
| require 'hirb' | |
| rescue LoadError | |
| # Missing goodies, bummer | |
| end | |
| if defined? Hirb | |
| # Dirty hack to support in-session Hirb.disable/enable | |
| Hirb::View.instance_eval do | |
| def enable_output_method |