Skip to content

Instantly share code, notes, and snippets.

View RatoX's full-sized avatar

Rodrigo Vieira RatoX

View GitHub Profile
@RatoX
RatoX / it-your-fault.sh
Created March 14, 2017 16:51
search string with git blame
ag "$1" --jade --vimgrep | cut -f1,2 -d: | awk -F: '{ print "git blame -L"$2",-1 --show-name -- " $1 }' | sh
FROM node:8.5.0
# Isso vai te ajudar a lidar com os signais tipo SIGKILL
RUN wget https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb
RUN dpkg -i dumb-init_*.deb
ENTRYPOINT ["dumb-init"]
# Google Chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
@RatoX
RatoX / bulk_replace
Created March 1, 2018 13:25
Bulk replace with ag for MAC
#!/bin/bash
# Bulk replace for MAC
# ag <https://github.com/ggreer/the_silver_searcher>
# original idea: https://gist.github.com/hlissner/db74d23fc00bed81ff62
# usage: replace [search] [replace]
function replace {
ag -0 -l "$1" | xargs -0 sed -i "" -E "s/$1/$2/g"
}
@RatoX
RatoX / infinite_sum.js
Last active May 12, 2018 17:38
Infinite sum until the result function was called with Javascript
function infinite(fn, ...args) {
function partial(...args2) {
return infinite(fn, ...args.concat(args2));
}
partial.result = () => {
return fn(...args);
};
return partial;
@RatoX
RatoX / inundacao.js
Last active May 17, 2018 01:22
Inundação
const matrix = [
[ 0,0,1,0,1],
[ 1,1,0,1,1],
[ 0,1,0,1,0 ],
[ 0,1,1,1,1 ],
[ 1,0,1,0,1 ],
]
function checkZero (index_x, index_y, check) {
const temp = matrix[index_x] || []
@RatoX
RatoX / regex_tag_content.js
Created June 14, 2018 23:51
Regex to match tags content with multiple lines
const str = 'Ola como vai <b>voce?\n Eu vou</b> <b>bem</b>'
str.replace(/<b>(.*?|[\s\S]*?)<\/b>/g, '**$1**')
// Result: "Ola como vai **voce?\n Eu vou** **bem**"
@RatoX
RatoX / adicionar_data.py
Last active September 11, 2018 14:58
Aula FATEC LP01
# The MIT License (MIT)
#
# Copyright (c) 2018 RatoX
#
# 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 copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
@RatoX
RatoX / ports.sh
Last active September 25, 2018 00:20
List all ports used by your user with the process name
#!/bin/bash
# This is in progress I tested it only on macOS 10.13.6
# outuput e.g:
# PID (319) Spotify -> :57621
function ports {
PORTS=$(lsof -iTCP -sTCP:LISTEN -nP)
echo "$PORTS" | awk 'match($9, /[\]|\*]+:(.*)$/) { print " PID ("$2") "$1" -> "substr($9, RSTART+1, RLENGTH-1) }'
}
@RatoX
RatoX / chrome-memory-leak.html
Created June 8, 2019 22:57
Google Chrome CSS memory leak
<html>
<head>
<style>
@keyframes wave {
0% {
font-variation-settings: 'wght' 100;
}
100% {
font-variation-settings: 'wght' 1000;
}
@RatoX
RatoX / tmux.conf
Created September 13, 2018 02:39
Integrate TMUX with Google Calendar using gcalcli
# First you need to install gcalcli please go to https://github.com/insanum/gcalcli
wg_next_event="#(gcalcli --military --nostarted agenda --nocolor | cut -d ' ' -f 2- | head -2 | tail -1 | cut -c1-40)"
set -g status-right "#[fg=colour15,bg=colour237,bold]📅 $wg_next_event"