Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View marcelog's full-sized avatar

Marcelo Gornstein marcelog

View GitHub Profile
@marcelog
marcelog / lambda-website-checker.js
Created October 22, 2016 12:10
This AWS Lambda can be used to check your website for availability
'use strict';
var url = require('url');
var target = 'http://www.yourwebsite.com'; // Change this one
exports.handler = function(event, context, callback) {
var urlObject = url.parse(target);
var mod = require(
urlObject.protocol.substring(0, urlObject.protocol.length - 1)
);
@marcelog
marcelog / aws-sqs.policy
Last active December 4, 2023 07:07
SQS Policy to allow an S3 bucket to publish messages
{
"Version": "2012-10-17",
"Id": "arn:aws:sqs:YOUR-AWS-REGION:YOUR-AWS-ACCOUNT-ID:YOUR-QUEUE-NAME/SQSDefaultPolicy",
"Statement": [
{
"Sid": "example-statement-ID",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
@marcelog
marcelog / passing_client_ssl_certificate_options_haproxy.conf
Last active November 21, 2023 18:22
Sample haproxy configuration snippet that will pass the SSL client certificate information to your application
mode http
http-request set-header X-SSL %[ssl_fc]
http-request set-header X-SSL-Client-Cert %[ssl_fc_has_crt]
http-request set-header X-SSL-Client-Verify %[ssl_c_verify]
http-request set-header X-SSL-Client-SHA1 %{+Q}[ssl_c_sha1,hex]
http-request set-header X-SSL-Client-DN %{+Q}[ssl_c_s_dn]
http-request set-header X-SSL-Client-CN %{+Q}[ssl_c_s_dn(cn)]
http-request set-header X-SSL-Issuer %{+Q}[ssl_c_i_dn]
http-request set-header X-SSL-Client-Not-Before %{+Q}[ssl_c_notbefore]
http-request set-header X-SSL-Client-Not-After %{+Q}[ssl_c_notafter]
@marcelog
marcelog / generic_proxy.erl
Last active October 1, 2023 16:15
Quick and small tcp proxy written in erlang. Opens a socket and listens for incoming connections. For every new incoming connection, it will open a connection to the proxied host, and send whatever it gets from either side to the other.
-module(generic_proxy).
-export([run/0]).
-define(PORT_FROM, 63790).
-define(PORT_TO, 6379).
-define(BACKLOG, 10000).
run() ->
{ok, Socket} = gen_tcp:listen(0, [
@marcelog
marcelog / nginx_with_external_openssl.sh
Created October 29, 2016 18:32
How to send specific linker options for nginx without using LDFLAGS
#!/bin/bash
./configure --with-ld-opt="-L/my/ssl/location"
@marcelog
marcelog / build_static_sox_binary.sh
Last active September 29, 2022 02:04
Build a static SOX binary suitable to be used in an AWS Lambda Container
cd /usr/src
wget "http://downloads.sourceforge.net/project/sox/sox/14.4.2/sox-14.4.2.tar.bz2?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fsox%2Ffiles%2Fsox%2F14.4.2%2F&ts=1476009578&use_mirror=ufpr" -O sox-14.4.2.tar.bz2
tar jxf sox-14.4.2.tar.bz2
cd sox-14.4.2
CPPFLAGS="-I/usr/libmad-0.15.1b/include -I/usr/lame-3.99.5/include " \
LDFLAGS="-L/usr/libmad-0.15.1b/lib -L/usr/lame-3.99.5/lib -L/usr/libgsm-1.0.10/lib" \
./configure --prefix=/usr/sox-14.4.2 --disable-shared --enable-static
make
make install
#!/bin/bash
cd /tmp
file=$(date +%a).sql
mysqldump \
--host ${MYSQL_HOST} \
--port ${MYSQL_PORT} \
-u ${MYSQL_USER} \
--password="${MYSQL_PASS}" \
${MYSQL_DB} > ${file}
if [ "${?}" -eq 0 ]; then
exten => _X.,1,Set(CURL_RESULT=${CURL(http://domain.com/test.txt)})
same => n,GotoIf($["${CURL_RESULT}" = "1"]?result1:result2)
same => n(result1),Verbose(Result 1)
same => n,Hangup
same => n(result2),Verbose(Result other)
same => n,Hangup
#!/bin/bash
cd /usr/src
git checkout https://github.com/Distrotech/libilbc-webrtc
cd libilbc-webrtc
./configure
make
make install
@marcelog
marcelog / buildspec.yml
Created April 2, 2017 15:44
Example for buildspec file for Amazon CodeBuild and Amazon CodePipeline to achieve Continuous Integration and Continuous Delivery for a ServerLess project
version: 0.1
phases:
install:
commands:
- printenv
- npm install
build:
commands:
- npm run build