Skip to content

Instantly share code, notes, and snippets.

View tadast's full-sized avatar

Tadas Tamošauskas tadast

View GitHub Profile
@tadast
tadast / countries_codes_and_coordinates.csv
Last active April 12, 2024 15:03
Countries with their (ISO 3166-1) Alpha-2 code, Alpha-3 code, UN M49, average latitude and longitude coordinates
Country Alpha-2 code Alpha-3 code Numeric code Latitude (average) Longitude (average)
Afghanistan AF AFG 4 33 65
Åland Islands AX ALA 248 60.116667 19.9
Albania AL ALB 8 41 20
Algeria DZ DZA 12 28 3
American Samoa AS ASM 16 -14.3333 -170
Andorra AD AND 20 42.5 1.6
Angola AO AGO 24 -12.5 18.5
Anguilla AI AIA 660 18.25 -63.1667
Antarctica AQ ATA 10 -90 0
@tadast
tadast / Alphasights_technical_challenge.md
Last active April 3, 2024 12:25
A technical challenge we give to our Ruby on Rails applicants in order to evaluate their coding proficiency.Job description: http://www.alphasights.com/positions/ruby-developer-london or http://www.alphasights.com/positions/ruby-developer-new-york

Update: I no longer work for the company and this challenge is no longer used, but I'll leave the gist here in case people want to practice.

Alphasights Technical Challenge

Using Ruby on Rails we would like you to create a simple expert search tool. The application should fulfill the requirements below. The source code must be placed in a public repo on GitHub. The application should be deployable on Heroku.

  • I enter a name and a personal website address and a member is created.
  • When a member is created, all the heading (h1-h3) values are pulled in from the website to that members profile.
  • The website url is shortened (e.g. using http://goo.gl)
  • After the member has been added, I can define their friendships with other existing members. Friendships are bi-directional i.e. If Sasha is a friend of Ash, Ash is always a friend of Sasha as well.
@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 / ssl_puma.sh
Last active January 29, 2024 04:41 — forked from trcarden/gist:3295935
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@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 / 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 / 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 / .irbrc
Created May 6, 2013 19:46
easy rails route scanning in Rails console
# Put this in your ~/.irbrc for easy rails route scanning
#
# Usage:
# > routes
# => prints all routes
# > routes /GET.*user/i
# => prints routes matching a given regex
# > routes "user"
# => matches strings as well
@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 / syntax_highlighting.py
Created November 28, 2012 15:17 — forked from JeanMertz/syntax_highlighting.py
Ruby on Rails syntax highlight switcher for Sublime Text 2
# Forked from https://gist.github.com/925008
# Makes it work with Ruby on Rails snippets
# https://github.com/tadast/sublime-rails-snippets#sublime-text-2-rails-snippets
import sublime, sublime_plugin
import os
class DetectFileTypeCommand(sublime_plugin.EventListener):
""" Detects current file type if the file's extension isn't conclusive """
""" Modified for Ruby on Rails and Sublime Text 2 """