Skip to content

Instantly share code, notes, and snippets.

🤓
Being a Nerd...

Uilque Messias uqmessias

🤓
Being a Nerd...
Block or report user

Report or block uqmessias

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@uqmessias
uqmessias / move-files-back.js
Last active Apr 23, 2018
Script to rename and organize all files from my Onedrive photo folder
View move-files-back.js
const fs = require('fs');
const albumPath = '/home/uqmessias/OneDrive/Imagens/Álbum\ da\ Câmera';
const albumNewPath = '/home/uqmessias/development/rename-files/files';
const handleFile = (dirPath, fileName) => {
const fileOldPath = `${dirPath}/${fileName}`;
const stats = fs.statSync(fileOldPath);
const fileNewPath = `${albumNewPath}/${fileName}`;
const atime = new Date(stats.atimeMs);
const mtime = new Date(stats.mtimeMs);
View index.canvas.html
<html>
<head>
<title>Bouncing Circles</title>
<script>
// shim layer with setTimeout fallback
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
@uqmessias
uqmessias / README.md
Last active Apr 4, 2018
Exercício de turnos
View README.md

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 Jul 23, 2019
My default .gitconfig with some alias
View .gitconfig
[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 Mar 13, 2018
Single line command to convert all png in the current directory to svg files.
View all-png-to-svg.sh
( 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 )
View date-to-period.js
// @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 Mar 5, 2018
This is a function to log (in form of a tree) the navigation based on `react-navigation` and redux state of this navigation.
View logNavigationRoute.js
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 Mar 7, 2019
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.
View loan-of-108000-reais-to-buy-a-house-from-caixa-federal.js
const payments = [
{
"nr": 1,
"payment": 1180.01
},
{
"nr": 2,
"payment": 1177.81
},
{
@uqmessias
uqmessias / replaceAtRouteName.js
Last active Oct 20, 2017
Function to replace route in a state with another route by routeName property
View replaceAtRouteName.js
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 Mar 27, 2019
Function to remove an single route from the navigation.route of react-navigation module
View removeAtRouteName.js
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) {
You can’t perform that action at this time.