Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Solera asolera

  • Secretaria Municipal de Inovação e Tecnologia de São Paulo
  • São Paulo
View GitHub Profile
@asolera
asolera / ad_localizar_dn.bat
Last active Jul 15, 2019
Active Directory - Localizar "dn" do usuário
View ad_localizar_dn.bat
dsquery user -samid d123456
:: Retorno => CN=Fulano da Silva,OU=Users,OU=XYZ,DC=rede,DC=sp
@asolera
asolera / sync.bat
Created Jul 15, 2019
Script de sincronização de FTP com diretório local
View sync.bat
REM --------------------------------
REM Script de sincronização do FTP 156 com diretório local
REM Autor: Andrew Solera (asolera@prefeitura.sp.gov.br)
@ECHO OFF
SET connectionname=nome_da_conexao
SET remotedir=/path/to/file/
SET localdir=C:\local_dir
SET filemask=file_mask_????????.txt
@asolera
asolera / index.js
Created Oct 22, 2019
ExpressJS - Interceptando responses (inclusão de logs) utilizando express-interceptor
View index.js
const express = require('express');
const app = express();
const interceptor = require('express-interceptor');
const responseInterceptor = interceptor((req, res) => {
return {
isInterceptable: () => true,
intercept: (body, send) => {
console.log('Intercepted!');
send(body);
@asolera
asolera / videoTimeControl.js
Created Dec 5, 2019
Add forward and backward feature to your HTML5 videos using keyboard arrows (left and right)
View videoTimeControl.js
const secondsToSkip = 3;
let video = document.getElementById("video-player_html5_api");
document.onkeydown = (event) => {
if (event.keyCode == 37) video.currentTime = video.currentTime - secondsToSkip;
if (event.keyCode == 39) video.currentTime = video.currentTime + secondsToSkip;
};
@asolera
asolera / listar.sh
Created Jan 31, 2020
Linux - Listar diretórios com o tamanho ocupado
View listar.sh
#!/bin/sh
du -sh ./*
@asolera
asolera / Dockerfile
Created May 19, 2020
Golang minimal Dockerfile image
View Dockerfile
FROM golang:1.14.3-alpine3.11 AS build
RUN apk add --no-cache git
RUN go get github.com/docker/docker/api/types
RUN go get github.com/docker/docker/client
RUN apk del git
WORKDIR /go/src/myapp
@asolera
asolera / merge.sh
Created Sep 4, 2020
Script to merge CSV files without duplicating headers
View merge.sh
#!/bin/bash
awk '(NR == 1) || (FNR > 1)' file_*.csv > files.csv
@asolera
asolera / .gitlab-ci.yml
Created Nov 4, 2020
Calling PostgreSQL script from GitLab CI
View .gitlab-ci.yml
# Credentials must be passed in through environment variables (DB_HOST, DB_PORT, DB_USER, DB_PASS, DB_NAME)
variables:
DOCKER_DRIVER: overlay2
GIT_STRATEGY: fetch
PGPASSWORD: "$DB_PASS"
services:
- docker:19.03.8-dind
stages:
@asolera
asolera / auth.xml
Created Dec 21, 2020
WSO2 Mediation Policy for External Authentication (before sending request) using Cookies
View auth.xml
<sequence name="ExternalAuth" statistics="enable" trace="enable" xmlns="http://ws.apache.org/ns/synapse">
<property expression="$axis2:REST_URL_POSTFIX" name="originalResource" scope="default" type="STRING"/>
<property action="remove" name="REST_URL_POSTFIX" scope="axis2"/>
<property name="BLOCKING_SENDER_PRESERVE_REQ_HEADERS" value="false"/>
<property name="HTTP_METHOD" scope="axis2" type="STRING" value="POST"/>
<callout initAxis2ClientOptions="false" serviceURL="https://api.external.example/auth?token=abcdefg">
<source type="envelope"/>
<target key="response"/>
</callout>
<property expression="$trp:Set-Cookie" name="setCookieHeader" scope="default" type="STRING"/>
@asolera
asolera / Dockerfile
Created Jan 11, 2021
Install Java (JDK8) inside Dockerfile from another image
View Dockerfile
FROM another/image:example
# Credits to https://stackoverflow.com/a/64062083
# some dockerfile commands...
ENV JAVA_FOLDER java-se-8u41-ri
ENV JVM_ROOT /usr/lib/jvm
ENV JAVA_PKG_NAME openjdk-8u41-b04-linux-x64-14_jan_2020.tar.gz
ENV JAVA_TAR_GZ_URL https://download.java.net/openjdk/jdk8u41/ri/$JAVA_PKG_NAME