Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
def next_member(previous)
previous.each_with_object([]) do |digit, member|
if member[-1] == digit
member[-2] += 1
else
member << 1
member << digit
end
@ilnurnasyrov2
ilnurnasyrov2 / hide-iterm-dock-icon.md
Created November 3, 2016 19:38 — forked from stvhwrd/hide-iterm-dock-icon.md
Hide the iTerm dock icon on Mac OS X

On my dual-drive MacBook Pro I have remapped the eject key to F13 using Karabiner and NoEjectDelay. The eject key has been assigned as the hotkey for a guake-style visor terminal using iTerm2. Having its own hotkey precludes the need for an icon, so I prefer to hide the iTerm dock icon.

####To hide the dock icon of iTerm2 on Mac OS X:

/usr/libexec/PlistBuddy -c 'Add :LSUIElement bool true' /Applications/iTerm.app/Contents/Info.plist

####To undo the above:

@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
@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
success = ProviderResponse::Success.new(
guid: transaction.guid,
status: :success
)
success =
ProviderResponse::Success.new(
guid: transaction.guid,
status: :success
)
# 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
require 'spec_helper'
require 'ostruct'
class FakePostRepo
attr_reader :posts
def initialize
@posts = []
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(
class Aclass
def some_method
end
end
class Bclass < Aclass
end
class Cclass < Bclass
end
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?))