Skip to content

Instantly share code, notes, and snippets.

View alexdlaird's full-sized avatar

Alex Laird alexdlaird

View GitHub Profile
@alexdlaird
alexdlaird / daemon.cpp
Last active June 5, 2025 16:19
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 / 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_AirNowTextingService.md
Last active June 5, 2025 16:21
Texting service to receive current air quality conditions and maps, powered by AirNow, Twilio, and AWS
@alexdlaird
alexdlaird / 1_pyngrok_TCPExample_server.py
Last active June 5, 2025 16:21
Simple 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 / pyngrok_HttpServerExample_server.py
Last active June 5, 2025 16:21
Simple 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 / pyngrok_AWSLambdaFlaskExample_server.py
Last active June 5, 2025 16:21
AWS Lambda Flask integration example for pyngrok, full documentation found at https://pyngrok.readthedocs.io/en/latest/integrations.html
import json
from flask import Blueprint, request
from lambdas.foo_GET import lambda_function as foo_GET
bp = Blueprint("lambda_routes", __name__)
@bp.route("/foo")
def route_foo():
# This becomes the event in the Lambda handler
import unittest
import threading
from flask import request
from pyngrok import ngrok
from urllib import request
from server import create_app
@alexdlaird
alexdlaird / pyngrok_FastApiExample_server.py
Last active June 5, 2025 16:21
Fast API integration example for pyngrok, full documentation found at https://pyngrok.readthedocs.io/en/latest/integrations.html
# USE_NGROK=True uvicorn server:app
import os
import sys
from fastapi import FastAPI
from fastapi.logger import logger
from pydantic import BaseSettings
@alexdlaird
alexdlaird / pyngrok_FlaskExample_server.py
Last active June 5, 2025 16:21
Flask integration example for pyngrok, full documentation found at https://pyngrok.readthedocs.io/en/latest/integrations.html
# USE_NGROK=True FLASK_APP=server.py flask run
import os
import sys
from flask import Flask
def init_webhooks(base_url):
# Update inbound traffic via APIs to use the public-facing ngrok URL
pass
@alexdlaird
alexdlaird / 1_pyngrok_DjangoExample_apps.py
Last active June 5, 2025 16:21
Django integration example for pyngrok, full documentation found at https://pyngrok.readthedocs.io/en/latest/integrations.html
import os
import sys
from urllib.parse import urlparse
from django.apps import AppConfig
from django.conf import settings
class CommonConfig(AppConfig):
name = "myproject.common"