This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
puts "Por favor escribe el width:" | |
width = gets.chomp! | |
puts "Por favor escribe el height:" | |
height = gets.chomp! | |
gatitos = open("http://placekitten.com/#{width}/#{height}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Object | |
def self.const_missing c | |
STDERR.puts "Missing constant: #{c.inspect}" | |
end | |
end | |
class Bobo < Object | |
def hello | |
puts "Hi Bobo!" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'artoo' | |
connection :sphero, :adaptor => :sphero, :port => '127.0.0.1:4321' | |
device :sphero, :driver => :sphero | |
work do | |
every(1.seconds) do | |
sphero.set_color(:red) | |
sphero.roll 90, rand(360) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//my variables to test | |
var preferred_code_sets = ['set', 'first', 'code', 'a']; | |
var codes_attribute = {'set': 1, 'dos': 3, 'a': 4}; | |
function codes_attribute(){ | |
{'set': 1, 'dos': 3, 'a': 4}; | |
} | |
function preferred_code(preferred_code_sets, codes_attribute, value_set_map=null){ | |
var code_value = function(code_attributes){try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
require 'minitest/pride' | |
# Will return a single code and code set if one exists in the code sets that are | |
# passed in. Returns a hash with a key of code and code_set if found, nil otherwise | |
def preferred_code(preferred_code_sets, codes_attribute=:codes, value_set_map=nil) | |
codes_value = send(codes_attribute) | |
preferred_code_sets = value_set_map ? (preferred_code_sets & value_set_map.collect{|cs| cs["set"]}) : preferred_code_sets | |
matching_code_sets = preferred_code_sets & codes_value.keys | |
#if matching_code_sets.present? <= present is only used in rails empty? is the ruby version of present? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($opal) { | |
var self = $opal.top, $scope = $opal, nil = $opal.nil, $breaker = $opal.breaker, $slice = $opal.slice, $hash2 = $opal.hash2; | |
$opal.add_stubs(['$send', '$&', '$collect', '$[]', '$keys', '$empty?', '$each', '$compact', '$flatten', '$==', '$first']); | |
return ($opal.Object._proto.$preferred_code = function(preferred_code_sets, codes_attribute, value_set_map) {try { | |
var $a, $b, TMP_1, $c, TMP_2, self = this, codes_value = nil, matching_code_sets = nil, code_set = nil; | |
if (codes_attribute == null) { | |
codes_attribute = "codes" | |
} | |
if (value_set_map == null) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -g default-terminal "xterm-256color" | |
setw -g window-status-current-bg default | |
setw -g window-status-current-attr underscore | |
set -g message-fg white | |
set -g message-bg black | |
set -g message-attr bright | |
setw -g mode-mouse on | |
setw -g utf8 on | |
set -g utf8 on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
module FlightAPI | |
def self.flights_populate(city) | |
date = (Date.today + 30).strftime("%Y/%m/%d") | |
json = JSON.parse(open("https://api.flightstats.com/flex/connections/rest/v1/json/direct/to/#{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| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Ability | |
include CanCan::Ability | |
def initialize(user) | |
# Mis Modelos: User Publicacion Imagen Galeria Event Departamento Comunicado Ckeditor | |
user ||= User.new | |
#El rol de administrador General | |
if user.role? :admin | |
can :manage, :all | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GuessGame | |
GUESS = 10 | |
def initialize(player_name) | |
@player_name = player_name | |
@number = generate_number | |
@attempts = 1 | |
play | |
end | |
def try_to_guess |
OlderNewer