View gist:845131
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
## Coding 1-2-3 | |
# This tutorial assumes you're using Ruby 1.8+ | |
# | |
# http://rubyonrails.org/download | |
# | |
# Pick up a free text-editor like SciTE for Windows or | |
# TextWrangler for Mac | |
# Windows: http://bit.ly/SciTE | |
# Mac: http://bit.ly/textwrangler | |
# |
View gist:845658
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
class String | |
def xml_tag_getter(some_tag_word) | |
self.scan(/<#{some_tag_word}\>(.+?)<\/#{some_tag_word}>/).map{|p| p[0] if p} | |
end | |
end |
View 01-get-wjchat-from-api.rb
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
## Scrape wjchat using Twitter API | |
# API Twitter [Docs here](http://dev.twitter.com/doc/get/search): | |
# by @dancow, News App Developer at ProPublica | |
# Updated Mar. 2, 2011 | |
## | |
# This tutorial uses basic scripting commands but doesn't take the time | |
# to explain them. A more explanatory tutorial can be found here: | |
# | |
# http://code-dancow.s3.amazonaws.com/beginners.html | |
# |
View gist:876820
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
<style type="text/css"> | |
#p7s1content1 { | |
position: absolute; | |
width: 1548px; | |
z-index: 99; | |
left: -182px; | |
top: 2064px; | |
visibility: visible; | |
height: 203px; |
View Studio20-Lesson1.rb
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
##### | |
## The following lines load the files we need, and also | |
## makes sure everything is in place | |
['../results', '../html'].each do |dir| | |
raise "#{dir} does not exist as expected" if !File.exists?(dir) | |
end | |
require 'rubygems' | |
require 'rest-client' |
View use_iconv_to_convert_to_ascii.rb
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 'iconv' | |
class String | |
def to_ascii | |
Iconv.iconv('ascii//ignore//translit', 'utf-8', self).to_s | |
end | |
end |
View hstrip.rb
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
class String | |
def hstrip | |
self.gsub(/(?:\s| |\u00A0)+/, ' ').strip | |
end | |
end |
View temper.rb
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
# server | |
require 'rubygems' | |
require 'sinatra' | |
get '/temp' do | |
content_type :json | |
temp = `./temper` | |
bits = temp.split(' ') | |
"{ \"time\" : #{bits[0]}, \"fahrenheit\" : #{bits[2].gsub(/F/,'')}, \"celsius\" : #{bits[3].gsub(/C/,'')} }" |
View poynter.rb
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
jQuery.getJSON('http://graph.facebook.com/Facebook', | |
function(data){ | |
console.log("Success!"); | |
console.log(data['id']); | |
}); |
View lightbulbtoggle-for-brupm.rb
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
# http://blog.brunomiranda.com/post/5660219139/100-light-bulbs-brain-teaser | |
arr = Array.new(100, true) | |
(2..100).each do |d| | |
arr.each_with_index{ |a, i| arr[i] = !a if (i + 1) % d == 0 } | |
end | |
puts arr.each_with_index.map{|a, i| i + 1 if a }.compact.join(", ") |
OlderNewer