Skip to content

Instantly share code, notes, and snippets.

View feymartynov's full-sized avatar

Timofey Martynov feymartynov

  • Wildberries
  • Moscow
View GitHub Profile
@paveltyk
paveltyk / slugify.ex
Created October 31, 2017 10:21
Slug generation for Elixir with Russian letters transliteration support.
defmodule Slugify do
@moduledoc """
The main intent of this module is to be used in slug generation for URLs.
Supports russian transliteration.
"""
@char_mappings %{"а" => "a", "б" => "b", "в" => "v", "г" => "g", "д" => "d", "е" => "e",
"ё" => "e", "ж" => "j", "з" => "z", "и" => "i", "й" => "i", "к" => "k", "л" => "l", "м" => "m",
"н" => "n", "о" => "o", "п" => "p", "р" => "r", "с" => "s", "т" => "t", "у" => "y", "ф" => "f",
"х" => "h", "ц" => "ts", "ч" => "ch", "ш" => "sh", "щ" => "sch", "ъ" => "", "ы" => "y",
@vahidabdi
vahidabdi / arc_resolver.ex
Last active March 5, 2020 22:02
Arc Uploader resolver for Absinthe Graphql
defmodule MyApp.Schema.ArcResolver do
defmacro __using__([uploader: uploader]) do
quote do
import unquote(__MODULE__), only: [
get_file: 2
]
@__arc_upload unquote(uploader)
end
end
@whazzmaster
whazzmaster / keybindings.json
Last active November 21, 2022 09:06
Test tasks for Visual Studio Code and Elixir
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "cmd+t cmd+t",
"command": "workbench.action.tasks.runTask",
"args": "Run All Tests"
},
{
"key": "f5",
"command": "workbench.action.tasks.runTask",
@mbenatti
mbenatti / 0-font-awesome-bootstap-phoenix.md
Last active February 2, 2024 14:59
Installing Bootstrap 4 + Font Awesome from NPM in Phoenix Framework using sass
  • Tested with Phoenix 1.3

1) Installing sass, font-awesome and bootstrap package's using Brunch

First, install the Sass, Font Awesome, bootstrap(and deps) package:

cd assets

  • npm install --save-dev sass-brunch
  • npm install --save font-awesome
@moklett
moklett / task1.exs
Last active May 7, 2024 09:59
Elixir Task - Crash Handling
# This demonstrates that, when using async/await, a crash in the task will crash the caller
defmodule Tasker do
def good(message) do
IO.puts message
end
def bad(message) do
IO.puts message
raise "I'm BAD!"
end
@a-r-d
a-r-d / convert-and-split.sh
Last active August 2, 2023 20:46
How to take an annoying APE + CUE file cd rip and convert it into a set of FLAC or MP3 files on ubuntu.
#first install all the things:
sudo apt-get install flac ffmpeg mp3splt libav-tools shntool
# Okay first lets do an MP3:
# input files:
# --> cd.ape
# --> cp.cue
# (there are other options, like bitrate, but this is just the bare bones)
avconv -i cd.ape cd.mp3
@cameron
cameron / docker-ssl-cert-generate
Last active February 2, 2023 10:09
Generate self-signed SSL certs for docker client <— HTTPS —> daemon
#! /bin/bash
# HEADS UP! Make sure to use '*' or a valid hostname for the FDQN prompt
echo 01 > ca.srl
openssl genrsa -des3 -out ca-key.pem
openssl req -new -x509 -days 365 -key ca-key.pem -out ca.pem
openssl genrsa -des3 -out server-key.pem
openssl req -new -key server-key.pem -out server.csr
@realmyst
realmyst / gist:1262561
Created October 4, 2011 19:34
Склонение числительных в javascript
function declOfNum(number, titles) {
cases = [2, 0, 1, 1, 1, 2];
return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ];
}
use:
declOfNum(count, ['найдена', 'найдено', 'найдены']);