Skip to content

Instantly share code, notes, and snippets.

@marciojrtorres
marciojrtorres / javascript_programacao_defensiva.js
Created August 5, 2013 20:41
Arrumando a casa com técnicas de programação defensiva
function dobro(n) {
if (typeof(n) != "number") return 0; // se n não é um número retorne 0
return n * 2;
}
document.write(dobro(2)); // ok, imprime 4
document.write(dobro("t")); // ok, "t" não é do tipo number, então imprime 0

Github Two-Factor Authentication (2FA) for Brazil via SMS

The Github doesn't provide country code for Brazil (+55). To add this option, just run the code below in your console. The option Brazil +55 will be the first on the list, already selected:


🇧🇷 [pt-BR]

Autenticação em dois fatores (2FA) do GitHub para o Brasil via SMS

@robertknight
robertknight / Build.md
Last active July 8, 2022 01:32
Minimal Webpack DllPlugin example

Compile with:

webpack --config vendor.webpack.config.js
webpack --config app.webpack.config.js

Use with the following index.html

@tomysmile
tomysmile / mac-setup-redis.md
Last active March 18, 2024 22:12
Brew install Redis on Mac

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis
@sibelius
sibelius / learning.md
Last active August 23, 2023 13:21
Learning Path React Native

Basics

  • Learn how to start a new react native project
  • Run it on ios simulator, on android emulator, on a real iPhone device and on a real Android device, with and without debugging enabled.
  • Learn how to upgrade a react native project
  • Learn how to add a package to the project
  • Learn how to add a package that has a native dependency (https://github.com/airbnb/react-native-maps, https://github.com/evollu/react-native-fcm) - DO NOT USE COCOAPODS
  • Learn how to use fetch to get data from your backend

Learn Navigation

@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active May 3, 2024 01:37
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@hagemann
hagemann / slugify.js
Last active October 30, 2023 09:10
Slugify makes a string URI-friendly
function slugify(string) {
const a = 'àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìıİłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;'
const b = 'aaaaaaaaaacccddeeeeeeeegghiiiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------'
const p = new RegExp(a.split('').join('|'), 'g')
return string.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters
.replace(/&/g, '-and-') // Replace & with 'and'
.replace(/[^\w\-]+/g, '') // Remove all non-word characters
@elijahmanor
elijahmanor / index-0-non-debounced.js
Last active December 20, 2022 21:14
React Debouncing Events
import React, { Component } from "react";
import { render } from "react-dom";
import "./index.css";
class Widget extends Component {
state = { text: "" };
handleChange = (e) => {
this.setState({ text: e.target.value });
};
render() {
@melloc01
melloc01 / cloudSettings
Last active September 24, 2021 14:43
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-12-19T18:25:14.965Z","extensionVersion":"v3.2.4"}
@sibelius
sibelius / authenticatedMidldeware.tsx
Created February 15, 2019 12:16
Auth middleware to use with RR4
import * as React from 'react';
import { withRouter } from 'react-router-dom';
import { isLoggedIn } from '../../security/authentication';
import routeTo from '../utils/routeTo';
const authenticatedMiddleware = Component => {
class AuthenticatedMiddleware extends React.PureComponent {
componentDidMount() {
this.redirectIfNotAuthenticated();