Skip to content

Instantly share code, notes, and snippets.

@joshuawscott
joshuawscott / sequel_points.rb
Last active June 11, 2017 22:19
Polygons/Points/Arrays using Sequel for PostgreSQL
require 'sequel'
class Point
attr_accessor :long, :lat
def initialize(long, lat)
@long = long
@lat = lat
end
def self.from_str(str)
@joshuawscott
joshuawscott / redis_slowlog.rb
Last active August 6, 2017 10:01
Get Redis Slowlog Entries and parse them
# [[87283, 1442412746, 18052, ["hincrby", "191320:2015-09-16", "2015-09-16T13:39:00.000Z", "1"]], [87282, 1442411252, 22037, ["setex", "sifi_session:da34d588e031730b84a0462538022c60", "604800", "\u0004\b{\u0000"]], [87281, 1442410521, 81575, ["scan", "0", "MATCH", "CampaignStatistic:*", "COUNT", "1000"]], [87280, 1442409284, 12309, ["hincrby", "167569:2015-09-16", "2015-09-16T12:57:00.000Z", "1"]], [87279, 1442409279, 11073, ["hincrby", "163562:2015-09-16", "2015-09-16T12:55:00.000Z", "1"]], [87278, 1442409206, 14440, ["hincrby", "163558:2015-09-16", "2015-09-16T12:40:00.000Z", "1"]], [87277, 1442409198, 14750, ["hincrby", "187840:2015-09-16", "2015-09-16T12:34:00.000Z", "1"]], [87276, 1442409180, 11376, ["hincrby", "127478:2015-09-16", "2015-09-16T12:07:00.000Z", "1"]], [87275, 1442405559, 18445, ["hincrby", "182934:2015-09-16", "2015-09-16T11:13:00.000Z", "1"]], [87274, 1442405558, 57467, ["hincrby", "17342:2015-09-16", "2015-09-16T11:03:00.000Z", "1"]]]
require 'redis'
class Entry
attr_reader :log_numbe
@joshuawscott
joshuawscott / ruby_news_2016-07.md
Created July 21, 2016 16:03
Ruby News Rundown, July 2016

News

Rails 5.0 released

Deets:

  • ActionCable - websockets in rails!
  • API mode - strip out all the unneeded parts of rails when you just want an API
Pending: (Failures listed here are expected and do not affect your suite's status)
1) AppNexus Advertiser writeme, testme, useme
# Not yet implemented
# ./spec/integration/advertiser_spec.rb:4
Failures:
1) AppnexusApi::Connection returns data from expiration
Failure/Error: fail "#{response.body['response']['error_code']}/#{response.body['response']['error_description']}"

LZF Format

LZF is made of 1 or more "Chunks" that are simply concatenated to each other.

Chunk Layout

   "Z"   |  "V"   | Type   |compressed length| original length | payload
+--------+--------+--------+--------+--------+--------+--------+=================
|01011010|01010110|0000000C|LLLLLLLL|LLLLLLLL|BBBBBBBB|BBBBBBBB| L bytes of data
+--------+--------+--------+--------+--------+--------+--------+=================