Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Diego Magalhães dgomesbr

🏠
Working from home
View GitHub Profile
@dgomesbr
dgomesbr / sample-policy.json
Created Jul 6, 2020
Sample DynamoDB policy
View sample-policy.json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:GetItem",
"dynamodb:PutItem",
"dynamodb:Query"
],
@dgomesbr
dgomesbr / deploy2AWS.sh
Last active Feb 24, 2019
WP2Static S3 + Cloudfront invalidation
View deploy2AWS.sh
#!/bin/bash
#######################################################################################
#
# On WP2Static, targetdir = /opt/bitnami/wordpress/wp-content/static-version/deploy
# the script is executed outside the deploy dir in case you need to do any transfomations
# before the actual sync.
#
# Earlier version contained for example, hash of the deploy dir and its files for
# comparison, but since we're using s3 sync, no need to keep that.
@dgomesbr
dgomesbr / RedisLoaderApplication.java
Last active Jul 6, 2018
Redis Pipeline: spring-data-redis vs simple jedis
View RedisLoaderApplication.java
import com.lambdaworks.redis.RedisAsyncConnection;
import com.lambdaworks.redis.RedisClient;
import com.lambdaworks.redis.SetArgs;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
@dgomesbr
dgomesbr / create-silence.sh
Created Dec 8, 2016
Create silence sound and convert to mp3
View create-silence.sh
!#bin/bash
sox -n -r 44100 -c 2 silence.wav trim 0.0 2
lame -b 32 --resample 8 -a silence.wav silence.mp3
@dgomesbr
dgomesbr / master.vm
Created Sep 2, 2016 — forked from rpgreen/master.vm
API Gateway "Send Everything" Mapping Template
View master.vm
## API Gateway "Send Everything" Mapping Template - Ryan Green - ryang@ryang.ca
## See http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
#set($allParams = $input.params())
{
"body-json" : "$input.json('$')",
"params" : {
#foreach($type in $allParams.keySet())
#set($params = $allParams.get($type))
"$type" : {
#foreach($paramName in $params.keySet())
View CreateSubscriptionClient.java
public SubscriptionClient createSubscriptionClient() {
//default sem timeouts
// PREFERRED_API_URL => http://subscription.bemobi.com.br/sc/
// pode ser sobrescrita pelo pela propriedade de ambiente -Dcom.bemobi.subscription.client.host ou pelo
// método #setPreferredAddress(URL);
//SubscriptionJAXRSClient client = new SubscriptionJAXRSClient();
int TIMEOUT_IN_MILIS = 35 * 1000;
int MAX_CONNECTION_IN_POOL = 100;
return new SubscriptionJAXRSClient(TIMEOUT_IN_MILIS, TIMEOUT_IN_MILIS, MAX_CONNECTION_IN_POOL);
}
View logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!-- if-then-else form -->
<if condition='property("profile").contains("PROD")'>
<then>
<property name="LOGGER_LEVEL" value="INFO" />
<property name="CONSOLE_LOGGER_LEVEL" value="WARN" />
</then>
<else>
<property name="LOGGER_LEVEL" value="INFO" />
View UserRequiredAnnotationInterceptor.java
public class UserRequiredAnnotationInterceptor extends HandlerInterceptorAdapter
{
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
{
if (handler == null)
{
return true;
}
View UserRequiredAnnotationInterceptor.java
public class UserRequiredAnnotationInterceptor extends HandlerInterceptorAdapter
{
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
{
if (handler == null)
{
return true;
}
@dgomesbr
dgomesbr / SpringConfig.java
Created Oct 9, 2012
Spring 3.1 Configurable Class :)
View SpringConfig.java
package com.bemobi.wap.config;
import java.util.Properties;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import org.hibernate.ejb.HibernatePersistence;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
You can’t perform that action at this time.