Skip to content

Instantly share code, notes, and snippets.

Ben Wendt rbwendt

Block or report user

Report or block rbwendt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ruby array of arrays to table.rb
class Array
def to_table
column_sizes = self.reduce([]) do |lengths, row|
row.each_with_index.map{|iterand, index| [lengths[index] || 0, iterand.to_s.length].max}
end
puts head = '-' * (column_sizes.inject(&:+) + (3 * column_sizes.count) + 1)
self.each do |row|
row = row.fill(nil, row.size..(column_sizes.size - 1))
row = row.each_with_index.map{|v, i| v = v.to_s + ' ' * (column_sizes[i] - v.to_s.length)}
puts '| ' + row.join(' | ') + ' |'
View gist:46279bb4e34d5b81641d6be9a7407c55
### Keybase proof
I hereby claim:
* I am rbwendt on github.
* I am rbwendt (https://keybase.io/rbwendt) on keybase.
* I have a public key ASAgyHz-jTP3l8PPKmLt9QAuFiLJW0KuQLsodwYyn-CjwAo
To claim this, I am signing this object:
View dimension_value.rb
class DynamicFlow::DimensionValue
include Comparable
attr_accessor :dimension, :value
def initialize(dimension, value)
@dimension = dimension
@value = value
end
def <=>(dv)
@rbwendt
rbwendt / index.html
Last active Oct 5, 2016
dumb Perfect blog
View index.html
<!doctype html>
<html>
<head>
<title>Blog</title>
</head>
<body>
<h1>A blog</h1>
<div id="app">
<article v-for="item in items">
<h2>{{ item.title }}</h2>
@rbwendt
rbwendt / gif.go
Created Sep 30, 2016
golang animated gif
View gif.go
package main
import (
"image"
"image/color"
"image/gif"
"os"
)
func line(from, to []float64, img *image.Paletted) {
You can’t perform that action at this time.