Skip to content

Instantly share code, notes, and snippets.

View marcomontes's full-sized avatar
🏠
Working from home

Marco Montes marcomontes

🏠
Working from home
View GitHub Profile
@marcomontes
marcomontes / gameengines.md
Created October 26, 2011 04:35 — forked from bebraw/gameengines.md
List of JS game engines. You can find a wikified version at https://github.com/bebraw/jswiki/wiki/Game-Engines. Feel free to modify that. I sync it here every once in a while.

IMPORTANT! Remember to check out the wiki page at https://github.com/bebraw/jswiki/wiki/Game-Engines for the most up to date version.

This table contains primarily HTML5 based game engines and frameworks. You might also want to check out these pages: [[Feature Matrix|Game-Engine-Feature-Matrix]], [[Game Resources]].

Name Latest Release Size (KB) License Type Unit Tests Docs Repository Notes
Akihabara 1.3.1 (2011/05) 453 GPL2, MIT Classic Repro no API github Intended for making classic arcade-style games in JS+HTML5
Aves Commer-cial Obsolete. Company bought by Zynga. [E3 2010 Aves Engine Prototype "Suburban World"](http://www.
@marcomontes
marcomontes / gist:3fe53bc930ed4f38161d
Last active September 29, 2015 01:17
INSTALACIÓN Y CONFIGURACIÓN DE PASSENGER EN SERVIDOR UBUNTU 10.04
2. INSTALACIÓN Y CONFIGURACIÓN DE PASSENGER EN SERVIDOR UBUNTU 10.04
2.1 INSTALACIÓN DE LIBRERÍAS REQUERIDAS POR EL MODULO PASSENGER PARA APACHE 2
sudo apt-get install libc6 libpcre3 libpcre3-dev libpcrecpp0 libssl0.9.8 libssl-dev zlib1g zlib1g-dev lsb-base
2.2 INSTALACIÓN DE LA GEMA PASSENGER
@marcomontes
marcomontes / scheduler.rake
Created March 13, 2013 02:32
Tarea rake que mantiene activo un sitio en heroku, impide que en entre en inactividad
desc "This task is called by the Heroku cron add-on"
task :call_page => :environment do
uri = URI.parse('http://myapp.herokuapp.com/')
Net::HTTP.get(uri)
end
@marcomontes
marcomontes / frases.rb
Created April 8, 2013 15:38
Nokogiri para extraer las frases de la página frasesde.org frases ordenadas por categorias
require 'nokogiri'
require 'open-uri'
page = 'http://www.frasesde.org/'
doc = Nokogiri::HTML(open("#{page}"))
doc.css('a').each do |link|
tema = Nokogiri::HTML(open("#{page}#{link['href']}"))
puts "\n\n=== #{link.content} === \n\n"
tema.css('li').each do |frase|
@marcomontes
marcomontes / extract_image.rb
Last active August 29, 2015 14:22
Función que extrae una imagen desde un articulo importado de un blog, valida que exista y tenga URL correcta, ademas omite imágenes pixel (1x1)
def extract_image_from_entry(entry)
image_list = Magick::ImageList.new
images = Array.new
final_image = String.new
content = Nokogiri::HTML(entry.content || entry.summary)
content.xpath("//img").each do |img|
unless img.attributes['src'].blank?
image_src = img.attributes['src'].value
@marcomontes
marcomontes / change_offset.rb
Last active August 29, 2015 14:22
Función que retorna la fecha en el uso horario especificado
###  Ex: change_offset('-5', Article.last.created_at)
def change_offset(user_offset, publish_date)
offset = Rational(user_offset, 24)
user_publish_date = publish_date.to_datetime.new_offset(offset)
user_publish_date.strftime("%B %dth. %Y, %I:%M%P")
end
@marcomontes
marcomontes / youtube_adapter.rb
Last active August 29, 2015 14:22
Funciones varias para extraer y validar info de youtube y crear thumbnails personalizados.
class YoutubeAdapter
def self.get_thumbnail(entry, size)
video_id = get_video_id entry.embed
case size
when 0 then "http://img.youtube.com/vi/#{video_id}/0.jpg"
when 1 then "http://img.youtube.com/vi/#{video_id}/1.jpg"
end
end
@marcomontes
marcomontes / calculo_tiempo.rb
Created June 11, 2015 14:23
Sistema parqueadero - calculo de tiempo
def calculo_tiempo(tiempo = "hora")
if tiempo == "hora"
segundos = self.fecha_salida - self.fecha_entrada
horas = (segundos / 3600)
if self.fecha_salida.hour < self.fecha_entrada.hour
total_horas = 24 - self.fecha_entrada.hour + self.fecha_salida.hour
else
total_horas = horas
end
total_horas.round(2).ceil
@marcomontes
marcomontes / currency_format.rb
Last active August 29, 2015 14:22
Currency Format - Convierte un número a formato de moneda, con símbolo y delimitadores
def currency_format(number, options={})
options = {:currency_symbol => "$", :delimiter => ".", :decimal_symbol => ",", :currency_before => true, :no_decimal => true}.merge(options)
# split integer and fractional parts
int, frac = ("%.2f" % number).split('.')
# insert the delimiters
int.gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{options[:delimiter]}")
if options[:no_decimal]
frac_part = ""
@marcomontes
marcomontes / download_zip.rb
Created June 11, 2015 14:43
Get images from Class, pack into Zip file and upload to S3. Notify user by mail with url for zip file
class << self
def download_zip(user, photo_ids)
photos = SurveyPhoto.find photo_ids.gsub(' ', ',').split(",")
zipfile_name = File.join(Rails.root, "tmp", "archive.zip")
Zip::ZipOutputStream.open(zipfile_name) do |zipfile|
photos.each do |photo|
if photo.image.present?
zipfile.put_next_entry("#{Time.now.strftime('%M%S')}-#{photo[:image]}")