Skip to content

Instantly share code, notes, and snippets.

View samuelastech's full-sized avatar
🎯
Focusing

Samuel A. Souza samuelastech

🎯
Focusing
View GitHub Profile
@samuelastech
samuelastech / index.html
Last active April 28, 2022 13:40
Label float input by Google
<div class="container">
<label class="field-form" for="name">
<input class="field" name="name" type="text" required autocomplete="off">
<span class="label">Nome</span>
</label>
</div>
@samuelastech
samuelastech / multiplesEventsAtOnce.js
Last active April 28, 2022 13:39
Multiple JavaScript events added at once
/*
* Add multiples "Event Listener" to an element
* @param {Node} element HTML Element
* @param {String} events All the events you want separated by a space
* @param {Object} fn The function you wanna execute to all these events
*/
addEventListenerAll(element, events, fn){ // Function
events.split(' ').forEach(event => {
element.addEventListener(event, fn)
})
@samuelastech
samuelastech / numberToArray.js
Created April 26, 2022 10:32
Converting a number into array
/**
* Takes a number and create an array from it
* @param {Number} number
* @returns {Object}
*/
function numberToArray(number){
return Array.from(String(number), digit => {
return Number(digit)
})
}
@samuelastech
samuelastech / includingHTML.html
Created April 28, 2022 13:38
Using jQuery 'load' function we can break our HTML files into smaller parts
<script src="./js/jquery-3.6.0.js"></script>
<script>
$(function () {
const includes = $('[data-include]')
$.each(includes, function(){
let file = 'includes/' + $(this).data('include') + '.html'
$(this).load(file)
})
})

Conventional Commit Messages

See how a minor change to your commit message style can make a difference. Examples

Have a look at CLI util git-conventional-commits to ensure this conventions and generate changelogs

Commit Formats

Default

@samuelastech
samuelastech / git-automated-push.sh
Created September 5, 2022 14:48
Automated git add, commit, and push
#!/bin/bash
FINISHED=false
while ! $FINISHED; do
echo 'Enter the files you want to commit: '
read FILES
if [ $FILES == '.' ]; then
git add $FILES
FINISHED=true
else
@samuelastech
samuelastech / ts-node-dev.json
Last active October 3, 2022 18:21
Typescript setup
{
"scripts": {
"dev": "ts-node-dev -r tsconfig-paths/register --respawn --transpile-only --ignore-watch node_modules --no-notify bin/www.ts"
}
}
@samuelastech
samuelastech / .eslintrc.json
Last active October 3, 2022 18:33
ESLint setup
{
"env": {
"es2021": true,
"node": true,
"jest": true
},
"extends": "standard-with-typescript",
"overrides": [
],
"parserOptions": {
@samuelastech
samuelastech / jest-package.json
Last active October 3, 2022 19:19
Jest and supertest setup
{
"scripts": {
"test": "jest --watch --verbose",
"test-coverage": "jest --coverage"
},
"devDependencies": {
"@faker-js/faker": "...",
"factory-girl": "...",
"faker": "...",
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current'
}
}
],