Skip to content

Instantly share code, notes, and snippets.

👾
Back, trying to catch-up

Diego Magalhães dgomesbr

👾
Back, trying to catch-up
Block or report user

Report or block dgomesbr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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 / 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);
}
@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;
View microservices.adoc

Service Design - Bemobi

Sample Dataset

This sample dataset is a representation of Bemobi

@dgomesbr
dgomesbr / error.log
Last active Aug 29, 2015
Docker Zipkin start error
View error.log
osboxes deploy # ./deploy.sh
** Starting zipkin-cassandra
9fc184535addcaaaa55de0df11241c3e9c806c174986ef8142e4282f12198367
** Starting zipkin-collector
ad7ac5b12f80463044b65e75b88fe36e245c98dacc0c9b46eeeee3310061d480
2015/03/24 05:48:01 Error response from daemon: Cannot start container ad7ac5b12f80463044b65e75b88fe36e245c98dacc0c9b46eeeee3310061d480: Cannot link to a non running container: /zipkin-cassandra AS /zipkin-collector/db
** Starting zipkin-query
2ff7e1cb21a7198685be229a84f242a59028e11363cf2d8853bbe821075f08bd
2015/03/24 05:48:03 Error response from daemon: Cannot start container 2ff7e1cb21a7198685be229a84f242a59028e11363cf2d8853bbe821075f08bd: Cannot link to a non running container: /zipkin-cassandra AS /zipkin-query/db
** Starting zipkin-web
View sample.q
DROP TABLE REVIVE_AD_VIS;
CREATE EXTERNAL TABLE REVIVE_AD_VIS ( hour String, bannerid STRING, campaignid STRING, zoneid STRING, count STRING )
row format
delimited fields terminated by ','
lines terminated by '\n'
STORED
AS TEXTFILE LOCATION 's3n://EMRresult/OutputFolder';
INSERT OVERWRITE TABLE REVIVE_AD_VIS
SELECT
@dgomesbr
dgomesbr / ConcurrentChunkProcessor.java
Last active Aug 29, 2015
Example of parallel processing on ConcurrentChunkProcessor
View ConcurrentChunkProcessor.java
/**
* same as SimpleChunkProcessor except otherwise shown
*/
public class ConcurrentChunkProcessor<I, O> implements ChunkProcessor<I>, InitializingBean {
// ...
// example of parallel processing using Executor service, better create this by Spring and inject if available or
// use the same TaskExecutor from the Context
private static final int THREADPOOL_TIMEOUT_IN_SECONDS = 1;
@dgomesbr
dgomesbr / patch.4.0.php
Last active Aug 29, 2015
Patch for domain defined in user properties.
View patch.4.0.php
if(!$user = $this->db->get("user",array("api"=>"?"),array("limit"=>1),array($key))) return $this->api_build(array("error"=>1,"msg"=>"A valid API key is required to use this service."));
$this->userid = $user->id;
$this->customDomain = $user->domain;
// Check Request type
if(!isset($_GET["url"]) && !isset($_GET["short"])) return $this->api_build(array("error"=>1,"msg"=>"Please enter a valid URL."));
// Check if shorten request is made
if(isset($_GET["url"])){
$array = array();
You can’t perform that action at this time.