Skip to content

Instantly share code, notes, and snippets.

@luistak
luistak / jqueryQueue.js
Last active February 9, 2020 02:41
Jquery Ajax queue
var ajax = {};
ajax.POST = 1;
ajax.GET = 2;
ajax.checkTimeout;
ajax.setup = function() {
if (ajax.loaded) {
return;
{
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true,
"editor.tabSize": 2,
"editor.fontSize": 15,
"editor.renderWhitespace": "all",
"eslint.workingDirectories": [
{
"directory": "packages/web",
"changeProcessCWD": true
@luistak
luistak / prepend-file.sh
Created April 2, 2020 15:43
Shell Script to prepend some content into any file
#!/bin/bash
FILE=$1
DATA=$2
cat <<-EOF > $FILE
$(echo -e $DATA)
$(cat $FILE)
EOF
type ThemedCss = FlattenInterpolation<ThemeProps<DefaultTheme>>;
type VariantOptions<T extends string> = {
variant: T | undefined;
variants: Record<T, ThemedCss>;
defaultStyle: ThemedCss;
};
type VariantCallback<T, K extends string> = (props: T) => VariantOptions<K>;
@luistak
luistak / setup-tests.md
Last active December 9, 2023 19:20
Testing-library Setup to a react tsdx library
  1. Install Testing library packages and types
yarn add --dev @testing-library/jest-dom @types/testing-library__jest-dom @testing-library/react @testing-library/user-event
  1. Create setupTests.ts file at /src with this content:
import '@testing-library/jest-dom/extend-expect';
  1. Add jest dom sixteen
@luistak
luistak / klebin.js
Created January 7, 2021 16:37
teste
#!/usr/bin/env node
console.log(' ó o exemplo aqui menó ');
@luistak
luistak / events-mf1.js
Created January 27, 2021 15:05
Cross micro frontends communication Gists
function App() {
const [messages, setMessages] = useState([]);
const handleNewMessage = (event) => {
setMessages((currentMessages) => currentMessages.concat(event.detail));
};
useEffect(() => {
window.addEventListener('message', handleNewMessage);
function App() {
const [messages, setMessages] = useState([]);
const handleNewMessage = (event) => {
setMessages((currentMessages) => currentMessages.concat(event.detail));
};
useEffect(() => {
window.addEventListener('message', handleNewMessage);
function App({ onNewMessage }) {
const handleSubmit = (e) => {
e.preventDefault();
const { target: form } = e;
const input = form?.elements?.something;
const customEvent = new CustomEvent('message', { detail: input.value });
window.dispatchEvent(customEvent)
form.reset();
const App = ({ microfrontends }) => {
const [messages, setMessages] = useState([]);
const handleNewMessage = (message) => {
setMessages((currentMessages) => currentMessages.concat(message));
};
return (
<main className="App">
<div className="App__header">