Skip to content

Instantly share code, notes, and snippets.

View giulioungaretti's full-sized avatar
💭
😘

Giulio Ungaretti giulioungaretti

💭
😘
View GitHub Profile
@giulioungaretti
giulioungaretti / gist:bf267f9f48fff056bcda
Last active August 26, 2015 15:02 — forked from wacko/gist:5577187
SSH between Mac OS X host and Virtual Box guest

On Mac OS (host):

Shutdown your VM and do:

VirtualBox > Settings > Network > Add (you will get vboxnet0)

On a terminal ifconfig will show you new interface vboxnet0

VM's Settings > System > check "Enable I/O APIC." VM's Settings > Network > Adapter 2 > host-only vboxnet0

@giulioungaretti
giulioungaretti / Makefile
Last active August 28, 2015 12:09 — forked from nhunzaker/Makefile
Access LMU light sensor on Mac. Also includes the Emacs plugin I use for automatically updating my theme according to ambient light.
all:
gcc light.m -std=c99 -framework Foundation -framework IOKit -o light
clean:
rm -f light
@giulioungaretti
giulioungaretti / 0_reuse_code.js
Created April 3, 2014 15:14
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@giulioungaretti
giulioungaretti / log-parser.py
Created April 3, 2014 15:16
Elionix log parser draft
{
"metadata": {
"name": "",
"signature": "sha256:692e999516bfd9f1fc18481fa2f8e6825be88a36173115c4a1cc8df7c1eb04e8"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
func maybe_string_to_int(in_value interface{}) (int, bool) {
switch t := in_value.(type) {
case string:
out_value, err := in_value.(int)
return out_value, err
case int, int32, int64:
out_value, err := in_value.(int)
return out_value, err
default:
func nuke(key string, in_data map[string]interface{}) error {
var err error
_, has_key := in_data[key]
if has_key == false {
err = fmt.Errorf("map does not have the requested key")
} else {
delete(in_data, key)
err = nil
}
return err
error:2015/01/06 16:16:16 main.go:24: timestamp can't be empty, for line >>{"uuid":"00ht4rh58fvn8gf3yq1hx42bl5licj8m","is_dealer_admin":false,"is_archive_user":false,"ai ana asdfadlskfjas; this is shit tkdsajglksadjgasldgjakls jgalskdjgladskjgsdalkjljklj
error:2015/01/06 16:16:16 main.go:24: timestamp can't be empty, for line >>gskdglja
error:2015/01/06 16:16:16 main.go:24: timestamp can't be empty, for line >>lkadgdas|{}{]":) ?:""} pp":120,"api_app_version":"0.1.14","api":"2.0.0","api_env":"production","ip":1586511713,"remote_addr":"94.144.63.97","server_ip":167798109,"server_addr":"10.0.101.93","user_agent":"Mozilla\/5.0 (Windows NT 6.3; WOW64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/33.0.1750.154 Safari\/537.36","query_string":"r_lat=55.667&r_lng=12.583&r_radius=100000&r_sensor=false&api_av=0.1.14","scope":"catalog","action":"download","timestampMs":1396205666925,"timestamp":1396205667,"catalog":"8618","dealer":"5"}
error:2015/01/06 16:16:16 main.go:24: timestamp can't be empty, for line >>{"uuid"
{
"metadata": {
"name": "",
"signature": "sha256:af408a93b8f53cb53d14d0b0af1021e673268a0fff4faab8ef0e7045eaa4e5c1"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@giulioungaretti
giulioungaretti / vim74_lua
Last active August 29, 2015 14:16 — forked from jdewit/vim74_lua
vimubuntulua
sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-common vim-gui-common
sudo apt-get build-dep vim
sudo apt-get install liblua5.1-dev luajit libluajit-5.1 python-dev ruby-dev libperl-dev mercurial libncurses5-dev
sudo rm -rf /usr/local/share/vim
sudo rm /usr/bin/vim
sudo mkdir /usr/include/lua5.1/include
gzcat 2015-02-01.json.log.gz | jq -c '[.timestamp, .]' >> json.log && sort -t "," -k1 json.log | cut -d "," -f 2- | cut -d "]" -f 1 >> clean.json