Skip to content

Instantly share code, notes, and snippets.

Avatar

Madis Nõmme madis

View GitHub Profile
View docker_findings.md

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
View counting_live_thread_objects.rb
#!/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 Aug 4, 2014
Parallels kernel patch
View kernel-patch.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 Mar 18, 2015
Ad-hoc mini WebRTC example
View ad_hoc_webrtc.js
getUserMedia({video: true, audio: true}, function(stream) {window.zeStream = stream}, function() {})
function makeLogger(message) {
return function(data) {
console.log(message, data)
}
}
function attachStream(event) {
View data_uri_to_blob.js
// 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 Jun 11, 2015
Firefox getUserMedia bug with quick consecutive calls
View getUserMediaBug.js
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 / bad_input.c
Created May 20, 2012
Secure programming homework
View bad_input.c
/**
* Secure programming HW4
* Find all potential vulnerabilities in this C function get_user_input
* Compiling: $ make main
* Running: $ ./main
*/
#include <stdio.h>
#include <stdlib.h> // For malloc
#include <string.h> // For strlen
@madis
madis / lets_install.sh
Created Sep 24, 2012
Lets install stuff automatically
View lets_install.sh
#!/bin/bash
echo Doing it now!
@madis
madis / gist:3781480
Created Sep 25, 2012
Konkreetne vs Abstraktne
View gist:3781480
Konkreetne							|	Abstraktne
====================================================
roheline							- värv
Clojure								- programmeerimiskeel
minu iPhone, praegusel ajahetkel 	- lihtsalt telefon
Juku								- loll
Programmeerija firmas X				- töökoht
View check_dependencies.sh
#!/bin/bash
echo "This script checks if you have all dependencies installed"
# Check for RVM
#RESULT= `type rvm | head -1`
RESULT="rvm is a function"
echo $RESULT
if [[ $RESULT = "rvm is a function" ]]; then
echo "RVM is OK"