Skip to content

Instantly share code, notes, and snippets.

View diegoponciano's full-sized avatar
🏠
Working from home

Diego Ponciano diegoponciano

🏠
Working from home
  • Sao Paulo - Brazil
View GitHub Profile
/* So how does this work?
I'm using ANSI escape sequences to control the behavior of the terminal while
cat is outputting the text. I deliberately place these control sequences inside
comments so the C++ compiler doesn't try to treat them as code.*/
//
/*The commands in the fake code comment move the cursor to the left edge and
clear out the line, allowing the fake code to take the place of the real code.
And this explanation uses similar commands to wipe itself out too. */
//
#include <cstdio>
# Script to get all config vars in a Heroku app and transfer to a new AWS Secrets Manager
# To get Heroku Auth Token:
# $ heroku auth:token
# Usage:
# python to_secrets.py
import boto3
import heroku3
import json
@biazzotto
biazzotto / validar_renavam.py
Last active February 3, 2017 10:42
Função para validar sequência de dígitos do Renavam
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# Função para validar sequência de dígitos do Renavam.
# Adaptado por Fabricio Biazzotto, a partir do original, feito em java:
# http://blog.victorjabur.com/2010/05/28/renavam_veiculos_java
def validar_renavam(renavam):
# Retorna falso caso o valor passado não seja um número inteiro
@ruebenramirez
ruebenramirez / setup-franz-ubuntu.sh
Created September 7, 2016 17:55
setup franz on ubuntu
#!/bin/bash
sudo rm -fr /opt/franz
sudo rm -fr /usr/share/applications/franz.desktop
# create installation dir
sudo mkdir -p /opt/franz
#install franz
@rjz
rjz / ngrok_hostname.sh
Created August 9, 2016 16:20
Get ngrok hostname from command line
#!/bin/sh
# ngrok's web interface is HTML, but configuration is bootstrapped as a JSON
# string. We can hack out the forwarded hostname by extracting the next
# `*.ngrok.io` string from the JSON
#
# Brittle as all get out--YMMV. If you're still reading, usage is:
#
# $ ./ngrok_hostname.sh <proto> <addr>
#
@jgillman
jgillman / restore.sh
Last active June 9, 2024 00:46
pg_restore a local db dump into Docker
# Assumes the database container is named 'db'
DOCKER_DB_NAME="$(docker-compose ps -q db)"
DB_HOSTNAME=db
DB_USER=postgres
LOCAL_DUMP_PATH="path/to/local.dump"
docker-compose up -d db
docker exec -i "${DOCKER_DB_NAME}" pg_restore -C --clean --no-acl --no-owner -U "${DB_USER}" -d "${DB_HOSTNAME}" < "${LOCAL_DUMP_PATH}"
docker-compose stop db
@slavafomin
slavafomin / install-telegram.sh
Last active June 2, 2017 15:40
Install Telegram on Ubuntu using shell automatically
#/usr/bin/env bash
set -o errexit
set -o pipefail
shopt -s nullglob
INSTALL_PATH="$HOME/Telegram"
TEMP_PATH="$HOME/.tmp"
sudo apt-get install xz-utils
@alexander-yakushev
alexander-yakushev / latex-cheatsheet-template.tex
Last active March 8, 2024 20:50
Beautiful cheatsheet template for key bindings, compiled with XeLaTeX
%% Copyright 2020 Alexander Yakushev
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
@kodekracker
kodekracker / json_encoder.py
Last active November 20, 2018 12:36
A Custom SqlAlchemy JSON encoder class to encode models instances in json format which supports major object instances useful in developing api's in flask.
# To use this custom JsonEncoder class, you have to create a __json__() named
# function in each sqlalchemy model class, which basically return a list of model
# class attributes to be parsed, otherwise all attributes are processed present
# in `dir(class_name)`.
#
# Model Example:
# class User(db.Model):
# id = db.Column(db.Integer, primary_key=True)
# name = db.Column(db.String(100))
# email = db.Column(db.String(100))
@jemshit
jemshit / text_colors.xml
Last active March 21, 2021 01:07
Android Text Colors according to Material Design Pattern
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Dark Text Color for Light Background -->
<color name="textDarkPrimary">#DE000000</color> <!--DE for %87 opacity-->
<color name="textDarkSecondary">#8A000000</color> <!--8A for %54 opacity-->
<color name="textDarkDisabled">#61000000</color> <!--61 for %38 opacity-->
<!-- White Text Color for Dark Background -->
<color name="textLightPrimary">#FFFFFF</color> <!--%100 opacity-->