Skip to content

Instantly share code, notes, and snippets.

View aloon's full-sized avatar

Alex Gonzalez Lacasa aloon

View GitHub Profile
@aloon
aloon / main.rb
Created March 10, 2012 09:34
download and delete from S3
#!/usr/bin/env ruby
require 'fileutils'
require 'aws/s3'
AWS_ACCESS_KEY_ID = '...'
AWS_SECRET_ACCESS_KEY = '...'
DOWNLOAD_DIR = 'files'
cont = true
@aloon
aloon / threads.rb
Created March 17, 2012 00:43
download and delete all from S3
#!/usr/bin/env ruby
require 'fileutils'
require 'right_aws'
AWS_ACCESS_KEY_ID = '...'
AWS_SECRET_ACCESS_KEY = '...'
BUCKET = 'jujuego'
DOWNLOAD_DIR = '../files'
BUCKET_NAME = 'jujuego'
@aloon
aloon / extract_fixtures.rake
Created April 3, 2012 16:36
extracting data for fixtures
desc "extracting data for fixtures"
task :extract_fixtures => :environment do
sql = "SELECT * FROM %s"
skip_tables = ["schema_info","schema_migrations"]
ActiveRecord::Base.establish_connection
(ActiveRecord::Base.connection.tables - skip_tables).each do |table_name|
i = "000"
File.open(Rails.root.join('test','fixtures',"#{table_name}.yml"), 'w' ) do |file|
data = ActiveRecord::Base.connection.select_all(sql % table_name)
file.write data.inject({}) { |hash, record|
@aloon
aloon / gist:4771179
Last active December 12, 2015 12:19
get UniqueRandomNumbers
Private Shared Function UniqueRandomNumbers(NumAleatories As Integer, elements As Integer) As List(Of Integer)
Dim aleatorios As New List(Of Integer)
If elements > 0 Then
Dim temp As List(Of Integer) = Enumerable.Range(0, elements)
If NumAleatories > elements Then
aleatorios = temp.OrderBy(Function(a) Guid.NewGuid())
Else
Dim r As New Random(DateTime.Now.Millisecond)
@aloon
aloon / gist:5263296
Created March 28, 2013 13:55
Get the additional info inserted in property through attributtes
using System;
using System.Reflection;
class moreInfoAttribute : Attribute
{
public string valor { get; set; }
}
@aloon
aloon / doc.md
Last active July 27, 2022 18:30
Chuleta GIT

#GIT

Configuracion inicial

Global

git config --global user.name "Alex Gonzalez"
git config --global user.email [email protected]
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
@aloon
aloon / inout.sh
Created August 30, 2014 07:11
Simple shell script to test STDIN and STDOUT
#!/bin/sh
if [ -t 0 ]; then
echo nothing in STDIN
else
while read LINE; do
echo ${LINE}
done
exit 0