Skip to content

Instantly share code, notes, and snippets.

Phil Pirozhkov pirj

Block or report user

Report or block pirj

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pirj
pirj / f_hjkl_movements.json
Last active Jul 23, 2019
Karabiner complex modiications: Vi'ish mode
View f_hjkl_movements.json
{
"title": "F + HJKL",
"rules": [
{
"description": "Vi'ish Mode [F as Trigger Key]",
"manipulators": [
{
"type": "basic",
"parameters": {
"basic.to_delayed_action_delay_milliseconds": 100,
@pirj
pirj / subject_stub.rb
Last active May 20, 2019
Modified version of the `lib/rubocop/cop/rspec/subject_stub.rb` cop to detect `expect(subject).to all receive(...)` syntax only
View subject_stub.rb
def_node_matcher :message_expectation?, <<-PATTERN
(send
{
(send nil? { :expect :allow } (send nil? %))
(send nil? :is_expected)
}
#{Runners::ALL.node_pattern_union}
#all_matcher?
)
PATTERN
@pirj
pirj / match.rb
Last active May 22, 2019
NodePattern debug boilerplate
View match.rb
def match(pattern, source)
ruby_version = RUBY_VERSION.to_f
node_pattern = RuboCop::NodePattern.new(pattern)
ast = RuboCop::ProcessedSource.new(source, ruby_version).ast
node_pattern.match(ast)
end
match('(send nil? :sum $...)', 'sum(1,2,3,n)')
# => [s(:int, 1), s(:int, 2), s(:int, 3), s(:send, nil, :n)]
@pirj
pirj / repl.rb
Created Feb 23, 2019
Ruby REPL when `pry` is not there
View repl.rb
while(true) do
begin
print '> '
input = STDIN.readline.chop
output = eval(input)
puts "=> #{output}"
rescue StandardError => e
puts "Error: #{e.message}"
end
end
@pirj
pirj / Outro slide #1
Created Aug 27, 2018
Productivity tips
View Outro slide #1
RECAP
- don't blindly follow the hints
- figure out what slows you down and takes away your focus
- move forward one confident step at a time
- be confident with the changes you make
- identify the inconveniences that slow you down or distract you, and eliminate them
- rest assured that what slows you down has a solution, you just need to find it
@pirj
pirj / pr.md
Created Feb 1, 2017 — 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:

@pirj
pirj / pull.sh
Created Jan 16, 2017
Pull Heroku DB from staging/prod to local dev
View pull.sh
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
Generate self-signed certificate
View self-signed.sh
# 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
git integration branch (for rebase)
View set-head.sh
git remote set-head origin develop
@pirj
pirj / time_freezer.rb
Created Feb 18, 2016
Allow Capybara to walk hand in hand with freezed time
View time_freezer.rb
# 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
#
You can’t perform that action at this time.