Skip to content

Instantly share code, notes, and snippets.

View joaodubas's full-sized avatar
🤓
always learning

Joao P Dubas joaodubas

🤓
always learning
View GitHub Profile
#!/usr/bin/env elixir
for path <- Path.wildcard("_build/test/lib/*/.mix/.mix_test_failures", match_dot: true),
{{mod, name}, path} <-
path
|> File.read!()
|> :erlang.binary_to_term()
|> elem(1)
|> Map.to_list(),
grep_match <-
name
@idlehands
idlehands / 00_info.md
Last active May 20, 2023 11:28
-info and links
@bst27
bst27 / gitea-backup.sh
Created August 18, 2020 07:15
A Gitea backup script for Docker: It creates a .zip backup of Gitea running inside Docker and moves the backup file to the current working directory.
#!/bin/bash
# This script creates a .zip backup of gitea running inside docker and copies the backup file to the current working directory
echo "Creating gitea backup inside docker containter ..."
docker exec -u git -it -w /tmp $(docker ps -qf "name=gitea_server_1") bash -c '/app/gitea/gitea dump -c /data/gitea/conf/app.ini --file /tmp/gitea-dump.zip'
echo "Copying backup file from the container to the host machine ..."
docker cp $(docker ps -qf "name=gitea_server_1"):/tmp/gitea-dump.zip /tmp
@nkhitrov
nkhitrov / logger.py
Last active July 3, 2024 03:12
Configure uvicorn logs with loguru for FastAPI
"""
WARNING: dont use loguru, use structlog
https://gist.github.com/nkhitrov/38adbb314f0d35371eba4ffb8f27078f
Configure handlers and formats for application loggers.
"""
import logging
import sys
from pprint import pformat
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@berinhard
berinhard / list_field.py
Last active December 16, 2015 04:08
SeparatedValuesField for Django
class SeparatedValuesField(models.TextField):
"""
Usage:
class Foo(models.Model):
bar = SeparatedValuesField()
_list = [1, '2', date.today()]
obj = Foo.objects.create(bar=_list)
assert obj.bar == _list
"""
@mfn
mfn / netsniff.js
Last active October 30, 2018 13:18
netsniff.js from phantomjs, added DOMContentLoaded
if (!Date.prototype.toISOString) {
Date.prototype.toISOString = function () {
function pad(n) { return n < 10 ? '0' + n : n; }
function ms(n) { return n < 10 ? '00'+ n : n < 100 ? '0' + n : n }
return this.getFullYear() + '-' +
pad(this.getMonth() + 1) + '-' +
pad(this.getDate()) + 'T' +
pad(this.getHours()) + ':' +
pad(this.getMinutes()) + ':' +
pad(this.getSeconds()) + '.' +
@P4
P4 / default.reg
Last active April 13, 2024 05:23
Color schemes for Windows Command Prompt
Windows Registry Editor Version 5.00
; Default color scheme
; for Windows command prompt.
; Values stored as 00-BB-GG-RR
[HKEY_CURRENT_USER\Console]
; BLACK DGRAY
"ColorTable00"=dword:00000000
"ColorTable08"=dword:00808080
; BLUE LBLUE
@dongyuwei
dongyuwei / phantomjs-netsniff.js
Created September 10, 2012 09:33
phantomjs auto netsniff, create HAR file.
if (!Date.prototype.toISOString) {
Date.prototype.toISOString = function () {
function pad(n) { return n < 10 ? '0' + n : n; }
function ms(n) { return n < 10 ? '00'+ n : n < 100 ? '0' + n : n }
return this.getFullYear() + '-' +
pad(this.getMonth() + 1) + '-' +
pad(this.getDate()) + 'T' +
pad(this.getHours()) + ':' +
pad(this.getMinutes()) + ':' +
pad(this.getSeconds()) + '.' +
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active July 26, 2024 18:34
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'