Skip to content

Instantly share code, notes, and snippets.

View boazsegev's full-sized avatar
💭
Changing

Bo boazsegev

💭
Changing
View GitHub Profile
@boazsegev
boazsegev / fizbuz.c
Last active February 9, 2021 09:24
FizBuz in C - a bitwise based approach
#include <stdio.h>
#include <stdlib.h>
// calls `snprintf` with the correct fizbuz result.
//
// Note: zero modulus is questionable... but we assume it's fine.
//
// A response to Kevlin Henney's talk from 2019: https://youtu.be/SFv8Wm2HdNM
int fizzbuzz(char *dest, unsigned long dest_len, unsigned long num) {
// construct bit based result for the 4 possible states of fizbuz
@boazsegev
boazsegev / The Priceless Ruby Websocket.md
Last active March 12, 2018 13:32
The Priceless Ruby Websocket

A proof of concept for Rack's env['rack.websocket']

This is a proof of concept for Rack based Websocket connections, showing how the Rack API can be adjusted to support server native real-time connections.

The chosen proof of concept was the ugliest chatroom I could find.

Although my hope is that Rack will adopt the concept and make env['rack.websocket?'] and env['rack.websocket'] part of it's standard, at the moment it's an Iodine specific feature, implemented using env['iodine.websocket'].

Install

@boazsegev
boazsegev / yank_all.rb
Last active January 6, 2020 13:32
Yank multiple versions of a single gem
#!/usr/bin/env ruby
# encoding: UTF-8
require'json'
def yank
gemname = (ARGV.index('-g') && ARGV[ARGV.index('-g') + 1]) || (puts('Please enter gem name:') || gets.strip)
data = JSON.parse `curl -s https://rubygems.org/api/v1/versions/#{gemname}.json`
versions = data.map {|v| v['number']} .reverse
puts "\n\n#{gemname} versions: #{versions.join ', '}"
puts "\nHow many versions to yank (starting at the first release) (none/ALL/number)?"