Skip to content

Instantly share code, notes, and snippets.

View azisaka's full-sized avatar

Zisa azisaka

View GitHub Profile
DIRECTORIES = %w(Users/username)
TO = '/path/for/backup'
OPTIONS = { :rsync => '--progress -varRu', :remote => false }
rsync DIRECTORIES, nil, TO, OPTIONS
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}"
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]
require 'socket'
class UDPClient
def initialize(host, port)
@host = host
@port = port
@socket = UDPSocket.open
@socket.connect(@host, @port)
end
require 'rubygems'
require 'httparty'
class Users
include HTTParty
base_uri 'localhost:5984'
format :json
end
Users.get('/users/_all_docs')['rows'].each do |row|
require 'rubygems'
require 'httparty'
class Users
include HTTParty
base_uri 'localhost:5984'
format :json
end
user = Users.post('/users', { :body => '{ "name": "Testing" }'})
#!/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 ..
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 |
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')
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