Skip to content

Instantly share code, notes, and snippets.

View renatocassino's full-sized avatar

Renato Cassino renatocassino

View GitHub Profile
@renatocassino
renatocassino / docker-compose-graphite-statsd-grafana-loki.yml
Last active May 5, 2024 18:39
Docker compose to build graphite, statsd, grafana and Loki (logs)
version: '3'
services:
loki:
image: grafana/loki:2.0.0
ports:
- "3100:3100"
command: -config.file=/etc/loki/local-config.yaml
promtail:
image: grafana/promtail:2.0.0
volumes:
mkdir ~/docker
chmod 777 ~/docker
# Create network to all containers
docker network create dockernet
# Mongo
docker run -v ~/docker/mongo/data:/data/db -p 27017:27017 --name mongodb --network dockernet -d mongo
# CouchDB
@renatocassino
renatocassino / use_share_x-clipboard_on_emacs_for_ubuntu_and_mac_os_x.lisp
Created February 18, 2017 14:41
Using the same clipboard (x-clipboard) for ubuntu and mac os X in the same script for emacs.
;;;;; Add in your ~/.emacs.d/init.el
;;;; Clipboard for ubuntu
(defun copy-from-ubuntu (text &optional push)
(interactive)
(if (display-graphic-p)
(progn
(message "Yanked region to x-clipboard!")
(call-interactively 'clipboard-kill-ring-save)
)
@renatocassino
renatocassino / abnt2.sh
Created April 17, 2020 16:55
Teclado americano com acentos em português no Linux
# ´a ´c ~a
setxkbmap -model abnt2 -layout us -variant intl
# á ç ã
@renatocassino
renatocassino / CrawlAirbnb.js
Created February 4, 2020 17:57
Crawl Airbnb example
import axios from 'axios';
import cheerio from 'cheerio';
import logger from './lib/logger';
const BASE_URL = 'https://www.airbnb.com';
const URL = `${BASE_URL}/s/Miami--FL--United-States/homes`;
const CSS_QUERY = '._fhph4u ._8ssblpx';
const CSS_QUERY_PAGINATOR = 'nav[data-id="SearchResultsPagination"] > ul > li a[aria-label="Next"]';
const content = {
@renatocassino
renatocassino / .tmux.conf
Created December 6, 2019 20:54
Tmux config
set -g terminal-overrides 'xterm:colors=88'
set -g default-terminal "screen-256color"
@renatocassino
renatocassino / game.rs
Last active August 19, 2018 20:10
2048-rust.rs
fn add_number_bad_way(board: Vec<Vec<i32>>, point: Vec<i32>, number: i32) -> Vec<Vec<i32>> {
return board.iter().enumerate().map(|(column_index, line)| {
return line.iter().enumerate().map(|(line_index, value)| {
if column_index as i32 == point[0] && line_index as i32 == point[1] {
return number;
}
return *value;
}).collect();
}).collect();
}
@renatocassino
renatocassino / 2048-game.js
Last active August 16, 2018 03:17
2048 game
const readlineSync = require('readline-sync');
const printBoard = (board) => {
const f = (n) => {
const size = n.toString().length;
const spaces = 5-size;
return ' '.repeat(spaces) + n.toString() + ' ';
};
textToPrint = [];
@renatocassino
renatocassino / 2048-print-board.js
Last active August 16, 2018 02:09
Tutorial 2048 functional
const printBoard = (board) => {
const format = (n, stringSize) => {
const size = n.toString().length;
return ' '.repeat(stringSize - spaces) + n + ' ';
}
const textToPrint = board.map((column, idxLine) => {
const line = column.map((_, idxColumn) => format(board[idxColumn][idxLine]));
return line.join('|');
});
console.log('-'.repeat(4*5+5));
@renatocassino
renatocassino / 2048-moveUpTry2.js
Last active August 11, 2018 23:46
2048-moveUpTry2.js
/**
* @param line Array Old board array
* @param result New array with new state. Start empty
* @param lineWithoutZerosMemoized array list of numbers in line without 0
*/
const moveLineUp = (line, results=[], lineWithoutZerosMemoized=null) => {
// line is used like a counter to add in results
if(line.length === 0) return results; // If line is empty, get out recursion
const lineWithoutZeros = lineWithoutZerosMemoized || line.filter((n)=>n > 0);