Skip to content

Instantly share code, notes, and snippets.

View denvazh's full-sized avatar

Denis Vazhenin denvazh

  • Tokyo
View GitHub Profile
@denvazh
denvazh / README.md
Last active August 29, 2015 13:57
Create new Rails application without installing Rails itself

Why?

This is just a small script to bootstrap Rails new application generation process.

Reason, why I don't use rails new as it is, because I don't want Rails to be installed at all :) What I really wanted to have is a way to create Rails application without installing Rails system-wide.

Typical configuration is done with rbenv ( to manage and install ruby ) and bundler ( which is the only gem I need to install manually system-wide ).

@denvazh
denvazh / Gemfile
Last active August 29, 2015 14:01
Small example for conversion of file with kanji strings to csv file with corresponding readings in katakana, hiragana and romaji.
# A sample Gemfile
source "https://rubygems.org"
gem "natto"
gem "romaji"
@denvazh
denvazh / Dockerfile
Created January 6, 2015 08:26
Forcing japanese locale for Scala docker container
FROM williamyeh/scala
RUN \
echo "ja_JP.UTF-8 UTF-8" >> /etc/locale.gen && \
dpkg-reconfigure -f noninteractive locales
ENV LANG ja_JP.UTF-8
ENV LANGUAGE ja_JP.UTF-8
ENV LC_ALL ja_JP.UTF-8
@denvazh
denvazh / README.md
Created February 22, 2015 04:18
Generate ios icon settings for cordova.xml

How to use

This script assumes cordova application uses app/res/icons/ios directory for icon assets.

  • Install appicon_generate gem using bundler (refer to this)
    • Put gen_xml.rb in the same directry with Gemfile
  • Use appicon_generate to generate icons for ios
  • Run ./gen_xml.rb to generate related xml tags

Sample output:

@denvazh
denvazh / check.rake
Last active December 17, 2015 07:39
Currently, gitlab supports only Debian based OS where scripts are installed under /etc/init.d/ by default. Patches below has few improvements to the gitlab check and task_helper rake scripts to verify whether init script was installed on FreeBSD machine.
diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake
index a57c349..3253e16 100644
--- a/lib/tasks/gitlab/check.rake
+++ b/lib/tasks/gitlab/check.rake
@@ -118,7 +118,7 @@ namespace :gitlab do
def check_init_script_exists
print "Init script exists? ... "
- script_path = "/etc/init.d/gitlab"
+ script_path = get_init_script_syspath
@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)

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 / 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:

@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 / 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