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 'nokogiri' | |
require 'open-uri' | |
require 'pp' | |
url = "http://www.bedbathandbeyond.com/product.asp?sku=40354439&" | |
doc = Nokogiri::HTML(open(url)) | |
data = {} |
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
[user] | |
name = Eric London | |
email = [email protected] | |
[core] | |
excludesfile = /Users/Eric/.gitignore | |
[alias] | |
lg = log --graph --pretty=format:'%C(red)%h%Creset%C(yellow)%d%Creset %C(bold blue)%an%Creset %C(green)%cr%Creset %s' --abbrev-commit --date=relative --all | |
lg2 = log --graph --pretty=format:'%C(red)%h%Creset%C(yellow)%d%Creset %C(bold blue)%an%Creset %C(green)%cr%Creset %s' --abbrev-commit --date=relative | |
[color] | |
ui = auto |
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 'selenium-webdriver' | |
require 'uri' | |
website_url = ARGV[0] | |
if website_url.empty? | |
puts "Website Argument Required.\n" | |
exit() | |
end |
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
# Usage: | |
# tree = RandomTreeToken.new | |
# puts tree.generate | |
class RandomTreeToken | |
def initialize | |
require 'net/http' | |
url = 'http://treesofnorthamerica.net/' | |
body = Net::HTTP.get_response(URI.parse(url)).body |
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
# I created a Post controller to accept a parameter for tag name. | |
# The problem is, the tag "Drupal 6.x", or anything with a period was triggering :format | |
get 'posts/tag/:tag' => 'posts#tag', :format => false, :constraints => {:tag => /.*/} |
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
1.9.2-p290 :002 > u = Upload.new | |
=> #<Upload id: nil, post_id: nil, created_at: nil, updated_at: nil, upload_file_name: nil, upload_content_type: nil, upload_file_size: nil, upload_updated_at: nil> | |
1.9.2-p290 :004 > u.upload = File.open('/Users/Eric/Desktop/estimation grid.png') | |
=> #<File:/Users/Eric/Desktop/estimation grid.png> | |
1.9.2-p290 :005 > u.save! | |
(0.1ms) begin transaction | |
SQL (17.4ms) INSERT INTO "uploads" ("created_at", "post_id", "updated_at", "upload_content_type", "upload_file_name", "upload_file_size", "upload_updated_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["created_at", Fri, 16 Mar 2012 16:13:46 UTC +00:00], ["post_id", nil], ["updated_at", Fri, 16 Mar 2012 16:13:46 UTC +00:00], ["upload_content_type", "image/png"], ["upload_file_name", "estimation_grid.png"], ["upload_file_size", 53079], ["upload_updated_at", Fri, 16 Mar 2012 16:13:43 UTC +00:00]] | |
(23.8ms) commit transaction |
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
# loop through nodes:story data | |
json_data['nodes']['story'].each do |i, story| | |
################################################## | |
# modify html per google prettify | |
# scan for <code> tags | |
matches = story['body'].scan(/(<code>)(.*?)(<\/code>)/im) | |
matches.each do |match| | |
new_string = '<pre class="prettyprint"><code class="prettyprint">' + match[1].gsub(/<\?php/, '<?php') + '</code></pre>' |
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
# update installed packages | |
sudo apt-get update | |
sudo apt-get upgrade | |
# ssh server | |
sudo apt-get install openssh-server -y | |
# install curl | |
sudo apt-get install curl -y |
NewerOlder