Skip to content

Instantly share code, notes, and snippets.

View gmgent's full-sized avatar

Krister Axel gmgent

  • Ashland IO LLC
  • Ashland, OR
View GitHub Profile
#!/usr/bin/env ruby
require file.dirname(__FILE__) + /../config/environment'
require 'aws/s3'
require 'progressbar'
#set up S3 config connect
config = YAML.load(File.open(File.join(RAILS_ROOT, 'config/amazon_s3.yml')))[RAILS_ENV]
bucket = config['bucket_name']
AWS::S3::Base.establish_connection!(
## Colors
# colors for misc things
export TERM=xterm-color
export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32'
export CLICOLOR=1
# Set colors
export LS_COLORS='di=1;36:fi=0:ln=4;34:pi=5:so=4;5:bd=5:cd=5:or=4;91:mi=4;92:ex=35:*.rb=90'
# used in command prompt
mv /Applications/Firefox.app/Contents/MacOS/libsqlite3.dylib /Applications/Firefox.app/Contents/MacOS/libsqlite3.dylib.orig
cp /usr/lib/libsqlite3.dylib /Applications/Firefox.app/Contents/MacOS/libsqlite3.dylib
ApprovalStatuses = {
deleteApprovalStatus: function() {
if(confirm("Are you sure you want to delete this approval status?")) {
if($(this).parent("form").find("input[name='drug_record_count']").val() > 0) {
$("#move_drug_records_form").attr("action", $(this).parent("form").attr("action"));
var approvalStatusId = $(this).parent("form").find("input[name='approval_status_id']").val();
$("#target_approval_status_id").customSelect.hideOption(approvalStatusId);
Thickbox.show({inlineId: "move_drug_records", modal: true, height: 200, width: 380});
} else {
$(this).parent("form").submit();
@gmgent
gmgent / stacker.rb
Created March 8, 2011 19:02
used to build a string for feeding to flash (like FusionCharts)
class Stacker
include Utils
attr_reader :chart_to_go
attr_accessor :caption
attr_accessor :start_date
attr_accessor :input_records
attr_accessor :date_string
def initialize(caption, start_date, y_axis)
@caption = caption
@gmgent
gmgent / geocoder.rb
Created March 8, 2011 19:05
used to get Lat Long values from Yahoo Maps API on the fly
class GetLatLong
require 'open-uri'
attr_reader :latitude
attr_reader :longitude
attr_reader :message
attr_reader :valid
attr_writer :address
attr_writer :state
class Float
def round_to(x)
(self * 10**x).round.to_f / 10**x
end
def ceil_to(x)
(self * 10**x).ceil.to_f / 10**x
end
def floor_to(x)
@gmgent
gmgent / scraper.rb
Created March 8, 2011 19:08
basically a proof of concept for playing with hpricot
desc 'Scrape away.'
require 'config/boot'
require 'config/environment'
require 'application'
require 'net/ftp'
#include Utils
require 'rubygems'
require 'open-uri'
require 'hpricot'
def create
respond_to do |format|
format.xml {
install = OnInstall.new do |i|
i.ip_address = request.remote_ip
i.mac_address = params[:mac_address]
i.on_dvd_id = params[:on_dvd_id].to_i
i.on_dvd_number = params[:on_dvd_number]
i.on_dvd_set_id = params[:on_dvd_set_id].to_i
CREATE PROCEDURE sp_generate_forecast (IN p_run_day INT(10), IN p_month INT(10), IN p_year INT(10), IN revplanid INT(10), IN month_days INT(10))
BEGIN
DECLARE r_units, r_day, r_partner int;
DECLARE done int DEFAULT 0;
— fields – partial_total day_ave retail_chg margin_chg
— retail_margin net_sales p_rev_share gross_margin
— clear out any previous forecast
DELETE FROM revplan_infos
WHERE revplan_id = revplanid