Skip to content

Instantly share code, notes, and snippets.

@zambon
zambon / database.sql
Created May 12, 2011 18:21
App Inventor/DB2 integration
$ create db APPINV
$ connect to APPINV
$ create table DATA (KEY varchar(250), VALUE varchar(250))
@zambon
zambon / email_format_validator.rb
Created September 14, 2012 15:38
EmailFormatValidator
class EmailFormatValidator < ActiveModel::EachValidator
def validate_each record, attribute, value
begin
email = Mail::Address.new value
# We must check that value contains a domain and that value is an email address
result = email.domain && email.address == value
tree = email.__send__ :tree
# We need to dig into treetop
# A valid domain must have dot_atom_text elements size > 1
# user@localhost is excluded
@zambon
zambon / gist:3802160
Created September 28, 2012 21:26 — forked from mmassaki/gist:3763257
Ruby debugger hack
puts "Start typing away."
while (line = STDIN.readline).strip != ""
puts eval(line)
end
@zambon
zambon / Gemfile
Created October 14, 2012 02:14 — forked from veesahni/Gemfile
Integrating Padrino w/ Mongoid & delayed_job on Heroku
gem 'delayed_job'
gem 'delayed_job_mongoid'
gem 'thin'
gem 'heroku'
@zambon
zambon / gist:6886984
Created October 8, 2013 15:59
How to connect to a DB2 database using the Ruby gem ibm_db
require 'ibm_db'
database = ''
host = ''
port = ''
username = ''
password = ''
conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=#{database};HOSTNAME=#{host};PORT=#{port};PROTOCOL=TCPIP;UID=#{username};PWD=#{password};"
@zambon
zambon / TestExec.java
Last active August 29, 2015 13:56
Finding an arbitrary user's home directory in Linux/UNIX
import java.io.*;
public class TestExec {
public static void main(String[] args) {
try {
// Replace 'username' with the actual username
String[] cmd = {"/bin/sh", "-c", "echo ~username"};
Process p = Runtime.getRuntime().exec(cmd);
Fonte: http://gohorseprocess.wordpress.com
1- Pensou, não é XGH.
XGH não pensa, faz a primeira coisa que vem à mente. Não existe
segunda opção, a única opção é a mais rápida.
2- Existem 3 formas de se resolver um problema, a correta, a errada e
a XGH, que é igual à errada, só que mais rápida.
#
# The BootstrapBreadcrumbsBuilder is a Bootstrap compatible breadcrumb builder.
# It provides basic functionalities to render a breadcrumb navigation according
# to Bootstrap's conventions.
#
# You can use it with the :builder option on render_breadcrumbs:
# <%= render_breadcrumbs builder: ::BootstrapBreadcrumbsBuilder %>
#
# Note: You may need to adjust the autoload_paths in your config/application.rb
# file for rails to load this class:
@zambon
zambon / config.ru
Last active August 29, 2015 13:57
Geminabox on WEBrick with SSL encryption.
require "rubygems"
require "webrick"
require "webrick/https"
require "geminabox"
# Set Geminabox' data directory
Geminabox.data = "path/to/data"
# Helpers for basic authentication
Geminabox::Server.helpers do
0 - Additional Products
707 - 600 GB iSCSI SAN Snapshot Space
4426 - Citrix NetScaler VPX 10.1 200Mbps Platinum
4513 - Dedicated Load Balancer with High Availability and SSL - 150,000 Connections
4612 - 6500 GB iSCSI SAN Replication
4184 - 750GB EVault Disk to Disk Enterprise Backup
4427 - Citrix NetScaler VPX 10.1 200Mbps Standard
902 - CDN Pay as You Go Storage
4028 - .com - 9 year
703 - 350 GB iSCSI SAN Snapshot Space