Skip to content

Instantly share code, notes, and snippets.

View DouglasdeMoura's full-sized avatar

Douglas Moura DouglasdeMoura

View GitHub Profile
@DouglasdeMoura
DouglasdeMoura / input.spec.tsx
Last active February 15, 2022 11:31
Simple React Input validation
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { Input } from '.'
describe('<Input />', () => {
it('should render the component', () => {
render(<Input label="mock_label" />)
expect(screen.getByLabelText('mock_label')).toBeInTheDocument()
@DouglasdeMoura
DouglasdeMoura / .editorconfig
Last active September 7, 2021 15:08
React template
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
@DouglasdeMoura
DouglasdeMoura / styles.css
Last active February 17, 2021 18:13
Tailwind CSS colors as CSS variables (v2.0.3)
:root {
--color-blue-gray-50: #F8FAFC;
--color-blue-gray-100: #F1F5F9;
--color-blue-gray-200: #E2E8F0;
--color-blue-gray-300: #CBD5E1;
--color-blue-gray-400: #94A3B8;
--color-blue-gray-500: #64748B;
--color-blue-gray-600: #475569;
--color-blue-gray-700: #334155;
--color-blue-gray-800: #1E293B;
@DouglasdeMoura
DouglasdeMoura / converter.fish
Last active January 17, 2021 18:03
Converting image to base64 on Linux
bash { echo "data:image/png;base64,"; openssl enc -base64 -in src/pages/Index/images/input.png; } > output.b64
# Remove new lines
echo (tr -d "\n\r" < output.b64) >> output_without_new_lines.b64
@DouglasdeMoura
DouglasdeMoura / dev-environment.sh
Last active February 26, 2021 12:00
Script to install my development tools on fresh Ubuntu installations
#!/bin/sh
# Add fish PPA
sudo apt-add-repository ppa:fish-shell/release-3
sudo apt update
# Install minimal tools
sudo apt install fish git dirmngr gpg vim -y
# Set fish as default shell
@DouglasdeMoura
DouglasdeMoura / bookmarklet.js
Last active October 25, 2020 15:27
Control YouTube playback rate
/*
* JAVASCRIPT BOOKMARKLET
*
* In order to have this function always at hand and use it in
* any website, just add the code below to a bookmark in your favorite browser.
* Every time you click it, the browser will prompt you for a new playback
* rate for first video in the page.
*/
javascript:(function() {
@DouglasdeMoura
DouglasdeMoura / keybindings.ahk
Created May 27, 2019 19:15
AutoHotKey Script for whom got used to Dell's laptops Fn + Arrow behavior
#Right::Send {End} ; Windows + Right Arrow = End
#Left::Send {Home} ; Windows + Right Arrow = Home
#+Right::Send +{End} ; Windows + Right Arrow + Shift = Select to the End
#+Left::Send +{Home} ; Windows + Right Left + Shift = Select to the Home
@DouglasdeMoura
DouglasdeMoura / custom_query.php
Last active October 23, 2017 18:48
Executar WP_Query randomicamente a cada 30 minutos
<?php
$cache_key = 'categoria-da-home';
if ( ! $ids = get_transient( $cache_key ) ) {
//Essa query pega apenas os IDs dos posts
$query = new WP_Query( [
'fields' => 'ids',
'posts_per_page' => 15,
'cat' => 5, //ID da categoria
@DouglasdeMoura
DouglasdeMoura / query.php
Last active October 13, 2017 18:50
WP_Query by date
<?php
function dougmoura_query_by_date( $ano = null, $mes = null, $dia = null ) {
// Retorna uma matriz com o dia de hoje. Veja http://php.net/manual/en/function.getdate.php
$hoje = getdate();
if ( null === $ano )
$ano = $hoje['year'];
if ( null === $mes )
@DouglasdeMoura
DouglasdeMoura / es_input.cfg
Last active February 24, 2017 00:43
EmulationStation + Retroach + Kodi on Ubuntu Minimal
<?xml version="1.0"?>
<inputList>
<inputConfig type="keyboard" deviceName="Keyboard" deviceGUID="-1">
<input name="a" type="key" id="115" value="1" />
<input name="b" type="key" id="97" value="1" />
<input name="down" type="key" id="1073741905" value="1" />
<input name="left" type="key" id="1073741904" value="1" />
<input name="pagedown" type="key" id="1073741902" value="1" />
<input name="pageup" type="key" id="1073741899" value="1" />
<input name="right" type="key" id="1073741903" value="1" />