Skip to content

Instantly share code, notes, and snippets.

View Piecuuu's full-sized avatar

Piecuu Piecuuu

  • Poland
  • 10:47 (UTC +01:00)
View GitHub Profile
@suupic
suupic / rb_snowflake_id.rb
Created November 20, 2015 15:46 — forked from pmarreck/rb_snowflake_id.rb
An implementation of Twitter's Snowflake ID generation algorithm in pure Ruby. Note: I didn't rewrite the bits that run this as a service. This is just the algorithm.
require 'monitor'
class IdWorker
attr_reader :worker_id, :datacenter_id, :reporter, :logger, :sequence, :last_timestamp
TWEPOCH = 1288834974657
WORKER_ID_BITS = 5
DATACENTER_ID_BITS = 5
MAX_WORKER_ID = (1 << WORKER_ID_BITS) - 1
@superbrothers
superbrothers / ansi-color.php
Created August 23, 2012 01:49
ANSI color terminal output module for php
<?php
/**
* php-ansi-color
*
* Original
* https://github.com/loopj/commonjs-ansi-color
*
* @code
* <?php
* require_once "ansi-color.php";