Skip to content

Instantly share code, notes, and snippets.

View marcoshack's full-sized avatar

Marcos Hack marcoshack

View GitHub Profile
#!/usr/bin/env ruby
#
# Based on this post that also gives an example on how to verify the certificate:
# http://stackoverflow.com/questions/2507902/how-to-validate-ssl-certificate-chain-in-ruby-with-net-http
#
require 'net/http'
require 'openssl'
uri = URI('https://username:password@example.com/myresource')
@marcoshack
marcoshack / load_path.rb
Created August 9, 2016 15:53
Adding a directory to Ruby's $LOAD_PATH
$:.unshift File.expand_path(File.join(File.dirname(File.join(__FILE__)), '../lib'))
@marcoshack
marcoshack / extract_JavaForMacOSX10_5Update10.sh
Created October 15, 2012 17:35
Extract Java JDK 1.5 from JavaForMacOSX10.5Update10.dmg (original Apple distribution)
cd ~/Downloads
wget http://support.apple.com/downloads/DL1359/en_US/JavaForMacOSX10.5Update10.dmg \
-O ~/Downloads/JavaForMacOSX10.5Update10.dmg
hdiutil attach ~/Downloads/JavaForMacOSX10.5Update10.dmg
pkgutil --expand /Volumes/Java\ For\ Mac\ OS\ X\ 10.5\ Update\ 10/JavaForMacOSX10.5Update10.pkg \
~/Downloads/JavaForMacOSX10.5Update10
cd ~/Downloads/JavaForMacOSX10.5Update10/JavaForMacOSX10.5Update10.pkg/
@marcoshack
marcoshack / rpmmacros
Created December 2, 2010 13:08
Arquivo de configuração para criação de pacotes RPM
%_topdir %(echo ${HOME}/redhat)
%_tmppath %{_topdir}/tmp
%packager Marcos Hack <marcos.hack@abril.com.br>
@marcoshack
marcoshack / gist:579133
Created September 14, 2010 14:37 — forked from hbrandl/gist:547170
irbrc
#making .irbrc posted at http://www.tech-angels.fr/post/963080350/improve-irb-and-fix-it-on-mac-os-x
#work with rails3
require 'rubygems'
#rails3: be sure to include wirble and hirb in your Gemfile
require 'wirble'
require 'hirb'
Wirble.init
Wirble.colorize
# hirb (active record output format in table)
@marcoshack
marcoshack / findclass
Created July 13, 2010 20:39
Find Java class (bash script)
#!/bin/bash
CLASS_NAME=$1
if [[ $CLASS_NAME == "" ]]; then
echo -e "\nUsage: $0 CLASS_NAME\n"
exit 1
fi
for i in `find . -name *.jar`; do
@marcoshack
marcoshack / mvn deploy:deploy-file
Created April 1, 2010 00:58
Maven2: add artifact to local repository
mvn deploy:deploy-file \
-DgroupId=<JAR_GROUP> \
-DartifactId=<JAR_NAME> \
-Dversion=<JAR_VERSION> \
-Dpackaging=jar \
-Dfile=</path/to/file>
@marcoshack
marcoshack / rakefile
Created October 2, 2009 20:18
Simple usage example of Rake::TestTask
require 'rake/testtask'
task :default => [:test]
task :test do
Rake::TestTask.new do |t|
t.libs << "test"
t.options = "-v"
t.test_files = FileList['test/tc*.rb']
t.verbose = true
@marcoshack
marcoshack / gist:117760
Created May 25, 2009 21:21 — forked from dje/gist:72840
AWS EC2 snapshot
#! /usr/bin/env ruby
=begin
backshot.rb is a Ruby program driving
Amazon EBS <http://aws.amazon.com/ebs/>
to generate snapshots for backup purposes.
Hourly, daily, weekly, and monthly snapshots
are generated by default.
@marcoshack
marcoshack / FileReader.java
Created February 5, 2009 20:08
File reading in Java
/**
* Read a file line by line in Java using FileReader and BufferedReader.
* @author Marcos Hack <marcoshack@gmail.com>
*/
public class FileReader {
String fileName = "/path/to/your/file";
try {
fileReader = new FileReader(fileName);
bufferedReader = new BufferedReader(fileReader);