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
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 / Dummies.java
Created January 23, 2016 23:36
Mockito: create a mock object that throws exception at any method call (so... a Dummy object, not a mock)
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import static org.mockito.Mockito.mock;
public class Dummies {
private static class NoMethodShouldBeCalledAnswer implements Answer<Object> {
private String className;
@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 / di-via-monads-js-ts.ts
Created June 29, 2019 09:40
Dependency Injection via Monads in JavaScript/TypeScript
import axios, {AxiosInstance} from 'axios';
interface Context {
get(s: string): any;
headersForResource(id: number): any;
}
class Contextual<T> {
constructor(private g: (ctx: Context) => T) {}
run(ctx: Context): T { return this.g(ctx) };
@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