Skip to content

Instantly share code, notes, and snippets.

View ericjsilva's full-sized avatar
🦉
silently correcting your grammar.

Eric Silva ericjsilva

🦉
silently correcting your grammar.
View GitHub Profile
@ericjsilva
ericjsilva / create_redshift_readonly_user.sql
Last active May 4, 2017 21:26
AWS Redshift: Create read-only user
create user [username] password 'password';
grant usage on schema [schema] to [username];
alter user [username] set search_path to [schema];
grant select on all tables in schema [schema] to [username];
commit;
select * from pg_user;
@ericjsilva
ericjsilva / optimized-rds-mysql56.sh
Last active May 25, 2016 03:11
AWS CLI script to modify RDS MySQL 5.6 parameter group to use optimized settings
aws rds modify-db-parameter-group --db-parameter-group={parameter-group-name} --region={region} \
--parameters="ParameterName=character_set_server, ParameterValue=utf8, ApplyMethod=pending-reboot" \
--parameters="ParameterName=collation_server, ParameterValue=utf8_general_ci, ApplyMethod=pending-reboot" \
--parameters="ParameterName=tmp_table_size, ParameterValue={DBInstanceClassMemory/16}, ApplyMethod=pending-reboot" \
--parameters="ParameterName=max_heap_table_size, ParameterValue={DBInstanceClassMemory/16}, ApplyMethod=pending-reboot" \
--parameters="ParameterName=query_cache_type, ParameterValue=1, ApplyMethod=pending-reboot" \
--parameters="ParameterName=query_cache_size, ParameterValue=3048576, ApplyMethod=pending-reboot" \
--parameters="ParameterName=table_open_cache, ParameterValue=2500, ApplyMethod=pending-reboot" \
--parameters="ParameterName=join_buffer_size, ParameterValue={DBInstanceClassMemory/64}, ApplyMethod=pending-reboot" \
--parameters="ParameterName=thread_cache_size, ParameterValue={DBIns
@ericjsilva
ericjsilva / cloudhub-redshift-proxy.md
Last active April 29, 2024 16:48
How to create and configure a proxy between MuleSoft CloudHub and Amazon AWS Redshift using an Amazon AWS EC2 instance.

Overview

Below are the steps needed to create and configure a proxy between MuleSoft CloudHub and Amazon AWS Redshift using an Amazon AWS EC2 instance.

The Problem

EC2 and Redshift instances are configured to support jumbo frames (MTU for ethernet interfaces is 9001). However, some routers between endpoints have a standard Ethernet MTU size (1500), which causes an inability to communicate with announced TCP MSS size (8961). The reason for this issue is that the PATH MTU discovery process relies on ICMP, specifically Type 3 Code 4 / Fragmentation Needed, and currently on Redshift ALL ICMP traffic is denied (regardless of Security Group configuration).

MuleSoft CloudHub uses the standard ethernet MTU (1500), and cannot connect to a RedShift cluster by default. The steps below document how to create a lightweight IP proxy using an EC2 instance.

Configuration Details

@ericjsilva
ericjsilva / SHA256Test.cs
Created June 2, 2015 19:17
SHA-256 Hash algorithms to test portability across platforms
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Security.Cryptography;
using System.Text;
public class SHA256Test
{
public static void Main(string[] args)
@ericjsilva
ericjsilva / README.md
Last active August 29, 2015 14:15
Unsubscribe Email Design

You can encode a URL like so:

http://yourserver.com/unsubscribe/<encoded-email>/<signature> Where <signature> is something like hash_hmac('sha256', $email, $secret_key). Encoded-email can just be a URL-encoding of the email, or it can be an actually encrypted (AES+CBC+Base64 or similar) version of the email. Using full encryption would seem to be of little use though - since the person receiving this has their own email address anyway.

This signature scheme has the advantage of not needing any database storage, while remaining secure against malicious attempts to unsubscribe someone.

@ericjsilva
ericjsilva / druplicon.coffee
Created January 30, 2015 19:55
Hubot script to print druplicon as ASCII art
# Description:
# When hubot hears druplicon, an ASCII art druplicon will appear.
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
<?php
/*
Plugin Name: Instagrate to WordPress
Plugin URI: http://www.polevaultweb.com/plugins/instagrate-to-wordpress/
Description: Plugin for automatic posting of Instagram images into a WordPress blog.
Author: polevaultweb
Version: 1.2.3
Author URI: http://www.polevaultweb.com/
Copyright 2012 polevaultweb (email : info@polevaultweb.com)

Keybase proof

I hereby claim:

  • I am ericjsilva on github.
  • I am ericjsilva (https://keybase.io/ericjsilva) on keybase.
  • I have a public key whose fingerprint is 4E30 8D75 9F24 3C48 315C D9AA 1DD8 AF6F 305E 289D

To claim this, I am signing this object:

@ericjsilva
ericjsilva / create_uuid.js
Created December 18, 2013 06:28
Creates a Type 4 UUID using regular expressions.
/*
* Full credit to Byron Salau at http://byronsalau.com/ for this script.
*/
function createUUID() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0,
v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
@ericjsilva
ericjsilva / CBJenkins.xml
Created August 28, 2013 12:46
Sample MuleSoft flow using the Jenkins connector against CloudBees to get information about a job, and then execute the job. NOTE: Code will not execute the job due to the fact that CloudBees requires a POST request and the Jenkins connector issues a GET request.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:jenkins="http://www.mulesoft.org/schema/mule/jenkins" xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/jenkins http://www.mulesoft.org/schema/mule/jen