Skip to content

Instantly share code, notes, and snippets.

View timoteoponce's full-sized avatar

Timoteo Ponce timoteoponce

View GitHub Profile
@timoteoponce
timoteoponce / gist:671113
Created November 10, 2010 16:50
BaseFactory.java
package org.uagrm.addressbook.util;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
/**
* Generic factory cache component, which binds an specific class definition
* with a class instance. It provides caching and creation facilities. Note: All
* bind classes should use classes(Boolean) as constructor parameters, native
package org.timo.gitconfig;
import java.io.IOException;
import java.util.logging.Logger;
public class GitConfigurationExample {
private static final Logger LOG = Logger
.getLogger(GitConfigurationExample.class.getName());
@timoteoponce
timoteoponce / gist:676291
Created November 15, 2010 01:10
example-gitconfig
#
# This is the config file, and
# a '#' or ';' character indicates
# a comment
#
; core variables
[core]
; Don't trust file modes
filemode = false
@timoteoponce
timoteoponce / TestPaginator.java
Created July 15, 2011 18:29
Paginator usage example
import java.util.Arrays;
import java.util.List;
import java.util.logging.Logger;
import org.timo.paginator.ListProvider;
import org.timo.paginator.Paginator;
import org.timo.paginator.Segment;
import org.timo.paginator.SegmentProvider;
/**
@timoteoponce
timoteoponce / loc_counter.rb
Created September 14, 2011 13:02
LOC counter in Ruby
# lines of code
def count_files( base_dir )
file_names = Dir.glob( base_dir + "/**/*.{java,py,sh,pl}")
puts "Counting LOC in [ #{file_names.length} ] files in folder : #{base_dir}"
total_count = 0
file_names.each do |file|
total_count += count_file file
end
puts "Total LOC: #{total_count}"
@timoteoponce
timoteoponce / oracle_h2_migrator.rb
Created September 28, 2011 20:35
Migrate Oracle backup script to H2(mode=ORACLE) script
def migrate_script ( input_file_name , output_file_name )
input_file = File.open( input_file_name , 'r')
loc = 0
File.open(output_file_name, 'w') do | output_file |
input_file.each do | line |
output_file.puts clean_line(line)
loc += 1
end
end
puts "#{input_file_name} -> #{output_file_name} : #{loc} lines migrated"
@timoteoponce
timoteoponce / SocketTransmission.java
Created October 19, 2011 03:45
Transmision de archivos a traves de sockets en Java
/**
*
* @author Miguel Peinado
* @author Timoteo Ponce
*/
import java.net.*;
import java.io.*;
class Cliente{
public static void main (String[] args){
@timoteoponce
timoteoponce / sieve_of_eratosthenes.rb
Created February 1, 2012 03:19
sieve_of_eratosthenes
def find_primes( limit )
list = Hash.new
(2..limit).each do |i|
list[ i ] = true
end
init = 2
while init <= limit/2 do
if list[init] then
index = init * 2
while index <= limit do
@timoteoponce
timoteoponce / sieve_of_eratosthenes_0.rb
Created February 1, 2012 03:25
sieve_of_eratosthenes_0
def find_primes( limit )
list = Hash.new
(2..limit).each do |i|
list[ i ] = false
end
init = 2
while init <= limit do
prime = init
while prime <= limit do
if prime > init then
public void close ( Process process ){
// statement.close(process,'0',1000,-1);
statement.close(process);
}