Skip to content

Instantly share code, notes, and snippets.

@oleoneto
oleoneto / dbhist.sh
Created January 26, 2024 01:32 — forked from outcoldman/dbhist.sh
DBHist: bash history in sqlite
# The MIT License
# SPDX short identifier: MIT
# Further resources on the MIT License
# Copyright 2017 Denis Gladkikh (https://www.outcoldman.com/en/archive/2017/07/19/dbhist/)
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# Source: https://gist.github.com/8adaf8fd6496bc99a466ba55834e1838
###############################################################
# Metacontroller - Custom Kubernetes Controllers The Easy Way #
# https://youtu.be/3xkLYOpXy2U #
###############################################################
# Additional Info:
# - Metacontroller: https://metacontroller.github.io/metacontroller
# - DevOps MUST Build Internal Developer Platform (IDP): https://youtu.be/j5i00z3QXyU
@oleoneto
oleoneto / 1_initial_migration.rb
Created October 1, 2021 05:40 — forked from wrburgess/1_initial_migration.rb
Setting up UUID columns for Rails 5+ models utilizing Postgres 9.4+
class InitialMigration < ActiveRecord::Migration[5.0]
def change
enable_extension "pgcrypto" unless extension_enabled?("pgcrypto")
end
end
import sys
def compute_collatz(number):
if number % 2 == 0:
return number / 2
return (number * 3 + 1) / 2
def main():
// Just learned that a `return` inside try-catch blocks does not prevent the execution of code found in a `finally` block.
// Case and point, the example below:
const help = ({ command, logger }) => {
try {
console.log("Trying...");
if (!command) {
console.log("Missing command. Halting...")
return false;
@oleoneto
oleoneto / handleDatabaseQuery.js
Last active June 11, 2021 20:41
Helper functions and wrapping controller to add some convenience around the use of Prisma.js in the context of an Express application.
/**
* Wraps database read query in an exception handler,
* which allows for a consistent return value even if an error occurs.
*
* @param {*} query
* @return {data} on success
* @return {[]} on error
*/
const handleDatabaseRead = async (query) => {
try {

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.

@oleoneto
oleoneto / redis_cheatsheet.bash
Created December 3, 2020 23:24 — forked from LeCoupa/redis_cheatsheet.bash
Redis Cheatsheet - Basic Commands You Must Know --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
@oleoneto
oleoneto / radio.liq
Created November 24, 2020 19:58 — forked from iliaaw/radio.liq
Example of LiquidSoap config for https://github.com/ilyakhokhryakov/radio-server
#!/usr/bin/liquidsoap
set("server.telnet", true)
files = playlist(
mode = "normal",
id = "files",
"PATH_TO_PLAYLIST.m3u"
)
@oleoneto
oleoneto / prepare-commit-msg.sh
Created November 3, 2020 16:38 — forked from bartoszmajsak/prepare-commit-msg.sh
How to automatically prepend git commit with a branch name
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"