Skip to content

Instantly share code, notes, and snippets.

View kyrylo's full-sized avatar
🦋
Fixing bugs

Kyrylo Silin kyrylo

🦋
Fixing bugs
View GitHub Profile
@kyrylo
kyrylo / colorized_logger.rb
Last active November 5, 2024 15:45
Nice colorized logs for Rails apps! With this initializer, you can instantly colorize your Rails development logs. Just copy and paste the code, and it’ll work. https://x.com/kyrylosilin/status/1852308566201237815
# frozen_string_literal: true
# config/initializers/colorized_logger.rb
# This initializer adds color to the Rails logger output. It's a nice way to
# visually distinguish log levels.
module ColorizedLogger
COLOR_CODES = {
debug: "\e[36m", # Cyan
info: "\e[32m", # Green
warn: "\e[33m", # Yellow
@kyrylo
kyrylo / plain.css
Last active September 20, 2024 15:47
How to hide scrollbars in 2024
/* Plain CSS */
/* Hide scrollbar for Chrome, Safari and Opera */
.no-scrollbar::-webkit-scrollbar {
display: none;
}
/* Hide scrollbar for IE, Edge and Firefox */
.no-scrollbar {
-ms-overflow-style: none; /* IE and Edge */
@kyrylo
kyrylo / deploy.yml
Created September 13, 2024 10:56
Deploy with Kamal and GitHub Actions
name: Deploy
on:
push:
branches:
- main
jobs:
Deploy:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
@kyrylo
kyrylo / main_correct.go
Created September 10, 2024 15:14
How to wrap errors in Go (wrong)
// Correct way
package main
import (
"errors"
"fmt"
)
var errDoopsy = errors.New("doopsy")
@kyrylo
kyrylo / service.rb
Last active August 7, 2024 06:11
How to define service objects in Rails: the simple way
# frozen_string_literal: true
class ApplicationService
def self.call(...)
new(...).call
end
def initialize(...)
end
end
@kyrylo
kyrylo / a.rs
Created July 20, 2018 16:34
Filters
fn main() {
let mut notifier = Notifier::new();
notifier.add_filter(|n| n.incr_count(1));
notifier.add_filter(|n| n.incr_count(1));
let mut notice = Notice::new();
println!("Before: {:#?}", notice);
notifier.notify(&mut notice);
println!("After: {:#?}", notice);
package main
import (
"database/sql"
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
@kyrylo
kyrylo / PKGBUILD
Last active August 29, 2015 14:19
openra-20150424 PKGBUILD
# $Id$
# Maintainer: Sven-Hendrik Haase <sh@lutzhaase.com>
# Contributor: Matthew Bowra-Dean <matthew@ijw.co.nz>
pkgname=openra
pkgver=20150424
pkgrel=1
pkgdesc="An open-source implementation of the Red Alert engine using .NET/mono and OpenGL"
arch=('any')
url="http://openra.net"
license=('GPL3')
@kyrylo
kyrylo / a.js
Created November 7, 2014 03:00
x = {}
> Object {}
x[{}] = 1
> 1
x[{a: 999}] = 2
> 2
x[{}]
> 2
x[{a: 999}]
> 2
-module(my_tuple_to_list).
-compile(export_all).
my_tuple_to_list(T) ->
my_tuple_to_list_acc(T, [], tuple_size(T)).
my_tuple_to_list_acc(_T, L, 0) -> L;
my_tuple_to_list_acc(T, L, N) ->
my_tuple_to_list_acc(T, [element(N, T)|L], N - 1).