Skip to content

Instantly share code, notes, and snippets.

View c4urself's full-sized avatar

Christian Verkerk c4urself

  • Tubular Labs
  • Mountain View
View GitHub Profile

strace up to 1kb with -f to follow children

strace -s 1024 -f <cmd>

@c4urself
c4urself / subprocess_capture_stderr.py
Last active February 23, 2016 05:20
Test out subprocess
import subprocess
# http://stackoverflow.com/questions/18774476/subprocess-call-logger-info-and-error-for-stdout-and-stderr-respectively
# http://stackoverflow.com/questions/21953835/run-subprocess-and-print-output-to-logging
def my_buddy_popen():
"""
Since only stderr is bound, we only get a value for stderr. if this was a good call (exit 0)
then out _would_ exist and sent to parent's and _not_ be in `out`.
package main
import (
"os"
)
func main() {
w := os.Args[1]
print(string(w[0]))
print(len(w))
println(string(w[len(w) - 1]))
@c4urself
c4urself / ui_install_guide.sh
Last active December 14, 2015 09:50
UI Install steps
# Current version: 0.8.4
scp beehive:~jeremy/nimbula-ui/nimbula-ui-X.X.X.zip
unzip nimbula-ui-X.X.X.zip
cd nimbula-ui
./nimbula-ui-installer.py -ahttps://api.usdev290.nimbula -u/root/root
# Visit https://10.33.19.10 ... replace with your IP
@c4urself
c4urself / simple_logging.js
Last active December 13, 2015 19:38
Simple logging utility for JS, takes IE's lack of console into account as well as difference in browser abilities with regard to console.info, console.warn and console.error.
app = {
DEBUG: true,
VERSION: '1.0.0'
};
app.logs = app.logs || { info: [], error: [], warn: [] };
app.logger = app.logger || {
log: function () {
var type = arguments[0],
msg = arguments[1],
na.iconCreator = function (x, y, width, height, iconName, hoverTitle, sstr) {
var p = this.properties,
dim = this.wrapper.getBBox(),
wx = _.isFunction(x) ? x(dim) : x, wy = _.isFunction(y) ? y(dim) : y,
r = this.paper.rect(wx, wy, width, height),
i = this.paper.path(na.icons[iconName]);
set = this.paper.set();
tstr = (sstr || 'S0.05,0.05,0,0') + 'T' + wx + ',' + wy;
// This is a hack to get all icons doing the same thing
@c4urself
c4urself / raphael_svg_fix.js
Last active December 10, 2015 22:08
A function that moves a path -- has the nice side-effect of making SVG paths with different starting points behave the same way.
/**
* Move path method // hack for getting all svg icons
* working the same way
*/
var movePath = function (x, y) {
var path = Raphael.pathToRelative(this.attrs.path),
dim = Raphael.pathBBox(this.attrs.path),
dx = (path[0][1] - dim.x) + (x * 100),
dy = (path[0][2] - dim.y) + (y * 100);
path[0][1] = dx;
@c4urself
c4urself / reference_by_value.js
Last active December 10, 2015 19:58
Javascript (mainly) pass-by-value
// More explicit example of
// http://stackoverflow.com/questions/518000/is-javascript-a-pass-by-reference-or-pass-by-value-language
//
// When you change the `item` property of the object referenced by `obj1`, you are changing the value
// of the `item` property that was originally set to 'unchanged'. When you assign `obj2` a value of
// {item: 'changed'} you are changing the reference to a new object. This object immediately goes out
// of scope when the function exits.
function changeStuff(_num, _obj1, _obj2) {
_num = _num * 10;
@c4urself
c4urself / mocha_jslint_happy.js
Created January 3, 2013 18:17
Chai doesn't play nice with JS Lint's check for incorrect use of `false` and `true` -- a setting that cannot be turned off via JS Lint options. The addition of `_true` and `_false` properties to Chai fixes this making JS Lint work correctly.
// We're providing some convenience functions here as well as making sure
// chai tests don't fall on jshint errors by remapping true/false properties
chai.Assertion.addProperty('_true', function () {
this.assert(
true === this.__flags.object,
'expected #{this} to be true',
'expected #{this} to be false',
this.negate ? false : true
);
});
@c4urself
c4urself / jira_importer.rb
Created December 28, 2012 22:43
GitHub to Jira importer
require 'octokit'
require 'csv'
require 'date'
# Description:
# Exports Github issues from one or more repos into CSV file formatted for import into JIRA
# Note: By default, all Github comments will be assigned to the JIRA admin, appended with
# a note indicating the Github user who added the comment (since you may not have JIRA users
# created for all your Github users, especially if it is a public/open-source project:
#