Skip to content

Instantly share code, notes, and snippets.

View mkldon's full-sized avatar

Mikhail Ryanzin mkldon

View GitHub Profile
@mkldon
mkldon / test_branch.rb
Created October 8, 2020 10:44
run rspec tests for all changed files on branch
#!/usr/bin/ruby
changes = `git diff master --name-only`.split("\n")
puts "All changes:\n #{changes.join("\n ")}"
changes = changes.select { |s| s =~ /^app/ }
puts "Changed app files:\n #{changes.join("\n ")}"
tests = changes.map { |s| s.gsub(/^app/, "spec").gsub(/.rb$/, "_spec.rb") }
tests = tests.select { |s| File.exists?(s) }
puts "Test files:\n #{tests.join("\n ")}"
@mkldon
mkldon / uin_validator.rb
Created March 5, 2020 16:40
Ruby uin validator
class UinValidator < ActiveModel::EachValidator
def self.valid?(uin)
return true if uin.blank?
return true if uin == "0"
return false unless uin.length.in? [20, 25]
return false unless valid_checksum?(uin)
true
end
def self.valid_checksum?(uin)
@mkldon
mkldon / excon_socket_debug.rb
Last active January 27, 2020 14:52
Excon print socket data
module ExconSocketDebug
def write(data)
puts data
super
end
def read(*args)
super.tap { |data| puts data }
end
@mkldon
mkldon / autosave10.akh
Last active January 3, 2020 22:37
Autohotkey - autosave with F5 every 10 minutes
#SingleInstance
#UseHook
Loop {
If (!LastF5)
{
LastF5 := 0
}
If ( (A_TickCount - LastF5) > 10 * 60 * 1000)
{
@mkldon
mkldon / sublime_text_here.reg
Last active September 14, 2017 21:44
"Sublime Text here" Explorer context menu option
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\Sublime Text Here]
"Icon"="C:\\Program Files\\Sublime Text 3\\sublime_text.exe"
[HKEY_CLASSES_ROOT\Directory\Background\shell\Sublime Text Here\command]
@="C:\\Program Files\\Sublime Text 3\\sublime_text.exe ."