Skip to content

Instantly share code, notes, and snippets.

View denvazh's full-sized avatar

Denis Vazhenin denvazh

  • Tokyo
View GitHub Profile
@denvazh
denvazh / bulk_screenshot_conv.rb
Created June 6, 2018 06:49
Convert screenshots for iPad to iPhone X size
#!/usr/bin/env ruby
require 'bundler/setup'
require 'pry'
require 'pathname'
module Intermediate
XAXIS = 1826
YAXIS = 2436
end
@denvazh
denvazh / extract_screenshots.rb
Created December 26, 2017 05:15
Extract screenshots from recorded profile in Google Chrome Dev tools
#!/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 November 6, 2017 08:10
Regular expressions

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 June 25, 2017 11:43
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
fi
PATCH_FILE=$1
@denvazh
denvazh / fix_react_build_configurations.rb
Created June 8, 2017 00:05
Create build configuration in the library xcode project using same name and type as parent one
#!/usr/bin/env ruby
require 'pathname'
require 'ostruct'
require 'bundler/setup'
require 'json'
require 'xcodeproj'
PLATFORM = :ios
@denvazh
denvazh / plot_ping.rb
Created February 1, 2017 06:53
Convert results of ping output to csv
#!/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 November 14, 2016 15:00
Script to show how git creates objects
#!/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 November 14, 2016 07:44 — forked from piscisaureus/pr.md
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 = 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:

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 June 20, 2016 05:13
Use email instead of confirmation token in Devise model (mainly used during stress testing)
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)