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
hash = Hash.new | |
data = @page.parser.css('tbody.white tr') | |
headers = data.shift.css('th')[2..-2].collect { |t| t.text.downcase.to_sym } | |
for row in data | |
values = row.css('td')[1..-2].collect {|t| t.text.strip.gsub(/(\u00A0|:)/, "").downcase } | |
key = values.shift.to_sym | |
hash[key] = Hash.new |
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 | |
# I am trying to replicate the successful connection granted by issuing the following command: | |
# openssl s_client -dtls1 -cipher DHE-DSS-AES256-SHA -connect 209.87.112.215:34135 | |
# http://stackoverflow.com/questions/12836847/how-to-establish-a-ssl-enabled-tcp-ip-connection-in-ruby | |
require 'socket' | |
require 'openssl' |
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 | |
# http://stackoverflow.com/questions/12836847/how-to-establish-a-ssl-enabled-tcp-ip-connection-in-ruby | |
require 'socket' | |
require 'openssl' | |
socket = TCPSocket.open('crew-access-data.ual.com', 34135) | |
ssl_context = OpenSSL::SSL::SSLContext.new | |
ssl_socket = OpenSSL::SSL::SSLSocket.new(socket, ssl_context) | |
ssl_socket.sync_close = 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
u = User.create | |
id = u.id | |
# The above should and does essentially do u.sessions.create() | |
# I expect after initializing this for it to test !session_valid? == false && !new_record? == false | |
u = User.find(id) | |
# I expect after initializing this for it to test !session_valid? == false && !new_record? == false |
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 am executing a program 'umessage' and piping output to this | |
# ruby script ... | |
# | |
# The problem is that I'm noticing my program isn't receiving all | |
# of the output I expect it to receive from STDOUT to STDIN...... | |
# It is consistently skipping data... any hints as to what I'm | |
# doing wrong? | |
DEBUG = 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
@current_data = '' | |
while(data = @current_data.to_s + STDIN.read(100).to_s) | |
@current_data = '' | |
messages = data.lines.slice_before(/^\d{2}\/\d{2}/).collect(&:join) | |
messages.each do |message| | |
if message.join.match(/\n$/) | |
UnimaticMessage.create user_id: ENV['DB_USER_ID'], data: message |
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
class CardsController | |
def create | |
render params.inspect | |
end | |
end | |
# Submitted, this yields: | |
# { "cards" => [ { "black" => ["Edit this new black card text..."] } ] } | |
# I want to yield this: |
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
class Andy | |
def initialize | |
@andytest = [] | |
end | |
attr_reader :andytest | |
end | |
__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
require 'active_support/all' | |
require 'active_record' | |
class WordpressConnection < ActiveRecord::Base | |
end | |
WordpressConnection.establish_connection adapter: 'mysql2', username: 'root', password: 'password', host: 'localhost', database: 'wordpress_wordpress' | |
class WordpressConnection::User < WordpressConnection | |
self.table_name = 'wp_users' |
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
source 'https://rubygems.org' | |
ruby '2.0.0' | |
#ruby-gemset=railstutorial_rails_4_0 | |
gem 'rails', '4.0.4' | |
group :development do | |
gem 'sqlite3', '1.3.8' | |
end |