Skip to content

Instantly share code, notes, and snippets.

View MarcosSantosDev's full-sized avatar
👨‍💻
studying react native

Marcos Adriano Ferreira Dos Santos MarcosSantosDev

👨‍💻
studying react native
View GitHub Profile
@MarcosSantosDev
MarcosSantosDev / user.mock.ts
Created February 28, 2024 00:16
msw with fake data
import { factory } from '@mswjs/data';
import { http, HttpResponse } from 'msw';
import { faker } from '@faker-js/faker';
import { primaryKey } from '@mswjs/data';
type User = {
id: string;
firstName: string;
};
@MarcosSantosDev
MarcosSantosDev / crypto.ts
Created February 2, 2023 15:49
Using the "crypto-js" library with encryption and decryption methods
import CryptoJS from 'crypto-js';
export const encryptData = <T = unknown>(secretPass: string, data: T) => {
const encryptedData = CryptoJS.AES.encrypt(
JSON.stringify(data),
secretPass,
).toString();
return encryptedData;
};
@MarcosSantosDev
MarcosSantosDev / useEncryptedLocalStorage.ts
Last active February 2, 2023 15:52
Hook to use encrypted local storage
/**
* Encryption methods and encryption removal
*/
# const encryptData = <T = unknown>(secretPass: string, data: T) => ...
# const decryptData = <T = unknown>(secretPass: string, encryptedData: string): T => ...
/**
* Secret key to use for encryption and decryption
*/
# const SECRET_PASS_LOCAL_STORAGE = '...'
@MarcosSantosDev
MarcosSantosDev / printHtml.ts
Created December 22, 2022 15:49
Print Html
type PrintHtmlParams = {
/**
* `containerId`:
* - Index of the element where the content to be printed will be assembled
*/
containerId: string;
/**
* `elementHtml`:
* - Content to be printed
*/
@MarcosSantosDev
MarcosSantosDev / getCookies.js
Last active August 22, 2022 14:13
Get cookies
/** Step 1
*
* Get cookies from a tab
*/
const getCookies = (keys = []) => {
const cookies = document.cookie;
const cookiesSplited = cookies.split('; ');
const myCookies = cookiesSplited.filter(cookie => {
const [key, value] = cookie.split('=');
@MarcosSantosDev
MarcosSantosDev / slack-messaging
Created July 2, 2022 18:03
A simple application with integration to the slack messaging API.
'use strict'
const axios = require('axios');
require('dotenv').config();
const getData = async () => {
const result = await axios.get('https://next.json-generator.com/api/json/get/4JJYrbRxu');
return result.data.map(person => ({
age: person.age,
@MarcosSantosDev
MarcosSantosDev / settings.json
Last active May 17, 2023 15:10
visual code settings.json
{
"workbench.iconTheme": "material-icon-theme",
"workbench.colorTheme": "Hack The Box-Lite",
"launch": {
"configurations": [],
"compounds": []
},
"editor.fontFamily": "Fira Code",
"editor.fontSize": 14,
"editor.lineHeight": 20,