Skip to content

Instantly share code, notes, and snippets.

Avatar

Willem van Bergen wvanbergen

View GitHub Profile
View gist:f84471dbf2b9f9a75d15
____ ____ ____ _______
| | | _/
| | | \o/ _/
| | | | _/
| | ==> | /\/
| o | | _/
| |- | | _/
|_/\_| |____/
@wvanbergen
wvanbergen / Makefile
Last active Aug 29, 2015
Makefile to install and run the confluent inc platform for CI purposes.
View Makefile
.PHONY: confluent/kafka/* confluent/zookeeper/* confluent/registry/* confluent/start confluent/stop
# Confluent platform tasks
confluent/start: confluent/rest/start
confluent/stop: confluent/rest/stop confluent/registry/stop confluent/kafka/stop confluent/zookeeper/stop
# Download & extract tasks
@wvanbergen
wvanbergen / bitwise.rb
Last active Aug 29, 2015
0xabc to 0xaabbcc using bitwise operators
View bitwise.rb
# There must be a nicer way than this
((x & 0xf00) << 12 | (x & 0xf00) << 8) |
((x & 0x0f0) << 8 | (x & 0x0f0) << 4) |
((x & 0x00f) << 4 | (x & 0x00f))
@wvanbergen
wvanbergen / gist:3510208
Created Aug 29, 2012
Travis build exception
View gist:3510208
1Using worker: ruby3.worker.travis-ci.org:ruby-3
2
3
4
5
6I'm sorry but an error occured within Travis while running your build.
7
8We are continuosly working on test run stability, please email support@travis-ci.org if this error persists.
9
10Below is the stacktrace of the error:
@wvanbergen
wvanbergen / png_properties.rb
Created May 24, 2012
Extract properties from PNG file.
View png_properties.rb
require 'chunky_png'
filename = 'image.png'
img = ChunkyPNG::Datastream.from_file(filename)
# The header chunk contains the information you are looking for
p img.header_chunk
# => #<ChunkyPNG::Chunk::Header:0x007fb3858a50f8 @type="IHDR", @width=8, @height=8, @depth=8, @color=3, @compression=0, @filtering=0, @interlace=1>
puts img.header_chunk.depth # bit depth per color channel, e.g. 8 (i.e. 24 bits for RGB, 32 bits for RGBA)
@wvanbergen
wvanbergen / inventory_serials.rb
Created Nov 16, 2011
Get the computer and display serial numbers for your Mac
View inventory_serials.rb
require 'yaml'
data = YAML.load(`system_profiler SPHardwareDataType SPDisplaysDataType`)
puts "Computer serial number: " + data['Hardware']['Hardware Overview']['Serial Number (system)']
data['Graphics/Displays'].each do |video_card, properties|
if properties['Displays']
properties['Displays'].each do |display_name, properties|
puts "#{display_name}: #{properties['Display Serial Number']}" if display_name =~ /Cinema/
@wvanbergen
wvanbergen / message_verifier.coffee
Created Sep 15, 2011
MessageVerifier implementation for node.js
View message_verifier.coffee
crypto = require 'crypto'
MessageVerifier =
serializer: JSON.stringify
deserializer: JSON.parse
generate: (data, secret, algorithm) ->
algorithm ?= 'sha1'
base64 = (new Buffer(MessageVerifier.serializer(data))).toString('base64')
@wvanbergen
wvanbergen / transfer
Created Jul 28, 2011
Script to transfer a database table quickly without temporary files
View transfer
#!/bin/sh
# Modify the source and target variables, and run:
# $./transfer table_name
# Note that this will only run on the same machine as the target MySQL server machine.
SOURCE_MYSQL_HOST=
SOURCE_MYSQL_PORT=
SOURCE_MYSQL_USERNAME=
@wvanbergen
wvanbergen / shell session
Created Nov 29, 2010
Wasn't bundler supposed to resolve issues like these?
View shell session
$ bundle install
[ ... ]
Your bundle is complete! It was installed into /Users/willem/.rvm/gems/ruby-1.9.2-p0
$ rails s
/Users/willem/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:238:in `activate': can't activate i18n (~> 0.4.1, runtime) for ["mail-2.2.10", "actionmailer-3.0.3", "rails-3.0.3"], already activated i18n-0.5.0 for ["activemodel-3.0.3", "actionpack-3.0.3", "rails-3.0.3"] (Gem::LoadError)
from /Users/willem/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:254:in `block in activate'
from /Users/willem/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:253:in `each'
from /Users/willem/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:253:in `activate'
@wvanbergen
wvanbergen / Decoding speed
Created Oct 5, 2010
Chunky PNG performance: same benchmarks on Ruby 1.8.7, but added 'require "oily_png"' for a speed boost
View Decoding speed
---------------------------------------------
ChunkyPNG (0.10.2) decoding benchmark (n=20)
---------------------------------------------
ChunkyPNG OilyPNG
PNG - no filtering ( 1.056832) ( 0.078345)
PNG - UP filtering ( 3.327986) ( 0.078387)
PNG - PAETH filtering ( 7.499367) ( 0.089143)
From RGBA pixelstream ( 0.032571) ( 0.035790)
You can’t perform that action at this time.