Skip to content

Instantly share code, notes, and snippets.

View armand1m's full-sized avatar

Armando Magalhães armand1m

View GitHub Profile
@armand1m
armand1m / .emscripten
Created November 19, 2017 16:39
Fix emscripten LLVM problems
# Replace the path for LLVM and Emscripten for these:
EMSCRIPTEN_ROOT = os.path.expanduser(
os.getenv('EMSCRIPTEN') or
'/usr/local/opt/emscripten/libexec')
LLVM_ROOT = os.path.expanduser(
os.getenv('LLVM') or
'/usr/local/opt/emscripten/libexec/llvm/bin')
@armand1m
armand1m / paginate.js
Last active March 4, 2018 23:13
simple and naive js object pagination implementation
const paginate = (array, pageSize) => {
const numberOfPages = Math.round(array.length / pageSize);
const needsOneMorePage = array.length % pageSize;
const totalNumberOfPages = needsOneMorePage
? numberOfPages + 1
: numberOfPages;
const iterableNumberOfPages = [
...Array(totalNumberOfPages).keys()
@armand1m
armand1m / jsconfig.json
Created April 29, 2018 12:31
VSCode Intellisense for Javascript projects with Module path alias
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"allowSyntheticDefaultImports": true,
"baseUrl": "./",
"paths": {
"Api/*": ["./src/api/*"],
"Components/*": ["./src/components/*"]
}
@armand1m
armand1m / setupTests.js
Created June 6, 2018 00:09
CRA Jest setup tests file with window.mediaMatch a simple mock
/**
* window.matchMedia mock
*
* it also exposes a custom global method called setMatchMediaProperties
* that accepts an object as parameter to merge with the default MatchMedia properties.
*/
(function matchMediaMock() {
const defaultMatchMedia = {
matches: false,
addListener() {},
@armand1m
armand1m / setupTests.js
Created August 5, 2018 20:22
My usual jest setup file
/**
* prepareDom method
*
* just creates the DOM structure needed to render
* this application before running tests.
*
* it is needed to test the `index.js` file of the project.
*/
(function prepareDom() {
document.body.innerHTML = '<div id="root"></div>';
@armand1m
armand1m / results-first-page.txt
Last active February 21, 2019 16:09
Table of reimbursements higher than 1000 BRL for BOLSONARO family. Exactly 1082 reimbursements higher than 1000 BRL.
┌──────────┬──────────────────────────┬──────────────────────────────────────────────────────────────┬────────────┬─────────┬─────────────────────────────────────────────────────────────────────────────────┐
│ Position │ Name │ What for │ Date │ Price │ Receipt │
├──────────┼──────────────────────────┼──────────────────────────────────────────────────────────────┼────────────┼─────────┼─────────────────────────────────────────────────────────────────────────────────┤
│ 16 │ EDUARDO BOLSONARO │ Maintenance of office supporting parliamentary activity │ 2018-08-02 │ 4200 │ http://www.camara.gov.br/cota-parlamentar/documentos/publ/2907/2018/6649961.pdf │
├──────────┼──────────────────────────┼──────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────────────────────────────────────────────
@armand1m
armand1m / CreditCardDetector.js
Created November 5, 2018 11:20
CreditCardDetector.js extracted from Cleave.js code
'use strict';
var CreditCardDetector = {
blocks: {
uatp: [4, 5, 6],
amex: [4, 6, 5],
diners: [4, 6, 4],
discover: [4, 4, 4, 4],
mastercard: [4, 4, 4, 4],
dankort: [4, 4, 4, 4],
{
"rules": {
".read": "auth.uid !== null && auth.provider === 'google'",
".write": "auth.uid !== null && auth.provider === 'google'"
}
}
@armand1m
armand1m / Dockerfile
Created February 21, 2019 16:08
Dockerfile with pre configured environment for playing with Fable F#
FROM mono:latest
RUN apt-get update
RUN apt-get install -y apt-transport-https
RUN curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
RUN mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
RUN curl -slO https://packages.microsoft.com/config/debian/8/prod.list
RUN mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
RUN chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
RUN chown root:root /etc/apt/sources.list.d/microsoft-prod.list
@armand1m
armand1m / debug-nm-l2tp-service.sh
Created April 10, 2019 08:38
stupid script to remind me how to debug network manager
sudo /usr/lib/NetworkManager/nm-l2tp-service --debug