Skip to content

Instantly share code, notes, and snippets.

looking at the stars

Marcello Barnaba vjt

looking at the stars
View GitHub Profile
vjt /
Created Aug 12, 2020
Painless scripting language literal newline character
vjt /
Created Aug 5, 2020
tcpdump on remote host

Running tcpdump on remote hosts with no storage

If you have tcpdump on your embedded home router and you want to see what traffic your crippled phone is doing, you can dump traffic on the router and visualise it on your main workstation using wireshark.

  1. On the remote host, create a FIFO
remotehost# mkfifo /tmp/tcpdump
View .gitconfig
email = # CHANGE THIS
name = Marcello Barnaba # CHANGE THIS
signingkey = 9956EB3C8D2787EF # CHANGE THIS
vjt / 2fa
Last active Apr 16, 2020
2FA from the mac command line using oathtool-toolkit without much fuss
View 2fa
# -*- 2fa Command Line -*-
# Uses oath-toolkit
# to generate 2FA OTPs and copies them in the Mac's
# clipboard using pbcopy(1). For other UNIX systems
# you can just strip the pbcopy at the bottom.
# In the dir below you should put TOTP token seeds,
View webseal-log-reader.rb
# Parses IBM ISAM's WebSeal (broken) XML logs and outputs a line-based
# version of them extracting the most relevant information required to
# analyse who is requesting HTTP resources, from where and when.
# - Tue May 30 15:51:28 CEST 2017
require 'nokogiri'
require 'time'
def openlog
vjt /
Created Dec 15, 2014
keybase authz

Keybase proof

I hereby claim:

  • I am vjt on github.
  • I am vjt ( on keybase.
  • I have a public key whose fingerprint is 723C 7CA3 3C19 2ACE 6E20 9CC1 9956 EB3C 8D27 87EF

To claim this, I am signing this object:


Welcome in many languages (in JSON format)

Today I wanted to implement a multi-language greeter for an application, and I ended up on

I extracted all the welcomes from the page using jQuery, serialized them as JSON and processed them using Ruby:

welcomes = x.inject({}) {|h, (lang, val)| val.gsub!(/\(.*?\)/, ''); vals = val.split(%r{\s+/\s+|\n});! {|val| val.strip!; val.gsub!(/^\w+ -\s+|- \w+$|^lit.*|>.+$/, ''); val.strip!; val}; vals.flatten!; vals.reject!(&:blank?);; h.update(lang => vals) }
vjt / chronomodel-fix-db-issue-23.rb
Last active Aug 29, 2015
Database fix for wrongly generated ChronoModel constraints (issue #23).
View chronomodel-fix-db-issue-23.rb
# Fixes wrong database structure created by ChronoModel's issue #23
# Download this file in your app root:
# curl -O
# Run it:
vjt / fontawesome-custom.eot
Last active Dec 28, 2015
FontAwesome.EOT that works with IE8, as it has Fontname, Family Name and Name for Humans all set to the same "FontAwesome" value. Refer to ... Internet Explorer, as usual, is the crappiest crap of all craps.
vjt / couchdb-undelete.rb
Last active Dec 24, 2019
Undeletes a document from a CouchDB database.
View couchdb-undelete.rb
#!/usr/bin/env ruby
# Undelete a document from a CouchDB database.
# Recovers a previously deleted document by looking at the _changes
# feed, putting a new empty document preserving the revisions chain,
# retrieves the revs_info for the document, asks the user which one
# to recover, and puts back the old revision into place.
# For this to work, GETting the document must return error: "not_found",
You can’t perform that action at this time.