Skip to content

Instantly share code, notes, and snippets.

View vjt's full-sized avatar
💭
looking at the stars

Marcello Barnaba vjt

💭
looking at the stars
View GitHub Profile
@vjt
vjt / fontawesome-custom.eot
Last active December 28, 2015 03:38
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 http://stackoverflow.com/a/12459447/80969 ... Internet Explorer, as usual, is the crappiest crap of all craps.
@vjt
vjt / couchdb-undelete.rb
Last active December 24, 2019 07:04
Undeletes a document from a CouchDB database.
#!/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",
@vjt
vjt / extract_sproc.sh
Last active December 19, 2015 07:48
Extract a stored procedure's text off a Sybase database from the command line. Required tools: sqsh, GNU sed
#!/bin/sh
#
# Poor man's defncopy implementation in Bourne Shell.
#
# Usage: ./extract_sproc.sh <sproc> <sqsh_options>
#
# Example: ./extract_sproc.sh foobar -S SERVER -U USER -P PASS -D DATABASE
#
# Description: Uses sqsh to invoke Sybase's sp_helptext that fetch a sproc
# definition from the system tables. Uses the "csv" output, that preserves
@vjt
vjt / .gitconfig
Created June 19, 2013 12:41
My .gitconfig
[user]
email = vjt@openssl.it
name = Marcello Barnaba
[core]
whitespace=fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile=~/.gitignore
[apply]
ignorewhitespace=change
whitespace=fix
[color]
@vjt
vjt / wsus-cleanup.ps1
Created June 12, 2013 23:30
WSUS Cleanup Script that logs to the Windows Event Log
# Performs a cleanup of WSUS and writes to a custom "WSUS Cleanup" log
# You must create the Event Log using
#
# New-EventLog -LogName "WSUS Cleanup" -Source "Script"
#
# the first time you run this script.
# PowerShell 2.0 required.
#
# - vjt@openssl.it (feeling dirty)
#
@vjt
vjt / copy-from-time-machine.sh
Last active March 8, 2024 17:05
Copy data from a Time Machine volume mounted on a Linux box.
#!/bin/bash
#
# Copy data from a Time Machine volume mounted on a Linux box.
#
# Usage: copy-from-time-machine.sh <source> <target>
#
# source: the source directory inside a time machine backup
# target: the target directory in which to copy the reconstructed
# directory trees. Created if it does not exists.
#
@vjt
vjt / schema_format.rake
Last active July 20, 2018 16:48
Rails SQL schema load support for PostgreSQL. Put both files in `lib/tasks`.
import File.expand_path(File.dirname(__FILE__) + '/schema_format.rb')
namespace :db do
# Define PG environment utility methods
task :pg_env => :environment do
def pg_get_config
ActiveRecord::Base.configurations.fetch(Rails.env).tap do |config|
ENV['PGHOST'] = config['host'].to_s if config.key?('host')
ENV['PGPORT'] = config['port'].to_s if config.key?('port')
ENV['PGPASSWORD'] = config['password'].to_s if config.key?('password')
@vjt
vjt / couchdb-compact.rb
Last active December 10, 2015 19:48
CouchDB database and views compaction script. Save in /usr/local/bin and cron it. Protip: https://coderwall.com/p/q-sjhw
#!/usr/bin/env ruby
# CouchDB compaction script - fetches the list of all databases from
# a running couchdb instance and issues the compaction command for each
# one of them, and for each design view into them.
# Read more about compaction here:
# http://wiki.apache.org/couchdb/Compaction
# - m.barnaba@ifad.org Wed Nov 30 18:19:27 CET 2011
@vjt
vjt / libreoffice.sh
Created December 3, 2012 12:34
Libreoffice LSB init script
#!/bin/sh
#
# Startup Script for the LibreOffice server. Save it into /etc/init.d/libreoffice
# and install it using `insserv /etc/init.d/libreoffice`.
#
# Copyright (C) 2012 Marcello Barnaba <vjt@openssl.it>
#
# LSB compatible service control script; see http://www.linuxbase.org/spec/
#
### BEGIN INIT INFO
@vjt
vjt / list-my-open-sockets.sh
Created November 20, 2012 18:19
Lists all open IPv4 sockets allocated by the current user's running processes whose command line matches the regex passed as the first parameter.
#!/bin/sh
#
# Lists all open IPv4 sockets allocated by the current user's
# running processes whose command line matches the regex passed
# as the first parameter. Uses "unicorn.*worker" by default -
# because we all love unicorns! :-)
#
# - vjt@openssl.it Tue Nov 20 19:06:08 CET 2012
#