Skip to content

Instantly share code, notes, and snippets.

View nikkypx's full-sized avatar

Nicholas Palaniuk nikkypx

  • Austin, TX
  • 03:19 (UTC -05:00)
View GitHub Profile

Keybase proof

I hereby claim:

  • I am nikkypx on github.
  • I am npalaniuk (https://keybase.io/npalaniuk) on keybase.
  • I have a public key ASD36UB1TEaqtstvU6bzLvFdnM2IdfJGR8plbbJlam92gAo

To claim this, I am signing this object:

# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Validate do
describe 'no presence' do
before(:each) do
@klass = Class.new
@klass.class_eval do
include Validate
@nikkypx
nikkypx / val.rb
Created July 22, 2020 18:19
val_spec
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe SimpleValidate do
describe 'invalid format' do
before do
@klass = Class.new
@klass.class_eval do
include SimpleValidate
# frozen_string_literal: true
RSpec.describe Event do
let(:event_emitter) { Event::Emitter.new }
describe '#add_listener' do
let(:event) { Faker::Lorem.word }
let(:listener) { -> { 'a' } }
let(:listener2) { -> { 'b' } }
def calc(n)
(1..n).inject([]) do |a, i|
a << (i % 15 == 0 ? 'FizzBuzz' :
(i % 5 == 0 ? 'Fizz' :
(i % 3 == 0 ? 'Buzz' : i)))
end
end
@nikkypx
nikkypx / fizz.rb
Last active September 28, 2016 00:08
def calc(n)
return [] if n == 0
calc(n - 1) << case
when n % 15 == 0
'Fizz Buzz'
when n % 5 == 0
'Fizz'
when n % 3 == 0
'Buzz'
else
@nikkypx
nikkypx / flatter.rb
Last active September 19, 2016 03:52
ruby flatten implementation
require 'rspec'
def flatter(arr)
[].tap do |res|
arr.each do |e|
if e.is_a?(Array)
res.concat(flatter(e))
else
res.push(e)
end
gem 'active_model_serializers'
gem_group :development, :test do
gem 'better_errors'
gem 'capybara'
gem 'pry-rails'
gem 'rspec-rails'
gem 'factory_girl'
end
module Twitter
class RestClient
attr_accessor :consumer_key
attr_accessor :api_token
def initialize
yield self
end
end
end
class Foo
def initialize(&block)
instance_eval(&block)
end
def fu
puts "fu"
end
def bar