Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View chrisvoo's full-sized avatar
🎸
hard as a rock

Christian Castelli chrisvoo

🎸
hard as a rock
View GitHub Profile
@chrisvoo
chrisvoo / pre-commit
Created May 5, 2021 12:24
Avoit to commit tests with `only`
# Redirect output to stderr.
exec 1>&2
# prevent it.only or describe.only commited
if [ "$allowonlytests" != "true" ] &&
test $(git diff --cached | grep -E "\b(it|describe).only\(" | wc -l) != 0
then
cat <<\EOF
Error: Attempt to add it.only or describe.only - which may disable all other tests
@chrisvoo
chrisvoo / discogs_search_example.ts
Created May 10, 2021 06:21
An example on how to retrieve an artist's discography with Discogs
/* The API returns way too much results: the example below is the best approximation
* to get a discography. Anyway, there are some errors:
* - another group is present
* - Cheshire cat's album is missing
*/
import { Client } from 'disconnect';
import dotenv from 'dotenv';
import { envSchema } from './utils';
import { showResult } from './utils/terminal';
@chrisvoo
chrisvoo / lastfm_search_discography.ts
Created May 10, 2021 09:12
Retrieving artist's top albums
/* 57034 results for 1141 pages! */
import dotenv from 'dotenv';
import LastFM from 'last-fm';
import { envSchema } from './utils';
import { showResult } from './utils/terminal';
const result = dotenv.config();
if (result.error) {
console.error(result.error.message);
@chrisvoo
chrisvoo / solution.md
Last active July 5, 2021 16:39 — forked from lgg/solution.md
JetBrains intellij idea + NVM + nodejs + WebStorm

NVM + WebStorm

If you get error:

run npm command gives error "/usr/bin/env: node: No such file or directory

Modify the Desktop icon ~/.local/share/applications/jetbrains-webstorm.desktop with:

@chrisvoo
chrisvoo / pgsql_cheatsheet.sql
Last active September 19, 2022 03:44
PostgreSQL cheat sheet
-- QUERIES OPERATIONS
----------------------------------------------------------------------------------
-- KILL ALL sessions FOR A DATABASE
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'TARGET_DB'
AND pid <> pg_backend_pid();
-- GETTING RUNNING QUERIES, version: 9.2+
@chrisvoo
chrisvoo / flac_to_mp3.sh
Last active December 10, 2022 20:03
Converts a FLAC file to MP3 with ffmpeg and lame encoder
to_mp3() {
filename=$(basename "$1")
extension="${filename##*.}"
filename="${filename%.*}"
ffmpeg -i "$1" -codec:a libmp3lame -b:a 320k -map_metadata 0 -id3v2_version 3 ${filename}.mp3
}
@chrisvoo
chrisvoo / how-to-start-colima-automatically-on-macos.md
Last active April 7, 2023 14:46 — forked from fardjad/how-to-start-colima-automatically-on-macos.md
[How to start Colima automatically on macOS] Instructions for starting Colima automatically on macOS similar to Docker Desktop #macos #colima #docker

Steps

  1. Create an executable script to run in foreground and manage colima:
cat <<-EOF | sudo tee /usr/local/bin/colima-start-fg
#!/bin/bash

export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
@chrisvoo
chrisvoo / redis.js
Created March 19, 2019 14:40
Node.js and Redis: async GET/SET
const redis = require("redis")
const { promisify } = require("util")
const {
redis: { clientOptions, expire },
} = require("../config/get-config")
let client
/**
* Asynchronous version of `client.get`