Skip to content

Instantly share code, notes, and snippets.

Working from home

Ismael Marin igmarin

Working from home
View GitHub Profile
igmarin / flight-api.rb
Created Apr 30, 2020
Module to get connections from flighstats
View flight-api.rb
require 'open-uri'
module FlightAPI
def self.flights_populate(city)
date = ( + 30).strftime("%Y/%m/%d")
json = JSON.parse(open("{city.iata_code}/arriving/#{date}?appId=app_id&appKey=api_key").read)
airports = json["appendix"]["airports"]
carriers = json["appendix"]["airlines"]
flights = json["flights"]
flights.each do |f|
igmarin / application_helper.rb
Last active Feb 14, 2018
method_with several links
View application_helper.rb
def login_form_links
links = [sign_in, devise_registration, password_recovery, confirmation_instructions, unlock_email]
if devise_mapping.omniauthable?
resource_class.omniauth_providers.each do |provider|
links << link_to(t('.sign_in_with_provider', provider: OmniAuth::Utils.camelize(provider)), omniauth_authorize_path(resource_name, provider))
links.join(' ')
igmarin / main.c
Last active Sep 3, 2017
Main ejemplo LCD
View main.c
#include <hidef.h> /* common defines and macros */
#include "derivative.h" // Definiciones de la familia del micro
#include <mc9s12c32.h> /******* Definiciones específicas del micro *******/
#include "LCD.H"
#include "PLL.H"
#pragma LINK_INFO DERIVATIVE "mc9s12c32"
View test_sphero_1.rb
require 'artoo'
connection :sphero, :adaptor => :sphero, :port => ''
device :sphero, :driver => :sphero
work do
every(1.seconds) do
sphero.roll 90, rand(360)
igmarin / bobo.rb
Last active Dec 14, 2015
Little example using const_missing, after reading Chap3 of Rebuilding Rails, this is how rails works.
View bobo.rb
class Object
def self.const_missing c
STDERR.puts "Missing constant: #{c.inspect}"
class Bobo < Object
def hello
puts "Hi Bobo!"
igmarin / gatito.rb
Created Feb 9, 2013
My example for Bajio on Rails Feb 9 meeting
View gatito.rb
require 'open-uri'
puts "Por favor escribe el width:"
width = gets.chomp!
puts "Por favor escribe el height:"
height = gets.chomp!
gatitos = open("{width}/#{height}")
igmarin / guess_game.rb
Last active Aug 29, 2015
This a Guess Game in Ruby just for fun and taking the Chap1 in Head First Ruby as a reference :)
View guess_game.rb
class GuessGame
GUESS = 10
def initialize(player_name)
@player_name = player_name
@number = generate_number
@attempts = 1
def try_to_guess
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0Adyhq/cMXC16jM0x6sTMH0pEwFbtpRAWZiUnj3HcffAPfmVmwgV5ES6MUmnWhN0ip+DaAit/CLC+tvN0+gSop/dEQgmQs+xj4Pc60dwPK6eCTuUUsqnuYv/cLcwoft0dha52vcNhvHLjSDR7pwEcWt3pG+PoGd1v0FWDNIV6jUrXm3eTyuBLK7YNkuPuCq8VoVYgLV5Iyc7avHWAaMvIBJ1B31PwuORQwdbszJmVZgvvmOYrxu0jVLBeQbpvpHGIEk5wiKPCGxD/14ATkJMkr5v1FyTTWWjIvznOPf4tXtJwAToH9pirYEzz68WUGXE9l9db2mR/SP/XoiZUJA9h
igmarin / ability.rb
Created Jul 23, 2014
Example Ability
View ability.rb
class Ability
include CanCan::Ability
def initialize(user)
# Mis Modelos: User Publicacion Imagen Galeria Event Departamento Comunicado Ckeditor
user ||=
#El rol de administrador General
if user.role? :admin
can :manage, :all