Skip to content

Instantly share code, notes, and snippets.

View alexdlaird's full-sized avatar

Alex Laird alexdlaird

View GitHub Profile
@alexdlaird
alexdlaird / pyngrok_HttpServerExample_server.py
Last active September 18, 2023 19:19
HTTP server integration example for pyngrok, full documentation found at https://pyngrok.readthedocs.io/en/latest/integrations.html
import os
from http.server import HTTPServer, BaseHTTPRequestHandler
from pyngrok import ngrok
port = os.environ.get("PORT", "80")
server_address = ("", port)
httpd = HTTPServer(server_address, BaseHTTPRequestHandler)
@alexdlaird
alexdlaird / 1_pyngrok_TCPExample_server.py
Last active October 19, 2023 17:47
TCP server/client integration example for pyngrok, full documentation found at https://pyngrok.readthedocs.io/en/latest/integrations.html
# HOST="1.tcp.ngrok.io" PORT=12345 python server.py
import os
import socket
from pyngrok import ngrok
host = os.environ.get("HOST")
port = int(os.environ.get("PORT"))
@alexdlaird
alexdlaird / 1_AirNowTextingService.md
Last active December 4, 2018 18:07
Texting service to receive current air quality conditions and maps, powered by AirNow, Twilio, and AWS
@alexdlaird
alexdlaird / 1_ServerlessSMSRaffle.md
Last active September 11, 2020 00:47
Serverless SMS raffle powered by Twilio and AWS

Serverless SMS Raffle

Create a new Role from a Policy with the following permissions:

{
    "Version": "2012-10-17",
    "Statement": [
        {
 "Effect": "Allow",
@alexdlaird
alexdlaird / 1_TrackimoSEStoSMS.md
Last active November 14, 2018 06:11
AWS Lambdas that receive emails from SES, process to SQS (optional deduplication), and send as SMS via Twilio

Trackimo SES to SMS

Create a new Role from a Policy with the following permissions:

{
    "Version": "2012-10-17",
    "Statement": [
        {
 "Effect": "Allow",
#!/usr/bin/env bash
# Install Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install Homebase CLI
mkdir -p /usr/local/opt
git clone https://bitbucket.sparkcentral.ninja/scm/int/homebase-cli.git /usr/local/opt/homebase-cli
ln -s /usr/local/opt/homebase-cli/bin/homebase-cli /usr/local/bin/homebase-cli
@alexdlaird
alexdlaird / daemon.cpp
Last active December 2, 2024 15:42
Useful as a starting point for a C++ based Linux daemon application.
#include <dirent.h>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <string>
#include <sys/stat.h>
#include <syslog.h>
@alexdlaird
alexdlaird / bashrc
Created August 26, 2014 19:24
Useful aliases for a Linux profile. Place in /etc/bashrc or ~/.bashrc.
alias vi='vim'
alias sudo='sudo '
alias which='type -a'
alias path='echo -e ${PATH//:/\\n}'
alias libpath='echo -e ${LD_LIBRARY_PATH//:/\\n}'
alias du='du -kh'
alias df='df -kTh'
alias ..='cd ..'
alias ...='cd ../..'
@alexdlaird
alexdlaird / profile
Created August 26, 2014 19:20
Force default shell to Bash. This is especially useful when user does not exist in /etc/passwd. Place this snippet at the end of /etc/profile or ~/.profile.
case $- in
*i*)
# If $BASH is not defined then we're already in a Bash shell
if [ -z "$BASH" ]; then
BASH_BIN=$(command -v bash)
# Ensure Bash is installed on the system, then switch shells
if [ -x "$BASH_BIN" ]; then
export SHELL="$BASH_BIN"
exec "$BASH_BIN"
fi
@alexdlaird
alexdlaird / service-name
Last active December 21, 2021 19:54
Useful as a starting point for a Linux service script. The parameters in the header comments (service-name, chkconfig, etc.) are specific to Red Hat-like Linux distributions and would be ignored in a Debian environment. Make script executable and place in /etc/init.d, then run appropriate chkconfig or update-rc.d command to add as a service.
#!/bin/sh
#
# service-name Service Name and brief description
#
# chkconfig: 2345 96 06
# description: Service Name and brief description
# processname: service-name
###########################################################################
# Modify the below variables do determine how the service is run