Skip to content

Instantly share code, notes, and snippets.

View klaytonfaria's full-sized avatar
🧪
Focusing

Klayton Faria klaytonfaria

🧪
Focusing
View GitHub Profile

Script to track % of TypeScript in your repo / project

If you are migrating to TypeScript it may be nice to keep track of how you are doing for a particular project, here is an example of using Tokei and jq to do this.

You can install both via Homebrew

  • brew install jq
  • brew install tokei
sudo iptables -I INPUT 2 -p tcp --dport 443 -j ACCEPT
sudo iptables -I INPUT 2 -p tcp --dport 80 -j ACCEPT
sudo iptables-save > /etc/iptables/rules.v4
@klaytonfaria
klaytonfaria / sentry.nginx.conf
Created January 23, 2019 15:56
Sentry NGINX config
server {
listen 80 default_server;
server_name sentry.xablau.com;
location / {
proxy_pass http://127.0.0.1:9000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const sourcePath = process.argv[ 2 ] || './example/files.json';
const fileList = require(path.resolve(__dirname, '../', sourcePath));
const outputPath = process.argv[ 3 ] || './Static/';
const findProcessTag = tag => process.argv.some(val => val.indexOf(tag) >= 0);
export default {
dest: './public',
base: '/',
hashRouter: true,
codeSandbox: false,
files: './docs/**/*.mdx',
themeConfig: {
logo: {
src: 'https://instagram.flis8-2.fna.fbcdn.net/vp/7d2e51b014efca981d3a8eb4bf5c3d07/5C916DBF/t51.2885-19/s320x320/14482113_1143788649039310_7192075474778980352_a.jpg',
width: 160,
@klaytonfaria
klaytonfaria / component-orchestrator.js
Created April 26, 2018 22:07
React component orchestrator schema
const orchestrator = {
// slug: String,
// title: String,
// description: String,
// step: Number,
// steps: Number,
items: [Object],
// progress: Number,
// progressType: String,
// startedAt: Date,
@klaytonfaria
klaytonfaria / index.js
Last active February 7, 2024 09:52
React-native MessageQueue.spy use
import React from 'react';
import {AppRegistry} from 'react-native';
import MainScreen from './screens/main';
import relayContainer from 'shared/relay-container';
import MessageQueue from 'react-native/Libraries/BatchedBridge/MessageQueue';
AppRegistry.registerComponent('MainScreen', () => relayContainer(MainScreen));
// Disable warning box on development mode
console.disableYellowBox = true;

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@klaytonfaria
klaytonfaria / .tmux.conf
Last active July 13, 2018 10:46
My tmux conf
# General settings {
# loud or quiet?
set-option -g visual-activity off
set-option -g visual-bell off
set-option -g visual-silence off
set-window-option -g monitor-activity off
set-option -g bell-action none
# Allows for faster key repetition
set -s escape-time 0
# Reload tmux
@klaytonfaria
klaytonfaria / renavam.js
Last active September 15, 2017 23:07
Validador de RENAVAM
function isRenavam(renavam = '') {
// Converte renavam em string e completa com zeros à esquerda, para que fique com 11 dígitos
renavam = (Array(11).join("0") + String(parseInt(renavam, 10))).slice(-11);
// Soma dos produtos dos 10 primeiros dígitos do renavam com os da sequência de multiplicadores (peso com base modulo11)
const CONTROL = '3298765432'.split('');
const renavamTen = renavam.substring(0, 10).split('');
let sum = 0;
CONTROL.map((item, i) => sum += (item * renavamTen[i]));
// Calcula a diferença entre 11 e o resto da divisão da soma por 11
let digit = 11 - (sum % 11);