(defun fact (n)
(if (= n 1)
1
(* n (fact (1- n)))))
This file contains hidden or 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
| #!/usr/bin/env ruby | |
| require 'rubygems' | |
| require 'json' | |
| require 'net/http' | |
| require 'colorize' | |
| def fetch(url) | |
| resp = Net::HTTP.get_response(URI.parse(url)) | |
| data = resp.body |
http://en.wikipedia.org/wiki/Homoiconicity
(setq y '(+ (* 7 (expt x 3) (* x 9) 2 (cos (* 3 x)))))Predicates - test if something is true.
This file contains hidden or 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
| # functional but linter hates it | |
| (1..100).map {|e| (e % 15).zero? ? "FizzBuzz": (e % 3).zero? ? "Fizz" : (e % 5).zero? ? "Buzz": e }.each {|e| puts e } |
This file contains hidden or 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 'yaml' | |
| puts YAML.load_file(ARGV[0].to_s).sort |
* * * * * cd /home/pi/Sites/testapp && /home/pi/.rvm/bin/rvm all do bundle exec rake sendemail:send >> /home/pi/Sites/testapp/log/cronlog.txt
A Pen by Christopher Saunders on CodePen.
This file contains hidden or 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 'uglifier' | |
| Dir[File.join('_site', '**', '*')].reject { |p| File.directory? p } | |
| .each do |file| | |
| next unless file[/\.js/] | |
| compressed = Uglifier.compile( | |
| File.read(file) | |
| ) | |
| File.open(file, 'w') { |newfile| newfile.write(compressed) } | |
| puts "#{file} uglified." |
This file contains hidden or 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 'zlib' | |
| Dir[File.join('_site', '**', '*')].reject { |p| File.directory? p } | |
| .each do |oldfile| | |
| old_file_text = File.read(oldfile) | |
| open(oldfile, 'wb') do |file| | |
| gzip = Zlib::GzipWriter.new(file) | |
| gzip << old_file_text | |
| gzip.close | |
| end |