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
def tip(msg); puts; puts msg; puts "-"*100; end | |
# | |
# 30 Ruby 1.9 Tips, Tricks & Features: | |
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/ | |
# | |
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2" | |
tip "Ruby 1.9 supports named captures in regular expressions!" |
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
ruby -e '(1..66).each { |i| (1..150).each { |j| system("wget http://mp3.bibleonline.ru/rus_#{i}_#{j}.mp3")}}' |
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
ruby -e "require 'taglib'; TagLib::MPEG::File.open('rus_1_1.mp3') { |file| file.id3v2_tag.frame_list('TIT2').first.text = 'Бытие, глава 1';file.id3v2_tag.frame_list('TPE1').first.text = 'Библия'; file.save}" |
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
(define (square a) (* a a)) | |
(define (sum-of-squares a b) (+ (square a) (square b))) | |
(define (sum-of-two-greatest-squares a b c) | |
(cond ((and (>= a c) (>= b c)) (sum-of-squares a b)) | |
((and (>= a b) (>= c b)) (sum-of-squares a c)) | |
(else (sum-of-squares b c)))) |
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
(define (average x y) | |
(/ (+ x y) 2)) | |
(define (improve guess x) | |
(average guess (/ x guess))) | |
(define (sqrt-iter guess x) | |
(if (good-enough? guess x) | |
guess | |
(sqrt-iter (improve guess x) |
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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/coffee-script/1.6.3/coffee-script.min.js"></script> | |
<script type="text/coffeescript"> | |
canvasWidth = 176 | |
canvasHeight = 176 | |
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
# ruby version >= 2.1.0 | |
require 'socket' | |
Socket.getifaddrs.each do |i| | |
puts "#{i.name}: #{i.addr.ip_address}" if i.addr.ip? | |
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
brews = [] | |
out = IO.popen("brew list", "r") do |io| | |
brews = io.read.split "\n" | |
end | |
def parse(brew, brew_info) | |
in_options = false | |
print "brew reinstall -v #{brew} " | |
brew_info.split("\n").each do |m| | |
#puts m.inspect |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<!-- TUMBLR APPEARANCE OPTIONS --> | |
<meta name="if:Include Like Button" content="0"> | |
<meta name="if:Include Tweet Button" content="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
function trs --description 'Google translate' | |
if test (count $argv) -gt 1 | |
translate \{$argv[1]\} $argv[2..(count $argv)] | gawk '{gsub(/^({+\s+)+/, "")};1' | gawk '{gsub(/\s+}+$/, "")};1' | |
else | |
translate $argv | |
end | |
end |
OlderNewer