Skip to content

Instantly share code, notes, and snippets.

View tadast's full-sized avatar

Tadas Tamošauskas tadast

View GitHub Profile
@tadast
tadast / A gift of life.md
Last active December 9, 2022 12:04
As a teenager I started writing a sci-fi story that I never finished. I was playing around with ChatGPT and decided to explain the plot to it and ask me to write the story. 15mins of edits and I've got my childhood story completed!

A gift of life

As the inhabitants of the planet gazed out at the endless expanse of space from the windows of their spaceship, they knew that their time on their home planet has come to an end. The planet was undergoing a catastrophic mass extinction event, the oceans were boiling, the atmosphere was thinning, and there was no way for the inhabitants to survive.

But, as all live things do, they were not willing to give up just yet. A group of scientists and engineers had been working on a plan to evacuate the remnants of the population using a massive spaceship that was capable of transporting thousands of people to a nearby planet, that, with some help from light terraforming, could become habitable.

After months of preparation, the spaceship was ready to launch. The inhabitants crowded onto the ship, their hearts filled with hope and fear. They knew that the journey would be long and dangerous, but they were determined to make it to their new home.

As the ship blasted off into space, the inhabitants w

@tadast
tadast / capybara_chrome_download.rb
Created June 3, 2020 10:32
Rails Capybara chromedriver setup for testing downloads
# 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 April 26, 2020 20:29
Example github actions config for Rails with postgres using DATABASE_URL
name: Ruby
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
@tadast
tadast / with_active_support.rb
Last active December 10, 2018 11:41 — forked from mbyczkowski/with_active_support.rb
session cookie decrypter for Rails 5.1
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 July 14, 2023 04:00
Update the Mac Desktop slack CSS

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 November 19, 2016 16:22
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
/*
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 September 8, 2016 15:02
Dynamoid test database cleaner
# 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 November 9, 2015 13:56
Service manual prototype hierarchy crawler
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 August 29, 2015 14:25 — forked from chrisroos/README.md
Spike into ways of visualising Smart Answers

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 June 1, 2015 18:34
My 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