Skip to content

Instantly share code, notes, and snippets.

View RatoX's full-sized avatar

Rodrigo Vieira RatoX

View GitHub Profile
@RatoX
RatoX / basic_code.js
Last active April 9, 2020 02:46
ProseMirror EditorState
'use strict';
const {EditorState} = require('prosemirror-state');
const {Schema, Node} = require('prosemirror-model');
const schema = new Schema({
nodes: {
doc: {
content: 'block+',
},
@RatoX
RatoX / last_branchs.sh
Created September 25, 2019 03:27
List last worked branchs
#!/usr/local/bin/bash
# OS x only
function last_branchs {
readarray array <<< $(git for-each-ref --sort=-committerdate refs/heads/ --format='%(committerdate:short) %(refname:short)')
FIVE_DAYS_AGO=$(date -v-5d "+%s")
for row in "${array[@]}";do
row_array=(${row})
@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 / 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 / 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"
@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 / 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 / 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 / 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 / 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"
}