Skip to content

Instantly share code, notes, and snippets.

Denis Vazhenin denvazh

  • Tokyo
View GitHub Profile
@denvazh
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
end
@denvazh
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
denvazh / README.md
Created Nov 6, 2017
Regular expressions
View README.md

Japanese

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

/[一-龠]+|[ぁ-ゔ]+|[ァ-ヴー]+|[a-zA-Z0-9]+|[a-zA-Z0-9]+[々〆〤]+/u

@denvazh
denvazh / safepatch.sh
Created Jun 25, 2017
Bash wrapper to conditionally apply patch
View safepatch.sh
#!/usr/bin/env bash
# first argument is a patch file
if [ $# -eq 0 ]; then
echo "No arguments supplied. Aborting."
exit 0
fi
PATCH_FILE=$1
@denvazh
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'
PLATFORM = :ios
@denvazh
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)
end
@denvazh
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: https://git-scm.com/book/en/v2/Git-Internals-Git-Objects#Object-Storage
require 'digest/sha1'
require 'fileutils'
require 'zlib'
require 'optparse'
require 'ostruct'
def gen_header(content)
@denvazh
denvazh / pr.md
Created Nov 14, 2016 — forked from piscisaureus/pr.md
Checkout github pull requests locally
View pr.md

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 = git@github.com:joyent/node.git

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:

View keybase.md

Keybase proof

I hereby claim:

  • I am denvazh on github.
  • I am denvazh (https://keybase.io/denvazh) on keybase.
  • I have a public key ASDwoSrrTknzdY6_GFR4VbZzDhapicyc5YIx3UzcfiCxzwo

To claim this, I am signing this object:

@denvazh
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)
You can’t perform that action at this time.