Skip to content

Instantly share code, notes, and snippets.

View pirj's full-sized avatar
🚜
Relentless

Phil Pirozhkov pirj

🚜
Relentless
View GitHub Profile
@pirj
pirj / pull.sh
Created January 16, 2017 15:25
Pull Heroku DB from staging/prod to local dev
psql -c "select pg_terminate_backend(pid) from pg_stat_activity where datname='LOCAL_DB_NAME'" postgres $(whoami) \
&& psql -c 'drop database LOCAL_DB_NAME' postgres $(whoami) \
&& heroku pg:pull DATABASE_URL LOCAL_DB_NAME --app APP_NAME
# Replace LOCAL_DB_NAME to say myblog_development and APP_NAME to myblog_staging
@pirj
pirj / self-signed.sh
Created May 30, 2016 16:30
Generate self-signed certificate
# https://devcenter.heroku.com/articles/ssl-certificate-self
[ -z "$1" ] && echo provide file name as argument e.g. self-signed.sh server && exit 1
openssl genrsa -des3 -passout pass:x -out $1.pass.key 2048
openssl rsa -passin pass:x -in $1.pass.key -out $1.key
rm $1.pass.key
openssl req -new -key $1.key -out $1.csr
openssl x509 -req -days 365 -in $1.csr -signkey $1.key -out $1.crt
cat $1.key $1.crt > $1.pem
rm $1.key $1.crt $1.csr
@pirj
pirj / set-head.sh
Created May 4, 2016 14:16
git integration branch (for rebase)
git remote set-head origin develop
@pirj
pirj / time_freezer.rb
Created February 18, 2016 09:03
Allow Capybara to walk hand in hand with freezed time
# Due to Capybara's intolerance to tools that freeze time
# (specifically Time.now), we only freeze Time.current here
# @param time [Time] Time. But may be anything else if you like
# @example
# TimeFreezer.freeze_current_time('lol') do
# Time.current #=> lol
# Time.now #=> Your system time
# end
# Time.current #=> Your time with respect to Time.zone
#
@pirj
pirj / ruby-block-sugar.asciidoc
Last active July 29, 2022 14:19
Ruby block sugar

You won’t find rants on how functional programming improves you, your sanity and your life overall here. There are some examples in the very beginning to save you some time on reading the whole post, just come along if you don’t like how they look like.

By the way, this is not even a blog, so formally this is not even a blog post. This is not a library or a new paradigm. It’s just a few pieces of code that might come handy for your daily job.

Example:

[1, 3.14, -4].map &_.safe{ magnitude odd? } # => [true, nil, false]
@pirj
pirj / git.md
Last active March 15, 2016 11:45
Git with ease

Below is a Git usage proposal I compiled to make everyone's live easier

Reason

Our repo is flooded with merge commits, and as team and topic branch number grows, this is going to grow like a snowball and prevail over regular commits (it already does by the way)

Rationale

Keep flat history Pull requests are always up to date with master

@pirj
pirj / locate.rb
Last active December 15, 2020 09:21
Locate those annoying MESSages during tests
# Put this in your test helper
# Use `caller` to locate where in code that BUGGER is
class IO
BUGGER = /annoying/
def print *args
binding.pry if args.any? { |arg| arg =~ BUGGER }
super *args
end
def puts *args
@pirj
pirj / app.rb
Created October 24, 2014 07:58
Padrino::CanCan example that is known to have worked years ago
class App < Padrino::Application
register Padrino::Mailer
register Padrino::Helpers
register Padrino::Admin::AccessControl
register Padrino::Rendering
set :session_secret, "blah"
set :sessions, true
[403, 404, 405, 500].each do |code|
@pirj
pirj / CV.md
Last active August 22, 2019 23:34
Curriculum vitae

Personal summary

Name: Filipp Pirozhkov

Age: 40

Located in: Somewhere traveling

Top engineer with proven ability to develop efficient solutions to complex problems. Extensive experience and skills with all levels of software and architecture.

@pirj
pirj / index.html
Created April 29, 2014 18:50
Пишем HTTP proxy сервер с плагинами / Хабрахабр
<!DOCTYPE html>
<!-- saved from url=(0032)http://habrahabr.ru/post/111569/ -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width = 1080">
<title>Пишем HTTP proxy сервер с плагинами / Хабрахабр</title>