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
DIRECTORIES = %w(Users/username) | |
TO = '/path/for/backup' | |
OPTIONS = { :rsync => '--progress -varRu', :remote => false } | |
rsync DIRECTORIES, nil, TO, 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 'rubygems' | |
require 'activesupport' | |
def rsync(directories, from, to, options = {}) | |
options.reverse_merge!(:rsync => "-varRu", | |
:remote => true) | |
directories.each do |dir| | |
destination = options[:remote] ? "#{from}:/#{dir}" : "/#{dir}" | |
command = "rsync #{options[:rsync]} #{destination} #{to}" |
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 'tempfile' | |
class LocalFile | |
# The filename, *not* including the path, of the "uploaded" file | |
attr_reader :original_filename | |
# The content type of the "uploaded" file | |
attr_reader :content_type | |
def initialize(path) | |
raise "#{path} file does not exist" unless File.exist?(path) | |
content_type ||= @@image_mime_types[File.extname(path).downcase] |
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 'socket' | |
class UDPClient | |
def initialize(host, port) | |
@host = host | |
@port = port | |
@socket = UDPSocket.open | |
@socket.connect(@host, @port) | |
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
require 'rubygems' | |
require 'httparty' | |
class Users | |
include HTTParty | |
base_uri 'localhost:5984' | |
format :json | |
end | |
Users.get('/users/_all_docs')['rows'].each do |row| |
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 'httparty' | |
class Users | |
include HTTParty | |
base_uri 'localhost:5984' | |
format :json | |
end | |
user = Users.post('/users', { :body => '{ "name": "Testing" }'}) |
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
#!/bin/sh | |
cd /tmp | |
curl -O http://savannah.c3sl.ufpr.br/freetype/freetype-2.3.9.tar.bz2 | |
tar xjvf freetype-2.3.9.tar.bz2 | |
cd freetype-2.3.9 | |
./configure --prefix=/usr/local | |
make | |
sudo make install | |
cd .. |
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
before | |
+----------------------+-------+-------+---------+---------+-----+-------+ | |
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M | | |
+----------------------+-------+-------+---------+---------+-----+-------+ | |
| Controllers | 1532 | 1230 | 16 | 97 | 6 | 10 | | |
| Helpers | 442 | 410 | 2 | 19 | 9 | 19 | | |
| Models | 814 | 622 | 18 | 69 | 3 | 7 | | |
| Libraries | 0 | 0 | 0 | 0 | 0 | 0 | | |
| Functional tests | 125 | 96 | 14 | 15 | 1 | 4 | |
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 File.dirname(__FILE__) + '/../../test_helper' | |
class ApplicationHelperTest < ActionView::TestCase | |
context "Encoding text" do | |
setup do | |
@text = '*Test* Test Test' | |
end | |
should "be in simple_format" do | |
result = encode_text(@text, 'none') |
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 "test/unit" | |
require "activesupport" | |
class String | |
def titleize_street | |
title = self.titleize | |
title =~ /^(\d+) (Th|Nd|St|Rd) (.*)/ ? "#{$1}#{$2.downcase} #{$3}" : title | |
end | |
end |