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 / INSTALL.txt
Created January 28, 2009 12:01
lighthouse-github integration
# Assuming you're on Ubuntu or OSX
#
GIT=$(dirname `which git`)
sudo install -m 755 git-lh.rb $GIT/git-lh
sudo install -m 755 git-lh-push.sh $GIT/git-lh-push
@vjt
vjt / README.md
Last active November 25, 2020 18:45
[POC] Temporal database system on PostgreSQL with Active Record in mind

This has become a Ruby gem: https://github.com/ifad/chronomodel

A temporal database system on PostgreSQL using table inheritance and the rule system.

This is a data structure for a Slowly-Changing Dimension Type 2 temporal database, implemented using only PostgreSQL >= 9.0 features.

Any application code is completely unaware of the temporal features: queries are done against a view that behaves exactly like a plain table (it can be SELECTed, UPDATEd, INSERTed INTO and DELETEd FROM), but behind the scenes the database redirects the queries to backend tables holding actual data, using the PostgreSQL rule system.

// Simple tabs implementation that requires the same markup as jQuery UI Tabs, but doesn't modify your
// markup or impose an horizontal layout of tabs. You're on your own setting up CSS, of course. Sample
// markup:
//
// <div id="tabs">
// <ul>
// <li><a href="#group-1">group 1</a></li>
// <li><a href="#group-2">group 2</a></li>
// </ul>
// <div id="group-1"></div>
@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 / passwdgen.js
Created March 29, 2012 16:52
Javascript Random Password Generator (jQuery)
// Demo: http://jsbin.com/emisib/5/edit#preview
//
// Markup:
//
// <input type="text" name="password" id="password" />
// <a href="#" class="passworder" data-length="10" data-target="#password">Generate</a>
//
// - vjt@openssl.it - public domain
//
(function () {
[user]
email = vjt@openssl.it # CHANGE THIS
name = Marcello Barnaba # CHANGE THIS
signingkey = 9956EB3C8D2787EF # CHANGE THIS
[core]
whitespace=fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile=~/.gitignore
[apply]
ignorewhitespace=change
whitespace=fix
@vjt
vjt / build-gnuradio.sh
Created September 1, 2012 06:38
GnuRadio build script w/ UHD, rtl-sdr, and gr-extras.
#!/bin/bash
#
# Taken from http://www.sbrac.org/files/build-gnuradio
#
# Build script for UHD+GnuRadio on Fedora and Ubuntu
#
# Updates: https://github.com/guruofquality/grextras/wiki
# Updates: https://github.com/balint256/gr-baz.git
#
#
@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 / 1-session.sh
Last active June 5, 2018 12:31
vjt's tmux RVM + ViM IDE setup
#!/bin/sh
#
# IDE Session starter - you should save this script as ~/bin/session, make it
# executable with chmod +x ~/bin/session, and then make a symlink to it for
# every application you want to start.
# E.g. ln -s session ~/bin/members creates a "members" symlink, and when you'll issue
# "members" on the command line this script will:
# Check if a tmux session named "members" exists
@vjt
vjt / parse-word-structure.rb
Created November 19, 2011 12:21
Parse a Word OpenXML document file with a predefined structure
#!/usr/bin/env ruby
require 'nokogiri'
require 'zip/zipfilesystem'
file = ARGV[0] or abort("Usage: #$PROGRAM_NAME <file.docx>")
Zip::ZipFile.open(file) do |zip|
doc = Nokogiri::XML(zip.file.read('word/document.xml'))