Skip to content

Instantly share code, notes, and snippets.

View jacortinas's full-sized avatar
💭
Coding

Jose Cortinas jacortinas

💭
Coding
View GitHub Profile
@jacortinas
jacortinas / lazy-aoc-2021-irb.rb
Last active December 6, 2021 23:14
Lazy AOC 2021
# No gems, just plain Ruby 3. Assumes inputs are in an inputs folder or something.
# Each line is a line or multiline input in an IRB prompt.
# Day 1
values = IO.readlines("inputs/1.txt").map(&:to_i)
# Part 1
values.each_cons(2).filter_map { |(a, b)| b > a }.count
# Part 2

Keybase proof

I hereby claim:

  • I am jacortinas on github.
  • I am jacortinas (https://keybase.io/jacortinas) on keybase.
  • I have a public key ASAJ3peUnQ7WlOpCTUJslbbpmKQky-j9NQCyrbFu_N5nNwo

To claim this, I am signing this object:

$(function() {
$(document).foundation('joyride', {
cookieMonster: true,
cookieName: 'tour',
cookieExpires: 365 * 5,
postRideCallback: function() {
alert('yeah');
console.log(arguments);
}
});
class User
def follow_default_users
default_user_emails = ['vulume@vulume.com']
default_user_emails.each do |email|
follow_with_email!(email)
end
end
def follow_with_email!(email)
class Name
def initialize name=''
@name = name
end
def name
@name ||= @name.to_s
end
alias :full :name
class InvitationRequest
extend ActiveModel::Naming
include ActiveModel::Conversion
include ActiveModel::Validations
include ActiveModel::Serializers::JSON
attr_reader :email, :url
attr_writer :clock, :invitation_class, :mailer
validates :email, presence: true
@jacortinas
jacortinas / authentication.rb
Created July 13, 2012 09:50
The difference between testing a small authentication file with BCrypt cost set to normal, then set to min.
# app/models/user/authentication.rb
require 'bcrypt'
class User
# Password authentication related methods and utilities.
module Authentication
extend ActiveSupport::Concern
module ClassMethods
@jacortinas
jacortinas / gist:3079083
Created July 9, 2012 21:30
Psych error using rbenv, ruby 1.9.3-p194 and rails 3.2.6
/Users/jacortinas/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.0/psych.bundle: warning: already initialized constant ANY
/Users/jacortinas/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.0/psych.bundle: warning: already initialized constant UTF8
/Users/jacortinas/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.0/psych.bundle: warning: already initialized constant UTF16LE
/Users/jacortinas/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.0/psych.bundle: warning: already initialized constant UTF16BE
/Users/jacortinas/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/psych/nodes/stream.rb:12: warning: already initialized constant ANY
/Users/jacortinas/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/psych/nodes/stream.rb:15: warning: already initialized constant UTF8
/Users/jacortinas/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/psych/nodes/stream.rb:18: warning: already initialized constant UTF16LE
/Users/jacortinas/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/psych/nodes/stream.rb:
redis_instance.pipelined do
[1,2,3].each do |item|
redis_instance.sadd 'some_key', item
end
end
require 'rubygems'
require 'spork'
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'