Skip to content

Instantly share code, notes, and snippets.

View JamesHarrison's full-sized avatar

James Harrison JamesHarrison

View GitHub Profile
@JamesHarrison
JamesHarrison / metoffice.rb
Created February 5, 2009 10:53
Two classes for scraping and viewing met office satellite data
# tiny little class to scrape Met Office satellite and radar image feeds and save them
require 'net/http'
require 'ftools'
class MetOfficeGrabber
def initialize(type, save_folder, file_format='jpg', base_url='http://www.metoffice.gov.uk/weather/images')
@type = type.to_s # eg ukir_sat or ukvis_sat
@url = URI.parse(base_url.to_s) # met office website
@path = save_folder.to_s # save location - will be folderised by type
@format = file_format.to_s # what format is the file on the website? radar uses gif.
# make save location if it doesn't exist
/*Column Information For - evemetrics_development.order_facts*/
---------------------------------------------------------------
Field Type Collation Null Key Default Extra Privileges Comment
-------------- ------- --------- ------ ------ ------- -------------- ------------------------------- -------
id int(11) (NULL) NO PRI (NULL) auto_increment select,insert,update,references
lowSellPrice float (NULL) YES (NULL) select,insert,update,references
totalDemand int(11) (NULL) YES (NULL) select,insert,update,references
avgSellPrice float (NULL) YES (NULL) select,insert,update,references
totalProvision int(11) (NULL) YES (NULL) select,insert,update,references
We couldn’t find that file to show.
@JamesHarrison
JamesHarrison / fitting.rb
Created February 23, 2009 23:22
Parser, classes and reader/writer for EVE Online Fitting XML exports
# Fitting.rb
# Version 0.1. Will package properly one day when it's all done and I get around to writing tests.
# Simple class for reading and writing CCP EVE Online Fitting Manager XML files.
# Generated Fitting classes with Module classes inside the Fitting's modules array attribute allow you to reproduce ships exactly.
# License: GPLv3
# If you use this, feel free to donate iskies to Ix Forres.
require 'rubygems'
require 'hpricot'
require 'builder'
require 'ftools'
# Using delayed_job and want to bring cache_money into the mix? Read on...
module Cash
module Query
class Abstract
delegate :with_exclusive_scope, :get, :table_name, :indices, :find_from_ids_without_cache, :cache_key, :columns_hash, :to => :@active_record
def self.perform(*args)
new(*args).perform
end
<?xml version="1.0" ?>
<eveOverview>
<tab bracket="battle (noblue)" name="battle" overview="battle (noblue)" showAll="True" showNone="False" showSpecials="False"/>
<tab bracket="normal" name="normal" overview="test" showAll="True" showNone="False" showSpecials="False"/>
<tab bracket="pos" name="pos" overview="pos" showAll="False" showNone="False" showSpecials="False"/>
<globalSettings>
<useSmallColorTags value="None"/>
<applyOnlyToShips value="None"/>
<hideCorpTicker value="0"/>
<overviewBroadcastsToTop value="1"/>
o = Eve::Overviews::Overview.new(File.read("overviewtest.xml"))
# Rename our profiles so nothing collides.
o.profiles.each do |p|
p.name = "IMP #{p.name}"
end
# We don't want to hide the corp ticker if they're in an alliance
o.global_settings.hide_corp_ticker = false
# Let's enable the corporation label
o.ship_labels.detect{|sl|sl.type='corporation'}.state = true
# And write to a file
require 'rubygems'
require 'reve'
path = "assets.msh"
file = File.open(path,'a+')
cid = 123098319308
uid = 20391123123
key = "YOURKEY"
api = Reve::API.new(uid,key)
assets = api.personal_assets_list(:characterid=>cid)
# this goes in xchat's program files directory
title = 'Unknown Song' if title.empty?
artist = 'Unknown Artist' if artist.empty?
srate = track.samplerate / 1000.0
string = "me is listening to \"\0034\002#{title}\002\003\" by \0034#{artist}\003"
string = "#{string} from \0034#{album}\003" unless album.empty?
string = "#{string} [#{position}..#{length}/#{track.bitrate}kbps/#{srate % 1 == 0 ? srate.to_i : srate}khz]"
puts string
# Returns username,repository,commit (HEAD by default),branch (if a branch home URL) of a given github URL.
# Parameters:
# url (String) - The URL to parse
# The method makes some assumptions:
# * Repositories will never have a branch name exactly 40 characters long- this will always be a commit reference
# * Github only allows alphanum and hyphens as user or repository names
def parse_github_url(url)
if url.match(/github.com\/([\w\-]+?)\/([\w-]+)\/([\w-]+)\/(\w{,39}|\w{40,})/) # We've got a specific commit mentioned here
username,repository,commit,branch = $1,$2,($4),'master'
elsif url.match(/github.com\/([\w\-]+?)\/([\w-]+)\/([\w-]+)\/([\w-]+)/)