Skip to content

Instantly share code, notes, and snippets.

View GusGA's full-sized avatar
🕶️
Reading someone else's code

Gustavo Giménez GusGA

🕶️
Reading someone else's code
  • Santiago, Chile
View GitHub Profile
{
"meta": {
"code": 200,
"requestId": "56b398a5498e7ce97bb8f1c8"
},
"notifications": [
{
"item": {
"unreadCount": 2
},
@GusGA
GusGA / script.rb
Last active January 3, 2016 15:49
Script scrapper que busca todos los id, precio Nuevo y refurbished de http://www.widespreadsales.com/Products/Circuit-Breakers, la tarea es tomada de una oferta de trabajo de freelancer.com
#!/usr/bin/ruby
require 'nokogiri'
require 'open-uri'
require 'progressbar'
@pages = 50 #7516
@page = "http://www.widespreadsales.com/Products/Search&category=cb&r_num=50&p="
@file = File.open(Dir.pwd + "/data", 'w')
@GusGA
GusGA / homework_3_1.rb
Created December 12, 2013 01:20
Script para eliminar el la la nota de la tarea con menor nota / Script to eliminate the homework with less score
require 'mongo'
@client = Mongo::Connection.new('localhost',27017)
@db = @client['school']
@collection = @db['students']
@filter = Array.new
@collection.find().each do |student|
hash = Hash.new
@GusGA
GusGA / mapper.rb
Created December 8, 2013 23:04
Mapper & Reducer in ruby
# Ruby code for map.rb
ARGF.each do |line|
# remove any newline
line = line.chomp
# do nothing will lines shorter than 2 characters
next if ! line || line.length < 2
@GusGA
GusGA / Setup.md
Last active December 29, 2015 06:08
Primecoin Setup in Digital Ocean
  1. Go to DigitalOcean and sign up for an account.

FYI, signing up for multiple accounts using the same info is against their terms of service. If you do this you may have your account removed by DigitalOcean and lose access to any coins you've mined.

  1. Create an Ubuntu 13.04 x64 droplet with the size you want. See below for speed ranges by instance size.

  2. You will be emailed an ip address and password. SSH into your new VM.

  3. cbeast posted his settings that will let you build primecoind on any size instance.

@GusGA
GusGA / copy_local_db_to_prod.rake
Last active December 28, 2015 13:39
Rake task to restore mongo databases, in both ways Prod to Local and Local to Prod
namespace :prod do
desc "Copy local database to production"
task :sync => :environment do
system 'mongodump -h localhost:27017 -d <LOCAL_DB_NAME> -o /path/to/folder'
system 'mongorestore -h host:port -db <PROD_DB_NAME> -u <DB_USER> -p <DB_PASS> --drop /path/to/folder/local_db_name'
end
end
@GusGA
GusGA / class_method_to_geojson.rb
Last active December 27, 2015 09:58
Método de clase para generar el contenido con formato geojson para crear puntos en el mapa
def self.to_geojson
{ type: "FeatureCollection",
features:
self.all.map do |local|
{
type: "Feature",
geometry: { type: "Point", coordinates: local.coordinates},
id: local.id,
properties: { prop1: local.val1,
prop2: local.val2,
@GusGA
GusGA / chinese_restaurant_in_caracas.json
Last active December 27, 2015 09:49
Restaurantes Chinos en Caracas
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@GusGA
GusGA / elefantes.rb
Last active December 21, 2015 20:39
La canción de los elefantes, a la 1 am... y mi bebé despierto
def elefantes(n)
(1..n).each do |n|
if n == 1
p "1 elefante se balanceaba sobre la tela de una araña, como veian que resistía fueron a llamar a otro elefante"
else
p "#{n} elefantes se balanceaban sobre la tela de una araña, como veian que resistía fueron a llamar a otro elefante"
end
end
end
@GusGA
GusGA / tareas_curso_rails_escuelaweb.rb
Last active December 21, 2015 08:49
Tarea del curso de RoR en @escuelawebve dictado por @despinoza85 (twitter)
#Fecha 19/08/13
#Halle la suma de todos los multiplos de 3 y 5, por debajo de 10000
def multiplos(n)
(1...n).map do |value|
value if (value % 3 == 0 || value % 5 == 0)
end.compact.inject(:+)
end
p multiplos(10000)
#Escriba un metodos para hallar el factorial del un numero