Skip to content

Instantly share code, notes, and snippets.

View acdcjunior's full-sized avatar
🌘
It's been a hard day's night

Antônio "acdc" Jr. acdcjunior

🌘
It's been a hard day's night
View GitHub Profile
@acdcjunior
acdcjunior / sha256-hash-nodejs-browser.js
Created May 20, 2024 23:12
Generate sha256 hash for a buffer - browser and node.js
/*
* Sometimes you want to hash stuff on the client and on the server to test if
* data transmission is happening okay. These functions to that.
*/
// node.js
import crypto from 'node:crypto';
async function calculateHashForArrayBuffer(data: ArrayBuffer) {
@acdcjunior
acdcjunior / project.iml
Created May 9, 2024 00:15
Generic IML file for Web Projects on IntelliJ IDEA
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
killer() {
echo "Will now kill '$1'..."
for p in $(ps aux | grep "$1" | grep -v grep | awk '{print $2}'); do
echo "killing $p"
kill -9 $p || true
done
echo "Done killing '$1'."
}
export const eventLoopLag = (() => {
let count = 0;
let avg: number | null = null;
let max: number | null = null;
const avgMax = () => `Average: ${avg?.toFixed(1)} ms - Max: ${max?.toFixed(1)} ms`;
const track = (countAverages = false, printAveragesEvery = 1_000_000, printImmediatelyThresholdMs = 10) => {
const start = performance.now();
setImmediate(() => {
const delay = performance.now() - start;
@acdcjunior
acdcjunior / cdk-bootstrap.json
Created September 15, 2023 01:15
CDK Bootstrap Minimal Permissions
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "CdkBoostrapPermissions1of5",
"Action": [
"cloudformation:CreateChangeSet",
"cloudformation:DeleteStack",
"cloudformation:DescribeChangeSet",
"cloudformation:DescribeStackEvents",
@acdcjunior
acdcjunior / react.md
Created October 26, 2022 20:10
React from CDN
const {
  Container,
  Pagination,
} = MaterialUI;

function App() {

@acdcjunior
acdcjunior / index.html
Created October 19, 2022 03:09
jquery document ready window load
<!DOCTYPE html>
<html>
<head>
<script
type="text/javascript"
src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js"
></script>
</head>
<body>
<pre id="out"></pre>
@acdcjunior
acdcjunior / index.html
Last active August 2, 2022 04:22
TOUCH OR HOVER DEVICES?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Touch or Hover device?</title>
<style>
@media (hover: hover) {
#hover-hover { background: blue; color: white; }
#hover-hover::after { content: " YES"; }
@acdcjunior
acdcjunior / index.html
Created February 4, 2022 04:57
overlay
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<title>Test</title>
</head>
<body>
<script src="https://gumroad.dev/js/gumroad.js"></script>
<a class="gumroad-button" href="https://gumseller.gumroad.dev/l/h">Buy on</a>
</boby>
@acdcjunior
acdcjunior / docker-compose.yml
Last active December 9, 2020 20:23
Basic Kafka + Kafka GitOps
version: '2.1'
services:
kafka-zookeeper-1:
image: zookeeper:3.4.9
hostname: kafka-zookeeper-1
ports:
- "2181:2181"
environment:
ZOO_MY_ID: 1