Skip to content

Instantly share code, notes, and snippets.

View skord's full-sized avatar
🤘

Mike Danko skord

🤘
  • Estuary
  • Columbus, OH, USA
View GitHub Profile
@skord
skord / gist:1981292
Created March 5, 2012 21:42
em poller
def self.poll(array_of_ips)
EM.synchrony do
snmps = array_of_ips.collect {|x| SNMP4EM::Manager.new(:host => x, :version => :SNMPv1)} #, :port => 4444
concurrency = 50
@start_time = Time.now
EM::Synchrony::Iterator.new(snmps, concurrency).map do |snmp, iter|
request = snmp.get([OID_SYSDESC,OID_OID])
@skord
skord / gist:2218635
Created March 27, 2012 18:17
killsort
$list->setOrdered(true);
if (isset($_GET['allkills']) && $_GET['allkills'] == 0 ) {
$list->setAPIKill();
$list->setOrderBy(' kll.kll_external_id ASC ');
} else {
$list->setOrderBy(' kll.kll_id ASC ');
}
if (isset($_GET['limit'])) {
$list->setLimit(min($maxkillsreturned, (int)$_GET['limit']));
} else {
@skord
skord / gist:2219516
Created March 27, 2012 19:29
get alliance kills
class Alliance
include Mongoid::Document
field :name, :type => String
field :eve_reference, :type => Integer
embeds_many :kills
def initial_kill_hash
initial_kills = Hash.from_xml(open("http://eve-kill.net/?a=idfeed&alliance=#{self.eve_reference}&startdate=#{1.year.ago.to_i}"))
create_kills_from_hash(initial_kills)
end
@skord
skord / gist:2406058
Created April 17, 2012 13:45
twitter location info
{"geometry":{"type":"Polygon","coordinates":[[[-84.820305,38.403423],[-84.820305,42.327132],[-80.518454,42.327132],[-80.518454,38.403423],[-84.820305,38.403423]]]},"country":"United States","bounding_box":{"type":"Polygon","coordinates":[[[-84.820305,38.403423],[-80.518454,38.403423],[-80.518454,42.327132],[-84.820305,42.327132]]]},"polylines":["ktkiFzmudOej\u007DV??qegYdj\u007DV??pegY"],"name":"Ohio","attributes":{"162813:id":"OH","162772:state_id":"39","189390:id":"ohio"},"full_name":"Ohio, US","country_code":"US","url":"http:\/\/api.twitter.com\/1\/geo\/id\/de599025180e2ee7.json","place_type":"admin","contained_within":[{"country":"United States","bounding_box":null,"name":"United States","attributes":{},"full_name":"United States","country_code":"US","url":"http:\/\/api.twitter.com\/1\/geo\/id\/96683cc9126741d1.json","place_type":"country","id":"96683cc9126741d1"}],"id":"de599025180e2ee7"}
@skord
skord / isilon.xml
Created April 27, 2012 14:02
OpenNMS Data Collection Definition for Isilon Storage Systems
<?xml version="1.0"?>
<datacollection-group name="Isilon">
<resourceType name="isiProtocolName" label="Isilon Node Traffic by Protocol" resourceLabel="${protocolName} Stats">
<persistenceSelectorStrategy class="org.opennms.netmgt.collectd.PersistAllSelectorStrategy"/>
<storageStrategy class="org.opennms.netmgt.dao.support.IndexStorageStrategy"/>
</resourceType>
<resourceType name="isiDiskPerfBay" label="Isilon Node Disk Bays" resourceLabel="Disk ${deviceName}">
<persistenceSelectorStrategy class="org.opennms.netmgt.collectd.PersistAllSelectorStrategy"/>
<storageStrategy class="org.opennms.netmgt.dao.support.IndexStorageStrategy"/>
@skord
skord / wootlet.rb
Created May 23, 2012 13:14
wootlet
#!/usr/bin/env ruby
require 'rubygems'
require 'feedzirra'
require 'open-uri'
def item_prices(parsed_feed, number_to_display)
prices = parsed_feed.entries[1..number_to_display].collect {|x| x.summary.scan(/itemPrice:\'(\d{1,}\.\d{2})/)}.collect {|x| x.flatten}
@skord
skord / kisama_downloader.rb
Created August 10, 2012 13:19
4chan board sync
Bundler.require(:default)
require 'open-uri'
require 'net/http'
require "em-synchrony"
require "em-synchrony/em-http"
require 'em-synchrony/fiber_iterator'
class KisamaDownloader
attr_reader :url, :live_thread, :images
@skord
skord / discard_frames.rb
Created August 27, 2012 14:52
Deletes X frames from mplayer jpeg output
#!/usr/bin/env ruby
def discard_x_frames(number)
files = Dir.glob('*.jpg')
files.in_groups_of(number + 1).each do |files|
files[1..-1].each do |file|
File.unlink(file)
end
end
@skord
skord / chanpi.rb
Created September 14, 2012 19:10
simple wrapper for the 4chan JSON api
require 'json'
require 'net/http'
require 'time'
class Chanpi
attr_accessor :url, :posts, :http_resp_code, :last_modified
attr_reader :board, :html_uri
def initialize(json_url)
@url = json_url
@board = URI(json_url).path.split('/')[1]
@skord
skord / profile.rb
Created October 4, 2012 01:18
AwkwardNarwhal User Model
class Profile
include Gmaps4rails::ActsAsGmappable
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Geospatial
# include Mongoid::Spacial::Document
field :name, :type => String, :default => 'Anonymous Narwhal'
field :headline, :type => String, :default => "I couldn't be bothered with a headline."