Skip to content

Instantly share code, notes, and snippets.

@ilnurnasyrov2
ilnurnasyrov2 / http_client_spec.rb
Created October 30, 2018 14:23 — forked from xaviershay/http_client_spec.rb
Running a rack app in a thread for integration tests.
require 'integration_helper'
require 'rack'
require 'rack/handler/webrick'
describe HttpClient do
before :all do
@server = WEBrick::HTTPServer.new(
:Port => 9293,
:Logger => Rails.logger,
:AccessLog => Rails.logger
@ilnurnasyrov2
ilnurnasyrov2 / bulgenos.sh
Last active April 2, 2018 16:00
osx. setup
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew cask install google-chrome
brew cask install slack
brew cask install sublime-text
brew cask install telegram-desktop
brew cask install spotify
brew cask install firefox
brew cask install iterm2
brew cask install skype
require "dry-validation"
schema = Dry::Validation.Schema do
optional(:vin).maybe(:str?)
optional(:chassis_number).maybe(:str?)
optional(:engine_number).maybe(:str?)
optional(:body_number).maybe(:str?)
rule(numbers_presense: [:vin, :chassis_number, :engine_number, :body_number]) do |vin, chassis_number, engine_number, body_number|
vin.filled? | (engine_number.filled? & (chassis_number.filled? | body_number.filled?))
class Aclass
def some_method
end
end
class Bclass < Aclass
end
class Cclass < Bclass
end
@ilnurnasyrov2
ilnurnasyrov2 / imgur.rb
Created February 6, 2018 16:45
Sample of imgur api usage
require "httparty"
require "base64"
# Put there your client id
client_id = "..."
binary_file = IO.read("image.jpg");
base64_encoded_file = Base64.encode64(binary_file);
response = HTTParty.post(
require 'spec_helper'
require 'ostruct'
class FakePostRepo
attr_reader :posts
def initialize
@posts = []
end
# example 1 (current)
(1..100).each_slice(10) do |ids|
puts ids.inspect #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
end
# example 2 (suggestion)
(1..100).each_slice(10) do |ids|
puts ids.inspect #=> (1..10)
end
success = ProviderResponse::Success.new(
guid: transaction.guid,
status: :success
)
success =
ProviderResponse::Success.new(
guid: transaction.guid,
status: :success
)
@ilnurnasyrov2
ilnurnasyrov2 / fizzbuzz.rb
Last active April 2, 2017 20:47
Fizz buzz without divison
require "active_support/core_ext/object/blank"
class FizzBuzzChecker
def initialize(point, point_name)
@point_name = point_name
@point = point
@current = 1
end
def check
@ilnurnasyrov2
ilnurnasyrov2 / gist:3f816d7600a384ac3f3cf3a78f343e6e
Last active February 13, 2017 16:20
Disable fullscreen switch animation
http://apple.stackexchange.com/questions/14001/how-to-turn-off-all-animations-on-os-x
```
# opening and closing windows and popovers
defaults write -g NSAutomaticWindowAnimationsEnabled -bool false
# smooth scrolling
defaults write -g NSScrollAnimationEnabled -bool false
# showing and hiding sheets, resizing preference windows, zooming windows