Skip to content

Instantly share code, notes, and snippets.

View marcelog's full-sized avatar

Marcelo Gornstein marcelog

View GitHub Profile
@marcelog
marcelog / serverless_lambda_cloudwatch_event.yml
Created February 26, 2017 16:57
An example of defining a CloudWatch scheduled event as an event for an AWS Lambda in the serverless framework by using a CloudFront template for resources
functions:
MyLambdaFunction:
role: MyLambdaRole
handler: index.handle
resources:
Resources:
MyEventName:
Type: AWS::Events::Rule
Properties:
Description: An awesome periodic event
#!/bin/bash
if [ ! "${#@}" -eq 5 ]; then
echo "Use: ${0} <scenario_file.xml> <voip_gateway> <from_did> <to_did> <local_ip_address>"
exit 255
fi
scenario=${1}
shift
voip_gateway=${1}
@marcelog
marcelog / ubuntu_install_webcamstudio.sh
Last active September 14, 2020 13:57
Install webcamstudio in Ubuntu to setup a virtual webcam to use as the phone camera in Android Emulator
#!/bin/bash
apt-get install software-properties-common
dpkg -S add-apt-repository
add-apt-repository ppa:webcamstudio/webcamstudio-dailybuilds
apt-get update
apt-get install webcamstudio
modprobe webcamstudio
@marcelog
marcelog / to_unix_eol.sh
Created March 12, 2017 22:05
Translating line endings from mac and dos to unix
#!/bin/bash
cat file.txt | tr '\r' '\n' | tr -s '\n' > file.translated.txt
@marcelog
marcelog / haproxy.conf
Created July 9, 2017 21:47
Multiple backends in haproxy by using ACL, one SSL certificate, and SNI
frontend http
bind *:443 ssl crt /etc/ssl/certs/mycert.pem ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4
mode tcp
acl backend1 ssl_fc_sni backed1.domain.com
acl backend2 ssl_fc_sni backed2.domain.com
tcp-request inspect-delay 5s
use_backend backend1 if backend1
use_backend backend2 if backend2
backend backend1
frontend www
bind *:80
mode tcp
acl network_allowed src 1.1.1.1 2.2.2.2
tcp-request connection reject if !network_allowed
use_backend my_backend_server
@marcelog
marcelog / serverless_way_for_scheduled_events.yml
Created February 27, 2017 01:51
The right way to use scheduled events with the serverless framework and lambda
events:
- schedule:
name: 'MyEventName'
rate: cron(0 6 * * ? *)
enabled: true
input:
key: value
#!/bin/bash
cd /usr/src
git clone https://github.com/DoubangoTelecom/webrtc2sip
export PREFIX=/opt/webrtc2sip
cd webrtc2sip
./autogen.sh
LDFLAGS=-ldl ./configure --prefix=$PREFIX
make
make install
cp -f ./config.xml $PREFIX/sbin/config.xml
#!/bin/bash
echo gcc -O2 -include /usr/include/errno.h > admin/daemontools-0.76/src/conf-cc
#!/bin/bash
AWS_ACCESS_KEY_ID=my_key \
AWS_SECRET_ACCESS_KEY=my_secret \
AWS_DEFAULT_REGION=us-west-2 \
S3_BUCKET=my_bucket \
MYSQL_HOST=host \
MYSQL_PORT=port \
MYSQL_USER=myuser \
MYSQL_PASS=pass \
MYSQL_DB=db \