Skip to content

Instantly share code, notes, and snippets.

Avatar

Jony Santos jonyfs

View GitHub Profile
@paulfairless
paulfairless / gist:81eb87bd5a0e1b3a6d048ee913efc79a
Created Apr 4, 2017
Specify pool for spring-cloud-aws SQS listener
View gist:81eb87bd5a0e1b3a6d048ee913efc79a
package com.endource.aws
import com.amazonaws.services.sqs.AmazonSQSAsync
import com.amazonaws.services.sqs.model.Message
import com.amazonaws.services.sqs.model.MessageAttributeValue
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.cloud.aws.messaging.config.SimpleMessageListenerContainerFactory
@gabrielbauman
gabrielbauman / CardType.java
Last active Apr 27, 2021
A Java enum representing credit card types (Visa, Mastercard etc) that can detect card type from a credit card number.
View CardType.java
package com.gabrielbauman.gist;
import java.util.regex.Pattern;
public enum CardType {
UNKNOWN,
VISA("^4[0-9]{12}(?:[0-9]{3}){0,2}$"),
MASTERCARD("^(?:5[1-5]|2(?!2([01]|20)|7(2[1-9]|3))[2-7])\\d{14}$"),
AMERICAN_EXPRESS("^3[47][0-9]{13}$"),
@shortjared
shortjared / nginx.conf
Last active Feb 2, 2021
AWS API Gateway Nginx Reverse Proxy
View nginx.conf
# NOTE
#
#
# Use sed on the instance up to replace the INSTANCE_ID and DNS_RESOLVER with the following commands
#
####################################################################################################
# Fetch the private IP for resolving DNS dynamically in nginx
# We also need to escape the `.` from it for usage in later sed
#
# DNS_RESOLVER=`grep nameserver /etc/resolv.conf | cut -d " " -f2 | sed 's/\./\\./g'`
@zerogvt
zerogvt / gist:081685d53465f2266e419310fcca304a
Last active Feb 2, 2021 — forked from rb2k/gist:8372402
A jenkins script to clean up workspaces on slaves
View gist:081685d53465f2266e419310fcca304a
// Check if a slave has < 10 GB of free space, wipe out workspaces if it does
import hudson.model.*;
import hudson.util.*;
import jenkins.model.*;
import hudson.FilePath.FileCallable;
import hudson.slaves.OfflineCause;
import hudson.node_monitors.*;
import org.jenkinsci.plugins.workflow.job.WorkflowRun
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
@zuch
zuch / JSONtoXML.java
Last active Dec 25, 2020
java - Convert JSON to XML
View JSONtoXML.java
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.Charset;
import org.json.JSONException;//http://bit.ly/12O4D2w
@reyjrar
reyjrar / New-iTerm-Window.scpt
Created Feb 8, 2012
AppleScript to Open a New iTerm Window and bring it to the front
View New-iTerm-Window.scpt
(*
* New-iTerm-Window.scpt
*
* Intended for use with QuickSilver
* I mapped option-y to running this script to create
* a new iTerm window on the current workspace
*
* Based on much Googling - very little "original" code here
* Comments/Suggestions to brad.lhotsky@gmail.com
*)
@giansalex
giansalex / README.md
Last active Apr 25, 2020
Sonarqube Docker Compose - Alpine
View README.md

SonarQube Docker

  • Create a directory for project
  • Copy docker-compose.yml
  • Create /extensions in project directory.
  • Run docker-compose up -d
@rponte
rponte / AcessaWsDaSefaz.java
Created Aug 20, 2014
Acessando WS da Sefaz para NF-e
View AcessaWsDaSefaz.java
package br.com.syspdv.nfe.utils;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.net.URL;
import java.security.Security;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPConnection;
@reddikih
reddikih / convertBytebufferToString.java
Last active Apr 10, 2020
java convert bytebuffer to string
View convertBytebufferToString.java
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
...
/**
Method Usage
ByteBuffer bf = string2ByteBuffer("test", Charset.forName("UTF-8"));
**/
View lambda-mongodb-example
'use strict'
const AWS = require('aws-sdk');
var MongoClient = require('mongodb').MongoClient;
let atlas_connection_uri;
exports.handler = (event, context, callback) => {
var uri = process.env['MONGODB_ATLAS_CLUSTER_URI'];
if (atlas_connection_uri != null) {