Skip to content

Instantly share code, notes, and snippets.

View tonistiigi's full-sized avatar

Tõnis Tiigi tonistiigi

  • Docker
  • San Francisco
View GitHub Profile
@tonistiigi
tonistiigi / cook-smartos
Last active December 21, 2015 17:28
Simple chef-solo prepare+cook script for SmartOS NGZ(SmartMachine)
#!/bin/bash
# Simple cook script for Chef Solo on SmartOS NGZ
# Will prepare Chef-11.6.0 fat client and push cookbooks+attributes to node
# Based on fat client by @benr http://wiki.smartos.org/display/DOC/Using+Chef
function usage {
cat <<EOF
USAGE: $0 [opt] user@host [ssh-opt]
Options:
-r Path to recipes [./cookbooks]
@tonistiigi
tonistiigi / gist:6228869
Last active December 21, 2015 01:38
limejs dragging items out of the scroller example
// this method is called on mousedown/touchstart
// image is the target that got the event
/*
To deal with the scroller's own dragging motion you have to check the direction of the event:
e.swallow(['mousemove', 'touchmove'], function(e) {
e.release(['mousemove', 'touchmove']);
var offset = goog.math.Coordinate.difference(e.position, pos);
if (Math.abs(offset.y / offset.x) > .7) { // << magic number
TIME(ns) EVENT ID ID_NAME PARENT_ID EXTRAS
8443690085348 start 10603 metadata 2320
8443692427571 change 10603 zoneadm 2320
8443702940285 end 10603 zoneadm 2320
8444335982213 start 10604 bash 6405
8444337958029 change 10604 vmadm 6405
8444507216359 start 10605 vmadm 10604
8444509921186 change 10605 zonename 10604
8444518845118 end 10605 zonename 10604
8444531284421 start 10606 vmadm 10604
export BOXNAME=smartos01
export ISO=https://download.joyent.com/pub/iso/latest.iso
# Download iso
wget $ISO
# Create VM
VBoxManage createvm --name $BOXNAME --ostype OpenSolaris_64 --register
VBoxManage modifyvm $BOXNAME --memory 1024 --hwvirtex on --hwvirtexexcl off --nestedpaging on --largepages on --vtxvpid on --accelerate3d off --boot1 dvd --boot2 disk --acpi on
@tonistiigi
tonistiigi / gist:5484637
Created April 29, 2013 20:45
LimeJS Buttons inside scroller
// Answer for: https://groups.google.com/forum/?fromgroups=#!topic/limejs/ZcgYa72SvVk
var scroller = ..
scroller.moveHandler_ = function() {
lime.ui.Scroller.prototype.moveHandler_.apply(this, arguments)
scroller.hasMoved = true
}
scroller.upHandler_ = function() {
lime.ui.Scroller.prototype.upHandler_.apply(this, arguments)
@tonistiigi
tonistiigi / 2013-02-05 29190303b52 Initial
Last active December 13, 2015 20:49
redisparse benchmark results
redisparse node_redis node_redis_old hiredis
ping 190±5 219±7 15% 216±2 14% 537±5 183%
set_small_str 140±4 175±7 24% 170±2 21% 522±21 272%
get_small_str 981±24 100% 491±6 1168±41 138% 535±8 9%
get_small_buf 510±6 681±54 34% 816±57 60% 883±45 73%
get_large_str 4295±30 13% 3793±79 59200±188 1461% 3842±75 1%
get_large_buf 661±8 764±56 16% 56223±274 8406% 4294±3 550%
incr 229±5 264±8 15% 277±1 21% 490±9 114%
lpush 227±6 262±7 15% 267±0 18% 491±5 116%
lrange10 321±3 79% 256±5 43% 180±3 431±1 140%
@tonistiigi
tonistiigi / data.js
Created November 8, 2012 15:09
data replicate stream
/**
* Experimental data store test
* - Dynamic data, any JS object structure
* - All changes evented
* - Stream based replication/syncronization
* - Parts inspired by substack/emit-stream
* - Persistence can be done via dominictarr/kv
**/
var Stream = require('stream').Stream
@tonistiigi
tonistiigi / gist:3931858
Created October 22, 2012 14:51
Stylus compilation information exporter
var EventEmitter = require('events').EventEmitter;
/**
* Only works with https://github.com/tonistiigi/stylus/tree/sourcemaps
* Usage:
* var StylusInfo = require('./stylusinfo').StylusInfo;
* var logger = new StylusInfo();
* var options = ...
* options._info = logger;
* stylus(str, options).render(function(err, css) {
@tonistiigi
tonistiigi / gist:3476859
Created August 26, 2012 10:16
Moving Lime shapes with keyboard
//set main namespace
goog.provide('keycontrol');
/**
* Sample for using keyboard to naturally move around lime objects.
*/
//get requirements
goog.require('lime.Director');
goog.require('lime.Scene');