Skip to content

Instantly share code, notes, and snippets.

View palkan's full-sized avatar
🗺️
RailsConf / RubyKaigi

Vladimir Dementyev palkan

🗺️
RailsConf / RubyKaigi
View GitHub Profile
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@lfender6445
lfender6445 / gist:9919357
Last active May 2, 2024 22:40
Pry Cheat Sheet

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@steinwaywhw
steinwaywhw / One Liner to Download the Latest Release from Github Repo.md
Last active May 5, 2024 20:02
One Liner to Download the Latest Release from Github Repo
  • Use curl to get the JSON response for the latest release
  • Use grep to find the line containing file URL
  • Use cut and tr to extract the URL
  • Use wget to download it
curl -s https://api.github.com/repos/jgm/pandoc/releases/latest \
| grep "browser_download_url.*deb" \
| cut -d : -f 2,3 \
| tr -d \" \
@palkan
palkan / postgres_queries_and_commands.sql
Last active December 5, 2019 13:01 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- kill running query
SELECT pg_cancel_backend(procpid);
-- kill idle query
@palkan
palkan / 01_readme.md
Last active January 15, 2024 10:32
Docker Dev
@Ceroce
Ceroce / recursion.erl
Created June 27, 2017 10:09
Erlang: Fibonacci with Tail recursion + determining if an integer is perfect.
-module(recursion).
-export([fib/1, fibtail/1, fibtail/3, isPerfect/1]).
fib(0) ->
0;
fib(1) ->
1;
fib(N) when N > 0 ->
fib(N-1)+fib(N-2).
@cheeaun
cheeaun / rdrc2017.md
Last active October 11, 2017 06:56
RedDotRubyConf 2017 links & resources 😘
@Earendil95
Earendil95 / task_hooks.md
Last active August 8, 2019 17:12
Git hooks for automatic reference issues in commit

Description

This hooks will remind you to reference task in your commit, and remember your task ref for branch. Your commit messages will have style "[reference] message"

Usage

  1. Create two files in your repo - e.g. [PROJECT_ROOT]/hooks/prepare-commit-msg.rb and [PROJECT_ROOT]/hooks/post-checkout.rb
  2. Copy to first file (here will assume that this is a [PROJECT_ROOT]/hooks/prepare-commit-msg.rb):
#!/usr/bin/env ruby
class Object
def defer(method, *args)
@current_fibers ||= []
@tracepoint ||= TracePoint.trace(:return) do |tp|
@current_fibers.reverse_each do |fib|
fib.resume
end
end
@current_fibers << Fiber.new do
module ApplicationPolicy
READ = :read
MANAGE = :manage
MANAGE_FIELD = { parent_role: MANAGE } # NOTE(rstankov): Used for GraphQL fields
UPDATE = :update
MODERATE = :moderate