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 / 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 / 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,
// @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 / 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 )
@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 / index.canvas.html
Created April 7, 2018 23:08
playing on canvas
<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 / move-files-back.js
Last active April 23, 2018 12:31
Script to rename and organize all files from my Onedrive photo folder
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);
@uqmessias
uqmessias / easing.js
Created June 14, 2018 15:08 — forked from gre/easing.js
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity
@uqmessias
uqmessias / easing.js
Created June 14, 2018 15:08 — forked from gre/easing.js
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity
@uqmessias
uqmessias / ogl_osx.md
Created June 19, 2018 15:32 — forked from v3n/ogl_osx.md
GLFW on OS X starting guide

OpenGL Development on OS X

While it's possible to download packages and install them manually, it's such a hassle. Fortunately for us, OS X has an unofficial package manager called http://brew.sh Let's install it. Open you Terminal and paste the following code:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Great. Homebrew will automatically install packages to /usr/local. Conveniently, that directory is already in your include and link paths.