Navigation Menu

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 / 5051.html
Created August 22, 2019 00:57
iframe window.postMessage example (inter-frame CORS communication)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>5051</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.js"></script>
</head>
<body>
<h1>5051</h1>
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import java.util.HashMap;
import java.util.Map;
@SuppressWarnings({"unused", "FieldCanBeLocal"})
public class LinkedResource<T> {
#!/bin/bash
set -eu
SENTRY_DOWNLOAD_Linux_i686="https://downloads.sentry-cdn.com/sentry-cli/1.46.0/sentry-cli-Linux-i686"
SENTRY_DOWNLOAD_Windows_x86_64="https://downloads.sentry-cdn.com/sentry-cli/1.46.0/sentry-cli-Windows-x86_64.exe"
SENTRY_DOWNLOAD_Darwin_x86_64="https://downloads.sentry-cdn.com/sentry-cli/1.46.0/sentry-cli-Darwin-x86_64"
SENTRY_DOWNLOAD_Linux_x86_64="https://downloads.sentry-cdn.com/sentry-cli/1.46.0/sentry-cli-Linux-x86_64"
VERSION="1.46.0"
PLATFORM=`uname -s`
ARCH=`uname -m`
@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) };
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Import;
import org.springframework.core.env.ConfigurableEnvironment;
sourceSets.test.resources.srcDirs = ["src/test/java"]
sourceSets.test.resources.includes = ["**/*.sql"]
sourceSets.test.resources.srcDir 'src/test/resources'
@Sql
@Sql(statements = "DELETE FROM CLIENTE WHERE SENHA = '7777'", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
@acdcjunior
acdcjunior / BobCaller.java
Created April 30, 2019 18:02
Spring: Async Parallel Limited by Thread Pool Count
package tdd.caixaeletronico;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.stream.Collectors;
@acdcjunior
acdcjunior / discover process at port.ps
Created April 25, 2019 21:03
discover process at port.ps
Get-Process -Id (Get-NetTCPConnection -LocalPort 8290).OwningProcess
@acdcjunior
acdcjunior / js_to_ts.md
Created April 14, 2019 05:02
Convert a JS project to TS

Run shell:

npm i -S typescript ts-node
npm i -D @types/node @types/jasmine

cd src
for file in $(find . -name '*.js'); do mv "$file" "${file%.js}.ts"; done
for file in $(find . -name '*.ts'); do sed -i 's/module\.exports =/export =/g' $file; done

Change package.json scripts:

@acdcjunior
acdcjunior / DDD.java
Created June 29, 2018 21:44
DDD Annotations for Java
import java.lang.annotation.*;
public class DDD {
@Target(ElementType.TYPE) @Retention(RetentionPolicy.SOURCE) public @interface ApplicationService { }
@Target(ElementType.TYPE) @Retention(RetentionPolicy.SOURCE) public @interface DomainService { }
@Target(ElementType.TYPE) @Retention(RetentionPolicy.SOURCE) public @interface AggregateRootEntity { }
@Target(ElementType.TYPE) @Retention(RetentionPolicy.SOURCE) public @interface NonAggregateRootEntity { }
@Target(ElementType.TYPE) @Retention(RetentionPolicy.SOURCE) public @interface ValueObject { }
@Target(ElementType.TYPE) @Retention(RetentionPolicy.SOURCE) public @interface Repository { }
@Target(ElementType.TYPE) @Retention(RetentionPolicy.SOURCE) public @interface Factory { }