Skip to content

Instantly share code, notes, and snippets.

View MatMercer's full-sized avatar
🎯
Focusing

Mateus Mercer MatMercer

🎯
Focusing
View GitHub Profile
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@MatMercer
MatMercer / dicto_closured.py
Last active June 16, 2017 02:19
Returns a dictionary with all functions closure levels inside a class.
"""
Recipe by Mateus Mercer ~ [email protected]
This code is released with the MIT license, if you
didn't got a copy, get a copy at https://opensource.org/licenses/MIT
12/2016
"""
@MatMercer
MatMercer / !_usage.md
Last active March 31, 2018 21:54
Syncig musics files to a Android phone using a command line.

Syncing music files to a Android phone

I use Simple MTPFS to access the Android phone and rsync to sync the music files.

Demo Usage

./mount_android.sh ~/Documents/temp/android     
Trying to mount android to '/home/mat/Documents/temp/android'.
Could not retrieve device storage.
@MatMercer
MatMercer / snakefy.js
Last active April 16, 2018 18:55
Snake matrix algorithm in JS
function createMatrix(x, y) {
matrix = new Array(y);
// Popula matriz
for (var i = matrix.length - 1; i >= 0; i--) {
matrix[i] = new Array(x)
}
return matrix;
}
@MatMercer
MatMercer / forca.java
Created February 26, 2019 12:44
Jogo da Forca
package net.matbm.forca;
import java.util.Scanner;
import static java.lang.System.out;
public class Main {
public static void main(String[] args) {
String palavra = "otorrinolaringologista";
int maxErro = 5;
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match *://*/*
// @grant none
// @require https://code.jquery.com/jquery-3.4.1.slim.min.js
// ==/UserScript==
@MatMercer
MatMercer / states.js
Last active December 27, 2019 02:21
Simple way of having a clean code in JS using object literals
var capitalByState = {
'MG': 'Belo Horizonte',
'PR': 'Curitiba',
'SP': 'São Paulo'
} // Allocated only one time and the data isn't INSIDE the function
// so 'capitalByState' can come from a external source!
var States = {};
States.getCapitalCity = state => capitalByState[state] || 'Not Found'; // Again, allocated only one time, simulates static
@MatMercer
MatMercer / main.cpp
Created January 16, 2021 23:07
Sort algorithms with struct templates in C++
#include <iostream>
#include <vector>
#include "sortalgs.h"
int main(int argc, char **argv) {
std::vector<int> v = {1, 5, 2, 3, -3, -2, -1, 0, 3, 1};
sortalg<Bubble>::sort(v.begin(), v.end());
auto start = v.begin();
@MatMercer
MatMercer / explode.py
Last active March 27, 2021 17:55
Explode notifications in your computer - pip install notify-py
# CREATES 100 notifications in your desktop, super dangerous script, beware
from notifypy import Notify
import threading
ammount = 100
def notify(num):
notification = Notify()
notification.title = "Cool Title: " + str(num)
@MatMercer
MatMercer / wsl-vpn-fix.sh
Last active August 23, 2022 06:24
Fix WSL 2 DNS resolution when connected to Cisco AnyConnect VPN
#!/bin/bash
#--------------------------------------------------------------------------------#
# #
# Fix WSL DNS resolution with Cisco AnyConnect #
# #
# ! Don't forget to set this configuration in /etc/wsl.conf: #
# [network] #
# generateResolvConf = false #
# #
# Based on: #