Skip to content

Instantly share code, notes, and snippets.

View alec-c4's full-sized avatar
🪓
I do make sacrifices to Odin

Alexey Poimtsev alec-c4

🪓
I do make sacrifices to Odin
View GitHub Profile
@alec-c4
alec-c4 / Dockerfile
Last active October 23, 2022 22:06
Code test for backend people
FROM ruby:latest
WORKDIR /usr/src/app/
ADD . /usr/src/app/
CMD ["ruby", "/usr/src/app/test.rb"]
@alec-c4
alec-c4 / string.rb
Created May 6, 2021 11:04
string to id (both integer and UUID)
String.class_eval do
def to_id
if self.match?(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i)
self.to_s
else
self.to_i
end
end
end
@alec-c4
alec-c4 / Brewfile
Last active October 23, 2022 22:01
tap "dart-lang/dart"
tap "hashicorp/tap"
tap "heroku/brew"
tap "homebrew/bundle"
tap "homebrew/cask-versions"
tap "homebrew/core"
tap "muesli/tap"
tap "romkatv/powerlevel10k"
tap "rs/tap"
tap "stripe/stripe-cli"
# Quick edits
alias ea 'vim ~/.config/fish/aliases.fish'
alias ef 'vim ~/.config/fish/config.fish'
alias eg 'vim ~/.gitconfig'
alias ev 'vim ~/.vimrc'
# OS related
alias cd.. 'cd ..'
alias .. 'cd ..'
alias ... 'cd ../..'
# Path to your oh-my-zsh installation.
export ZSH=/Users/alec/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"
# Uncomment the following line to use case-sensitive completion.
@alec-c4
alec-c4 / pin.ex
Created September 24, 2016 21:27
defmodule Pin do
def generate(length \\ 4) when is_integer(length) and length >= 0 do
Enum.join(gen_pin(length))
end
defp gen_pin(1) do
[:rand.uniform(9)]
end
# config valid only for current version of Capistrano
lock '3.4.0'
set :application, 'domochat'
set :repo_url, 'git@github.com:domochat/domochat.git'
set :ruby_version, '2.2.3'
# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
@alec-c4
alec-c4 / .vimrc
Last active October 23, 2022 22:11
my .vimrc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" ██╗ ██╗██╗███╗ ███╗██████╗ ██████╗
" ██║ ██║██║████╗ ████║██╔══██╗██╔════╝
" ██║ ██║██║██╔████╔██║██████╔╝██║
" ╚██╗ ██╔╝██║██║╚██╔╝██║██╔══██╗██║
" ╚████╔╝ ██║██║ ╚═╝ ██║██║ ██║╚██████╗
" ╚═══╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@alec-c4
alec-c4 / gist:138659
Created July 1, 2009 07:53
locale filter
###### application_controller.rb
before_filter :set_locale
def set_locale
locale = params[:locale] || cookies[:locale] || TLD_LOCALES[request.host.split('.').last] || request.headers['HTTP_ACCEPT_LANGUAGE'].split(',').map { |l| l.split(';').first }
locale = DEFAULT_LOCALE unless (SUPPORTED_LOCALES).include?(locale.to_s)
I18n.locale = locale.to_s
cookies[:locale] = locale unless (cookies[:locale] && cookies[:locale] == locale)