Skip to content

Instantly share code, notes, and snippets.

Avatar

Ori Tzoran otzoran

  • Israel
View GitHub Profile
@otzoran
otzoran / json2yaml.md
Last active Oct 17, 2017
json2yaml and yaml2json oneliners using ruby
View json2yaml.md

Add to bashrc

alias yaml2json="ruby -ryaml -rjson -e 'puts JSON.pretty_generate(YAML.load(ARGF))'"
alias json2yaml="ruby -ryaml -rjson -e 'puts YAML.dump(JSON.parse(STDIN.read))'"

WIIG4

take a horrible json (such as packer template), convert it to yaml, edit it (vi, sed, awk) and convert back

side dish

@otzoran
otzoran / vbox_NS_ERROR_FAILURE_resolve.md
Created Jul 25, 2017
virtualbox VM in Saved state fail start with NS_ERROR_FAILURE machinewrap
View vbox_NS_ERROR_FAILURE_resolve.md

Problem

macOS Sierra 10.12.5
VBoxManage --version = 5.1.24r117012
Win VM paused, mac => sleep; on wakeup attaempt to rev the VM yields error:
The virtual machine '[name]' has terminated unexpectedly during startup because of signal 6.
NS_ERROR_FAILURE (0x80004005)

Googling

@otzoran
otzoran / snuppet.sh
Created Jan 12, 2016
pbcopy/paste on Linux
View snuppet.sh
# pbcopy (on Mac OS), copies stdin to the X clipboard, the aliases created here simulate that.
# need the 'xsel' package
if [[ $(uname -s) == "Linux" && -x /usr/bin/xsel ]]; then
alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'
fi
@otzoran
otzoran / Replace_Unity_by_MATE.md
Created Aug 9, 2015
Ubuntu: Replace Unity by MATE
@otzoran
otzoran / virtualbox_prereq_guest_additions.md
Last active Aug 29, 2015
Installing Guest Additions on Debian Ubuntu Mint etc.
View virtualbox_prereq_guest_additions.md

Installing Guest Additions on Debian

Follow these steps to install the Guest Additions on your Debian virtual machine:

sudo -i
apt-get update && apt-get upgrade
apt-get install build-essential module-assistant
# Configure your system for building kernel modules by running:
m-a prepare
@otzoran
otzoran / env_ec2.sh
Created Aug 6, 2015
env file for Mac, brew to work with EC2
View env_ec2.sh
# vim: set filetype=sh :
# Purpose
# set environment variables for EC2_URL EC2_HOME JAVA_HOME CLASSPATH
# required by ec2-api-tools, used by other tools (e.g. vagrant)
# Usage:
# source this
# create local env.monsoon in a project's subdir defining:
# export AWS_PROJECT="MOCONS / rmjen"
@otzoran
otzoran / check bash interactive.md
Last active Aug 29, 2015
Check if bash shell is interactive
View check bash interactive.md

The old way

if tty -s; then
  echo "interactive"
fi

Cons

This method does the job, but invloves process invocation (fork/exec) of tty, which is expensive in terms of performance.
But there's a worse side-effect:
If PATH is empty or wrong, calling tty will fail. When sourced for a login shell,

@otzoran
otzoran / ntp_iix.md
Last active Aug 26, 2016
NTP Server Israel
View ntp_iix.md

NTP Server Israel

source: isoc-il

timeserver.iix.net.il   # 192.114.62.250 stratum-2
@otzoran
otzoran / truecrypt_fix.bash
Last active Aug 29, 2015 — forked from yiufung/truecrypt_fix.bash
Fixes annoying brew doctor messages caused by Truecrypt - tested on Yosemite
View truecrypt_fix.bash
#!/usr/bin/env bash
# Author: Ori Tzoran, based on idea and gist by aaronzirbes (see evolution below)
# Tested on Mac OS X 10.10.2 (14C109)
set -e
## verify root runs this
[[ $(id -u) == 0 ]] || { echo need root; exit 1; }
#set -vx
@otzoran
otzoran / chrome-install.sh
Created Aug 31, 2014
Chrome Installation on Ubu - script steps - tested on 14.04
View chrome-install.sh
#!/bin/bash
set -ex
[[ $(id -u) == 0 ]] || { echo "Buddy needs to be root to run this"; exit 1; }
[[ $PWD == "/root" ]] || { echo "Run this from /root"; exit 1; }
# 1. Download key
wget -q -O google_signing_key.pub https://dl-ssl.google.com/linux/linux_signing_key.pub
apt-key add google_signing_key.pub
You can’t perform that action at this time.