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 / 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 / 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))
#!/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 / 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
@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 / 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 / for_1.9.3.c
Last active December 23, 2015 12:19
Compiling geoip-c for ruby 2.0.0 vs 1.9.3 mkmf error
// Compile with:
// export RUBY_DIR=$HOME/.rvm/rubies/ruby-1.9.3-p448
// gcc-4.6 -o for_1.9.3 -I$RUBY_DIR/include/ruby-1.9.1/x86_64-darwin12.4.1 -I$RUBY_DIR/include/ruby-1.9.1/ruby/backward -I$RUBY_DIR/include/ruby-1.9.1 -Iext/geoip -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fno-common -pipe for_1.9.3.c -L. -L$RUBY_DIR/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -liconv -lruby.1.9.1 -lGeoIP -liconv -lpthread -ldl -lobjc
#include "ruby.h"
int t() { GeoIP_record_by_ipnum(); return 0
@madis
madis / option_arrow_bash.md
Last active July 18, 2016 12:21
Use [option] + [arrow] on OS X iterm2 to move and delete by word
  1. in ~/.inputrc:
"\M-d": backward-kill-word
"\e[1;5C": forward-word
"\e[1;5D": backward-word
  1. iTerm2 preferences: Profiles -> Keys
@madis
madis / postgres_setup.md
Last active December 21, 2015 03:18
OS X installing postgres. Setting up postgres roles and database
# Install postgres
brew install postgres

# Create folder for logs
mkdir -p /usr/local/var/postgres/

# Set permissions
chmod 700 /usr/local/var/postgres
@madis
madis / useful_ruby_rails_snippets.rb
Created August 4, 2013 11:09
Useful Ruby & Rails snippets
# Running only fast tests on command line
`zeus test -t ~slow spec`
# Getting the profiling information for RSpec runs
`echo "--profile">> .rspec`