Skip to content

Instantly share code, notes, and snippets.

View danielpsf's full-sized avatar

Daniel Fernandes danielpsf

View GitHub Profile
@miguelmota
miguelmota / ssm_parameter.go
Last active September 26, 2023 10:36
AWS SSM Go SDK parameter store example
package main
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ssm"
)
@crgimenes
crgimenes / stringToReaderCloser.go
Last active April 11, 2024 15:41
string to io.ReadCloser
package main
import (
"bytes"
"fmt"
"io"
"os"
"strings"
)
@igorrendulic
igorrendulic / MailGun.java
Created December 3, 2017 22:17
MailGun Webhook Signature Validation
private static final key = "mailgun_key"
public static boolean isSignatureValid(String token , long timestamp, String signature) {
try {
Mac hmac = Mac.getInstance("HmacSHA256");
SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(), "HmacSHA256");
hmac.init(signingKey);
String signed = Hex.encodeHexString(hmac.doFinal((timestamp + token).getBytes()));
if (signed.equals(signature)) {
return true;
}
@marians
marians / main.go
Created January 27, 2017 10:25
OAuth 2.0 authentication in a Golang CLI
package main
import (
"context"
"crypto/tls"
"fmt"
"log"
"net/http"
"net/url"
"time"
@dreikanter
dreikanter / encrypt_openssl.md
Last active May 2, 2024 12:55 — forked from crazybyte/encrypt_openssl.txt
File encryption using OpenSSL

Symmetic encryption

For symmetic encryption, you can use the following:

To encrypt:

openssl aes-256-cbc -salt -a -e -in plaintext.txt -out encrypted.txt

To decrypt:

@dgmorales
dgmorales / Makefile
Last active February 14, 2023 06:18
Example Makefile for creating deb/rpm packages with jordansissel/fpm
# This is an example Makefile for quick package creation
#
# It uses FPM [1] to generate simple packages.
# - If you need more features or a greater quality package, use debian
# standard tools for packaging.
# - Do not use checkinstall. Use FPM instead.
#
# [1] (https://github.com/jordansissel/fpm/wiki)
# IMPORTANT:
@SthanleyLima
SthanleyLima / conf.js
Last active February 1, 2016 18:54
Apresentação Calculadora Sem PO
// Report sem screenShot
var jasmineSpecReporterSetup = function() {
var SpecReporter = require('jasmine-spec-reporter');
jasmine.getEnv().addReporter(new SpecReporter({
displayFailuresSummary: true, //mostra resumo das falhas
displaysFailedSpec: true, //exibe os testes que falharam
displaySuiteNumber: true, //numero do teste na suite
displaySpecDuration: true //tempo de execução dos testes
@SthanleyLima
SthanleyLima / conf.js
Last active February 1, 2016 19:05
Apresentação Calculadora Protractor
// Report sem screenShot
var jasmineSpecReporterSetup = function() {
var SpecReporter = require('jasmine-spec-reporter');
jasmine.getEnv().addReporter(new SpecReporter({
displayFailuresSummary: true, //mostra resumo das falhas
displaysFailedSpec: true, //exibe os testes que falharam
displaySuiteNumber: true, //numero do teste na suite
displaySpecDuration: true //tempo de execução dos testes
@ankushs92
ankushs92 / SomeInterceptor.java
Last active April 12, 2024 12:23
How to get Path Variables inside a Spring interceptor.[This post assumes that you have an Interceptor registered and set up using XML or Java config]
public class SomeInterceptor extends HandlerInterceptorAdapter{
@Override
public boolean preHandle(final HttpServletRequest request,final HttpServletResponse response,final Object handler)
throws Exception
{
/*Assume the URI is user/{userId}/post/{postId} and our interceptor is registered for this URI.
* This map would then be a map of two elements,with keys 'userId' and 'postId'
*/
final Map<String, String> pathVariables = (Map<String, String>) request
.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
@gene1wood
gene1wood / all_aws_managed_policies.json
Last active April 4, 2024 18:11
A list of all AWS managed policies and they're policy documents as well as a short script to generate the list
This file has been truncated, but you can view the full file.
{
"APIGatewayServiceRolePolicy": {
"Arn": "arn:aws:iam::aws:policy/aws-service-role/APIGatewayServiceRolePolicy",
"AttachmentCount": 0,
"CreateDate": "2019-10-22T18:22:01+00:00",
"DefaultVersionId": "v6",
"Document": {
"Statement": [
{
"Action": [