Skip to content

Instantly share code, notes, and snippets.

View madis's full-sized avatar
🧑‍💻
code mode

Madis Nõmme madis

🧑‍💻
code mode
View GitHub Profile
@madis
madis / gist:7689035
Created November 28, 2013 08:59
Installing geoip-c gem when you get the "extconf.rb failed" error with Ruby 2
env LDFLAGS=-L/usr/local/Cellar/geoip/1.5.1/lib CFLAGS=-I/usr/local/Cellar/geoip/1.5.1/include gem install geoip-c
@madis
madis / fruits.rb
Created January 2, 2014 17:56
Tutti frutti
require 'delegate'
require 'securerandom'
# Demo solution for Stenver's refactoring problem
class Fruit
attr_accessor :description, :weight
def initialize(description, weight)
@description = description
@madis
madis / docker_findings.md
Created May 7, 2014 09:31
Docker findings

Gettings started with OS X, Vagrant & VirtualBox

  1. Create empty box with veewee You should have newest VirtualBox & Vagrant installed.
gem install veewee
veewee vbox define 'ubuntu-14.04-server' 'ubuntu-14.04-server-amd64' --workdir=/Users/madis/infra/veewee
# Change your box (e.g. add memory, it has 512MB by default)
veewee vbox build 'ubuntu-14.04-server' --workdir=/Users/madis/infra/veewee
#!/usr/bin/env ruby
require 'ruby-mass' # gem install ruby-mass
NUMBER_OF_RUNS = 30
# No OOP in here :) Just some small snippets for measuring show Ruby's GC
# collects finished Thread objects. A question that popped up at Fortumo
# party.
def report_object_count
@madis
madis / kernel-patch.patch
Created August 4, 2014 07:53
Parallels kernel patch
diff -Nru prl_fs.orig/SharedFolders/Guest/Linux/prl_fs/inode.c prl_fs/SharedFolders/Guest/Linux/prl_fs/inode.c
--- prl_fs.orig/SharedFolders/Guest/Linux/prl_fs/inode.c 2013-11-11 17:56:58.000000000 +0200
+++ prl_fs/SharedFolders/Guest/Linux/prl_fs/inode.c 2013-11-29 20:41:53.689167040 +0200
@@ -199,10 +199,18 @@
if (attr->valid & _PATTR_MODE)
inode->i_mode = (inode->i_mode & S_IFMT) | (attr->mode & 0777);
if ((attr->valid & _PATTR_UID) &&
- (sbi->plain || sbi->share || attr->uid == -1))
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
+ (sbi->plain || sbi->share || __kuid_val(attr->uid) == -1))
@madis
madis / ad_hoc_webrtc.js
Created March 18, 2015 09:17
Ad-hoc mini WebRTC example
getUserMedia({video: true, audio: true}, function(stream) {window.zeStream = stream}, function() {})
function makeLogger(message) {
return function(data) {
console.log(message, data)
}
}
function attachStream(event) {
@madis
madis / data_uri_to_blob.js
Created May 14, 2015 08:26
Data URI to Blob
// From http://stackoverflow.com/questions/6850276/how-to-convert-dataurl-to-file-object-in-javascript
function dataURItoBlob(dataURI) {
if(typeof dataURI !== 'string'){
throw new Error('Invalid argument: dataURI must be a string');
}
dataURI = dataURI.split(',');
var type = dataURI[0].split(':')[1].split(';')[0],
byteString = atob(dataURI[1]),
byteStringLength = byteString.length,
arrayBuffer = new ArrayBuffer(byteStringLength),
@madis
madis / getUserMediaBug.js
Created June 11, 2015 17:06
Firefox getUserMedia bug with quick consecutive calls
navigator.mozGetUserMedia({video: true, audio: false}, function(s) {window.zeVideoOnly = s}, function() {}); navigator.mozGetUserMedia({video: true, audio: true}, function(s) {window.zeVideo = s}, function() {})
@madis
madis / gist:f07bf068e6b7fc5be7cc
Created June 29, 2015 08:05
Remove all docker images
docker images | tail -n+2 | awk '{print $3}' | xargs -L1 docker rmi
Settings