Skip to content

Instantly share code, notes, and snippets.

View uqmessias's full-sized avatar
🤓
Being a Nerd...

Uilque Messias uqmessias

🤓
Being a Nerd...
View GitHub Profile
@uqmessias
uqmessias / README.md
Last active April 4, 2018 04:20
Exercício de turnos

Problema

Janio trabalha em uma empresa em três turnos sequenciais (manhã, tarde e a noite). Ele trabalha dois dias em cada turno e quando trabalha no último turno (noite), tem dois dias de folga (folga).

Nos dias 02 e 03 de Abril ele trabalha no turno da manhã. Dado um primeiro dia do primeiro turno (02/04/2018 para o turno da manhã) e a quantidade de terças-feira seguintes (5 por exemplo), devolva as próximas terças-feira e em quais ele poderá participar da sessão de programação.

As sessões acontecem à noite e por isso nos dias de terça-feira em que ele trabalha à noite, não poderá participar da sessão.

@uqmessias
uqmessias / .gitconfig
Last active July 23, 2019 18:20
My default .gitconfig with some alias
[user]
name = Uilque Messias
[alias]
graph = log --graph --oneline --all --decorate --stat
graphall = log --graph --all --decorate --stat
pull = pull --rebase
graphline = log --graph --oneline --all --decorate
delbranch = "!f() { git push origin :\"$1\" --no-verify && git branch -d \"$1\"; }; f"
contributors = shortlog -s -n --no-merges
@uqmessias
uqmessias / all-png-to-svg.sh
Created March 13, 2018 19:00
Single line command to convert all png in the current directory to svg files.
( set -x ; for f_png in *.png ; do f="${f_png%.png}" ; convert "$f_png" -flatten "$f.pgm" && potrace "$f.pgm" -s -o "$f.svg" ; done )
// @flow
export type TimePeriod = 'am' | 'pm';
export type TimeOfTheDay = { hour: number, minute: number, period: TimePeriod };
const getTimeOfTheDay = (date: Date): TimeOfTheDay => ({
hour: date.getHours() > 12 ? date.getHours() - 12 : date.getHours(),
minute: date.getMinutes(),
period: date.getHours() >= 12 ? 'pm' : 'am',
});
@uqmessias
uqmessias / logNavigationRoute.js
Last active March 5, 2018 20:38
This is a function to log (in form of a tree) the navigation based on `react-navigation` and redux state of this navigation.
type NavigationRoute = {
index?: ?number,
routeName: string,
routes?: ?Array<NavigationRoute>,
};
type FormattedState = {
children: Array<FormattedState>,
routeName: string,
@uqmessias
uqmessias / loan-of-108000-reais-to-buy-a-house-from-caixa-federal.js
Last active March 7, 2019 16:27
This is some data extracted from a simulation at http://www8.caixa.gov.br/siopiinternet-web/simulaOperacaoInternet.do?method=inicializarCasoUso in order to get some money to buy an apartment in Brazil.
const payments = [
{
"nr": 1,
"payment": 1180.01
},
{
"nr": 2,
"payment": 1177.81
},
{
@uqmessias
uqmessias / replaceAtRouteName.js
Last active October 20, 2017 19:00
Function to replace route in a state with another route by routeName property
const replaceAtRouteName = (state, routeName, route) => {
if (!route || !routeName || !state.routes) {
return state
}
const newState = { ...state }
let replaced = false
state.routes.forEach((value, index) => {
let replacedRoute = value
@uqmessias
uqmessias / removeAtRouteName.js
Last active March 27, 2019 23:28
Function to remove an single route from the navigation.route of react-navigation module
const removeAtRouteName = (state, routeName) => {
if (!routeName || !state.routes || !state.routes.length) {
return state;
}
const newState = { ...state };
let removed = false;
state.routes.forEach((currentRoute, index) => {
if (currentRoute.routeName === routeName) {
@uqmessias
uqmessias / .editorconfig
Last active July 23, 2019 18:46
Function to select the current screen on an react-navigation.navigation.routes
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
@uqmessias
uqmessias / normalize-dates-and-remove-reply-and-like-link-on-facebook.js
Last active October 27, 2020 00:55
My wife did want to save some screenshots of our posts on facebook, but she wanted to remove all *like* and *reply* buttons. Besides, she wanted to change the relative date and time to an absotule one.