Skip to content

Instantly share code, notes, and snippets.


Denis Vazhenin denvazh

  • Tokyo
View GitHub Profile
denvazh / bulk_screenshot_conv.rb
Created Jun 6, 2018
Convert screenshots for iPad to iPhone X size
View bulk_screenshot_conv.rb
#!/usr/bin/env ruby
require 'bundler/setup'
require 'pry'
require 'pathname'
module Intermediate
XAXIS = 1826
YAXIS = 2436
denvazh / extract_screenshots.rb
Created Dec 26, 2017
Extract screenshots from recorded profile in Google Chrome Dev tools
View extract_screenshots.rb
#!/usr/bin/env ruby
require 'optparse'
require 'json'
require 'base64'
require 'pathname'
module Screenshot
class Snapshot
attr_reader :name, :ts, :blob, :format
denvazh /
Created Nov 6, 2017
Regular expressions


match all dashes, English alphanumerics, Japanese katakana, hiragana, multibytes of alphanumerics half-width and full-width


denvazh /
Created Jun 25, 2017
Bash wrapper to conditionally apply patch
#!/usr/bin/env bash
# first argument is a patch file
if [ $# -eq 0 ]; then
echo "No arguments supplied. Aborting."
exit 0
denvazh / fix_react_build_configurations.rb
Created Jun 8, 2017
Create build configuration in the library xcode project using same name and type as parent one
View fix_react_build_configurations.rb
#!/usr/bin/env ruby
require 'pathname'
require 'ostruct'
require 'bundler/setup'
require 'json'
require 'xcodeproj'
denvazh / plot_ping.rb
Created Feb 1, 2017
Convert results of ping output to csv
View plot_ping.rb
#!/usr/bin/env ruby
require 'csv'
class Entry
attr_reader :id, :text
def initialize(text)
@id, @text = parse_text(text)
denvazh / hash-object.rb
Last active Nov 14, 2016
Script to show how git creates objects
View hash-object.rb
#!/usr/bin/env ruby
# Based on code from:
require 'digest/sha1'
require 'fileutils'
require 'zlib'
require 'optparse'
require 'ostruct'
def gen_header(content)
denvazh /
Created Nov 14, 2016 — forked from piscisaureus/
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url =

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:


Keybase proof

I hereby claim:

  • I am denvazh on github.
  • I am denvazh ( on keybase.
  • I have a public key ASDwoSrrTknzdY6_GFR4VbZzDhapicyc5YIx3UzcfiCxzwo

To claim this, I am signing this object:

denvazh / user.rb
Created Jun 20, 2016
Use email instead of confirmation token in Devise model (mainly used during stress testing)
View user.rb
unless Rails.env.test?
module Devise
module Models
module Confirmable
module ClassMethods
# Use email instead of confirmation_token, i.e. if user exist it will be confirmed
def confirm_by_token(email)
user_confirmable = find_first_by_auth_conditions(email: email)
unless user_confirmable
user_confirmable = find_or_initialize_with_error_by(:email, email)