Skip to content

Instantly share code, notes, and snippets.

View sovetnik's full-sized avatar
🪓
Ярость топора!

Oleg Sovetnik sovetnik

🪓
Ярость топора!
View GitHub Profile
@andreaseriksson
andreaseriksson / convert_to_verified_routes.ex
Last active March 25, 2025 14:01
This is a mix task for converting old Phoenix routes to new verified routes
defmodule Mix.Tasks.ConvertToVerifiedRoutes do
@shortdoc "Fix routes"
use Mix.Task
@regex ~r/(Routes\.)(.*)_(path|url)\(.*?\)/
@web_module MyAppWeb
def run(_) do
Path.wildcard("lib/**/*.*ex")
@anildigital
anildigital / cleanup_swap.md
Last active March 6, 2025 20:16
Cleanup swap space on macOS

To see current swap usage

sysctl -a | grep swap

Use only when when your system is in a very bad shape

$ sudo pkill -HUP -u _windowserver 
@JamesYang76
JamesYang76 / Time Zone.md
Last active March 9, 2025 15:26
Time Zone for rails

Time zones

There are trhee diffrent time zones in rails

  • System - The server time zone
  • Application - Rails application use own time zone
  • Database - Default is UTC, but do not change it

Cautions

  • config.time_zone should be set when an app dose not support multiple time zones
  • Do not use Date/Time API using system time zone
  • Date could be incorrect by being converted from datetime or time to date
@germsvel
germsvel / .projections.json
Last active May 6, 2025 11:59
Elixir/Phoenix basic projections
{
"lib/**/views/*_view.ex": {
"type": "view",
"alternate": "test/{dirname}/views/{basename}_view_test.exs",
"template": [
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}View do",
" use {dirname|camelcase|capitalize}, :view",
"end"
]
},
@lukasni
lukasni / pre-commit.sh
Created January 18, 2019 16:16
git pre-commit hook for Elixir running format check, tests and credo.
#!/bin/bash
#
# Linter Elixir files using Credo.
# Called by "git receive-pack" with arguments: refname sha1-old sha1-new
#
# Config
# ------
# credo.terminate
# The credo exit status level to be considered as “not passed”—to prevent
# git commit until fixed.
@magjac
magjac / README.md
Last active September 21, 2024 15:25
d3-graphviz demo application showing association of SVG elements with DOT source elements

Open the console to see detalied info about what's going on

@felixyz
felixyz / converter.rb
Last active January 29, 2025 08:53
dry-validation form => json schema
module DryJsonSchema
# Transforms a dry-validation form to json-schema-compatible objects (hash or array)
# Usage:
# DryJsonSchema::Converter.(my_form)
# => { :type => :object,
# :properties => { :abc => { :type => :integer },
# :xyz => { :type => :integer }
# },
# :required => [:abc]}
class Converter
@jarosluv
jarosluv / hanami_app.rb
Created May 25, 2017 23:04
Minimal viable application template for reproducing bug reports in Hanami
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
@nelsonic
nelsonic / up-and-running-with-edeliver-on-do.md
Created May 10, 2017 19:21 — forked from mattweldon/up-and-running-with-edeliver-on-do.md
Getting Elixir / Phoenix running on Digital Ocean with edeliver

Build Server

  • Go to Digital Ocean
  • Create new droplet
  • London
  • Ubuntu
  • No apps
  • Add SSH keys