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 ConvertAgentNameToIds < ActiveRecord::Migration | |
TYPES = ['created', 'modified', 'cancelled'] | |
def up | |
@agents = Hash[*User.select([:first_name, :last_name, :username]).map {|i| ["#{i.first_name} #{i.last_name}", i.username]}.flatten] | |
TYPES.each {|i| convert_agent(i)} | |
end | |
def down | |
@agents = Hash[*User.select([:first_name, :last_name, :username]).map {|i| [i.username, "#{i.first_name} #{i.last_name}"]}.flatten] |
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
Module Utility | |
class << self | |
def to_time_with_zone(timezone, date, hour, minute) | |
old_time_zone = Time.zone | |
Time.zone = timezone | |
Time.zone.parse("#{date} #{hour}:#{minute}") | |
ensure | |
Time.zone = old_time_zone | |
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
class Reports::Duplicates | |
include ActiveModel::Validations | |
include ActiveModel::Conversion | |
extend ActiveModel::Naming | |
attr_accessor :run_time, :conditions, :matches | |
def initialize(attributes = {}) | |
self.run_time = Time.now | |
attributes.each {|name, value| send("#{name}=", value)} |
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 FooController < ApplicationController | |
require 'rubygems' | |
require 'mechanize' | |
require 'open-uri' | |
def scrape | |
url = 'http://www.hotnewhiphop.com/archive/' | |
agent = Mechanize.new | |
page = agent.get(url) | |
render text: page.links.map(&:to_html).join("\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
IMAGE: https://www.dropbox.com/s/90swuhnofjwheil/temp.png | |
#!/bin/env ruby | |
require 'rubygems' | |
require 'rtesseract' | |
mix_block = RTesseract::Mixed.new("temp.png") do |image| | |
image.area(85, 13, 80, 30) | |
end | |
puts mix_block.to_s |
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
http://localhost:3001/locations/upload_locations?key=12345 | |
GET /locations/upload_locations?key=12345 HTTP/1.1 | |
Host: localhost:3001 | |
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:26.0) Gecko/20100101 Firefox/26.0 | |
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 | |
Accept-Language: en-US,en;q=0.5 | |
Accept-Encoding: gzip, deflate | |
Connection: keep-alive | |
If-None-Match: "7215ee9c7d9dc229d2921a40e899ec5f" |
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
def upload_locations | |
if params[:key] == '12345' | |
@locations = Location.active.order("locations.code") | |
stream = render_to_string(template: "locations/index", formats: [:xml]) | |
Net::SFTP.start('host', 'user', password: 'pass') do |sftp| | |
sftp.file.open("locations.xml", "w") do |f| | |
f.puts stream | |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Prototype</title> | |
<style> | |
h1 { | |
text-align: center; | |
} | |
#main_container { |
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
Me(19:26:20): Ok, I'm logged in | |
Me(19:26:33): My issue now is that I can't view my bill | |
Me(19:26:40): Can you look into why? | |
John(19:27:21): I show the following: This account is Suspended due to non-payment and access to email is blocked. Email access will be unblocked once the required payment is made. | |
Me(19:27:45): lol, how can I make payment if my access is blocked? | |
John(19:28:05): Normally, an account must be upgraded to Full Access in order to view the bill; however with that lock I can't tell if that is the case. | |
You should still be able to pay the bill, even with that lock. | |
Me(19:28:37): there's no place for me to make payment | |
Me(19:28:57): can you unlock so I can pay? |
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
def overlap?(range1_start, range1_end, range2_start, range2_end) | |
if (range1_start > range2_end || range1_end < range2_start) | |
false | |
else | |
true | |
end | |
end |