Skip to content

Instantly share code, notes, and snippets.

View lazyatom's full-sized avatar
🤠
Yes

James Adam lazyatom

🤠
Yes
View GitHub Profile
Fedifeed implementation notes
Two components
Server implements a few endpoints
/reblogs — returns accounts that you reblog the most
/core_servers — returns the instances who host most of the accounts you follow
/favourites — returns users that you favourite the most
Client hits those endpoints, and then:
@lazyatom
lazyatom / Output
Last active October 3, 2016 12:36
Huffman encoding and decoding
$ ruby huffman.rb this is a test of compression
input length in bits 232 (29 * 8)
Binary 1111100000100011001000110100101101111101000111111001111100110111010111001110001101111010000001001110110
Encoded string length in bits: 103
Compression: 44.396551724137936%
Decoded: this is a test of compression
@lazyatom
lazyatom / jruby_refinements.rb
Created December 18, 2015 14:40
Do refinements work in JRuby?
module Refinement
refine Object do
def new_method
'new method!'
end
end
end
class Thing
using Refinement
@lazyatom
lazyatom / app1.rb
Created February 6, 2015 15:05
Detecting where your library has been required from
# Some userland app code
$LOAD_PATH.unshift "."
require 'lib'

this is a test

  • item one
  • item two
  • item three

test complete! but what about normal lists?

  • thing
  • another thing

Keybase proof

I hereby claim:

  • I am lazyatom on github.
  • I am lazyatom (https://keybase.io/lazyatom) on keybase.
  • I have a public key whose fingerprint is BE7C E844 BBAA 3308 53A6 63B5 13FD BF1B D9DA 2B35

To claim this, I am signing this object:

@lazyatom
lazyatom / playing-with-docker-instructions.md
Last active August 29, 2015 13:56
Austin on Rails - play around with Docker

If you'd like a taste of Docker, here's how to get my silly Taco app running under Docker on your machine.

First, install docker-osx

... using instructions from https://github.com/noplay/docker-osx

curl https://raw.github.com/noplay/docker-osx/0.8.0/docker-osx > /usr/local/bin/docker-osx
chmod +x /usr/local/bin/docker-osx

Then start the docker VM

How Should We Use Struct?

The Choice

It's common in Ruby to see some code setup a Struct like this:

class Specialized < Struct.new(:whatever)
  # ... define custom methods here...
end
@lazyatom
lazyatom / rocco.css
Created April 2, 2013 09:29
Rocco CSS
/*--------------------- Layout and Typography ----------------------------*/
body {
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
font-size: 15px;
line-height: 22px;
color: #252519;
margin: 0; padding: 0;
}
a {
color: #261a3b;
@lazyatom
lazyatom / anonimise_selections.sql
Created March 14, 2013 13:26
Ruby Manor 4.0 voting - anonymised
select substring(md5(<first salt> || proposal_id) for 8) as proposal_hash, substring(md5(<second salt> || user_id) for 8) as user_hash from selections;