Skip to content

Instantly share code, notes, and snippets.

Avatar

Tadas Tamošauskas tadast

View GitHub Profile
@tadast
tadast / capybara_chrome_download.rb
Created Jun 3, 2020
Rails Capybara chromedriver setup for testing downloads
View capybara_chrome_download.rb
# in rails_helper.rb
driver = if ENV['CHROME_DEBUG'] == 'true'
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome)
end
:chrome
else
Capybara.register_driver :headless_chrome do |app|
browser_options = ::Selenium::WebDriver::Chrome::Options.new
@tadast
tadast / ruby.yml
Created Apr 26, 2020
Example github actions config for Rails with postgres using DATABASE_URL
View ruby.yml
name: Ruby
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
@tadast
tadast / with_active_support.rb
Last active Dec 10, 2018 — forked from mbyczkowski/with_active_support.rb
session cookie decrypter for Rails 5.1
View with_active_support.rb
require 'cgi'
require 'json'
require 'active_support'
def verify_and_decrypt_session_cookie(cookie, secret_key_base = Rails.application.secrets.secret_key_base)
cookie = CGI::unescape(cookie)
salt = 'encrypted cookie'
signed_salt = 'signed encrypted cookie'
key_generator = ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000)
secret = key_generator.generate_key(salt)[0, ActiveSupport::MessageEncryptor.key_len]
@tadast
tadast / Paint slack black.md
Last active Oct 27, 2020
Update the Mac Desktop slack CSS
View Paint slack black.md

In the console

export SLACK_DEVELOPER_MENU=true
open /Applications/Slack.app

In slack UI

right-click on anything -> inspect element

@tadast
tadast / json_api_to_graphviz.js
Created Nov 19, 2016
This is a script to take in a {json:api} document (jsonapi.org) and generate a visual graph (http://www.graphviz.org) representation of it
View json_api_to_graphviz.js
/*
This is a script to take in a {json:api} document (jsonapi.org)
and generate a graphviz (http://www.graphviz.org) representation of it.
Usage:
> node <this_file>
then copy and paste the output to some graphviz parser
e.g. http://www.webgraphviz.com or http://gravizo.com
*/
@tadast
tadast / dynamoid_reset.rb
Created Sep 8, 2016
Dynamoid test database cleaner
View dynamoid_reset.rb
# Prevent wiping out data in non-test environments
raise "Test should be run in 'test' environment only" if Rails.env != 'test'
module DynamoidReset
def self.all
Dynamoid.adapter.list_tables.each do |table|
# Only delete tables in our namespace
if table =~ /^#{Dynamoid::Config.namespace}/
Dynamoid.adapter.delete_table(table)
end
@tadast
tadast / sm-prototype-hierarchy-crawler.rb
Last active Nov 9, 2015
Service manual prototype hierarchy crawler
View sm-prototype-hierarchy-crawler.rb
require 'nokogiri'
require 'open-uri'
require 'pry'
require 'yaml'
class Crawl
def initialize(start_url = "http://sm-11.herokuapp.com")
@start_url = start_url
@guides = []
end
@tadast
tadast / README.md
Last active Aug 29, 2015 — forked from chrisroos/README.md
Spike into ways of visualising Smart Answers
View README.md

The print_graph method displays the Smart Answer as a tree.

The print_questions_and_possible_next_nodes method displays the questions and their possible next nodes.

The extraction of possible next nodes is horrible in the case where the Smart Answer uses the block syntax of next_node. I'm getting the source of the block and extracting things that look like symbols.

@tadast
tadast / public_pgp_key
Created Jun 1, 2015
My public PGP key
View public_pgp_key
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFVsoucBEACcPaABLP8Hm6b0R5wcZjsLsyTfrgGwC1mKsGSvoFa8Lu4d9moa
xsyWWO1NdIMMB7UNtlB1sbnFI0mkAiZoRVpk+hdYx9UvPup/exfbsKZWMG2srCvJ
cjL36X5jeGbu3X/78zAlPXlKhvJLf1i+8aMgQheO6He+D8Xu5G1QrCqYPaoEWgER
xQrUxu01S25ziwaf/7VvY3C35hKrQL7JG4N1mOL+QjxMRIzrVXe7mL7Igm7rT5Oz
tQtgfeMc4piTKQaztNbP+Yj+6LdoqeIzs3NWlFxfSqYw2qWrDIAqJlfpwMn/MWGN
r/8skOuCjBYPffDgngayAJrNhjeTlY5u++A41Cx84NhnMH93WpZd+Q7ga12QvRPc
U5/F2IBj/8eaSucKrgOL1KREo2JLS+8/Xp8lgJJNDzRkWhfMAqJnz7F8UwJs3DNW
XkLgKBxZobwztoxVWXgLhm78hwQ1vJLQbGlcFM9wbJzuLLRONniK0Rhx4Kuu0Zn2
@tadast
tadast / unused_yam_keys.rb
Last active Aug 29, 2015
Unused YAML keys
View unused_yam_keys.rb
def find_keys(hash)
hash.flat_map do |key, value|
if value.is_a?(Hash)
find_keys(value)
else
key
end
end
end
You can’t perform that action at this time.