Skip to content

Instantly share code, notes, and snippets.

@Preocts
Preocts / pd_alert.py
Created December 8, 2021 20:23
Python 3.8 pagerduty alert sender, no external libraries.
"""
Send an Alert Event to PagerDuty
NOTE: "ALERT_ROUTING_KEY" environment variable must contain a
valid routing key for a PagerDuty service.
https://developer.pagerduty.com/docs/ZG9jOjExMDI5NTgw-events-api-v2-overview#getting-started
Usage:
$ python -m pd_alert "Alert Title" "Alert Body" "dedup_key"
@ThisIsMissEm
ThisIsMissEm / Schema.graphql
Created October 2, 2019 05:15
Form Validation as a Result Union
mutation updateUser(
details: UpdateUserInput!
): UpdateUserResult
union UpdateUserResult =
UpdateUserSuccess |
FormValidationError
type UpdateUserSuccess {}
@davideicardi
davideicardi / README.md
Last active February 7, 2021 12:02
Package a Python Lambda for AWS

Package a Python Lambda for AWS

Python virtual env

Create Python virtual env

python3 -m venv v-env

Activate

@adamwathan
adamwathan / 1-add-macros.php
Last active June 11, 2022 19:55
Multiformat Endpoints in Laravel
<?php
namespace App\Providers;
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
use Illuminate\Support\ServiceProvider;
use App\Http\Middleware\CaptureRequestExtension;
class AppServiceProvider extends ServiceProvider
@zabaala
zabaala / BindDatabaseServiceProvider.php
Last active March 2, 2021 07:50
php artisan db:log <start> <stop>
<?php
namespace App\Commands\Database;
use Illuminate\Support\ServiceProvider;
class BindDatabaseServiceProvider extends ServiceProvider
{
public function boot()
{
@tomfa
tomfa / handler.py
Last active May 12, 2023 14:44
AWS Lambda: Python Hello World HTTP API
# This file is your Lambda function
import json
def mirror_query_strings(event, context):
body = {
"queryStrings": event['queryStringParameters']
}
return {
"statusCode": 200,
@nstogner
nstogner / retry_jitter.go
Last active September 30, 2024 11:50
Go: Simple retry function with jitter
func init() {
rand.Seed(time.Now().UnixNano())
}
func retry(attempts int, sleep time.Duration, f func() error) error {
if err := f(); err != nil {
if s, ok := err.(stop); ok {
// Return the original error for later checking
return s.error
}
@svrist
svrist / cf_create_or_update.py
Created February 7, 2017 21:34
Update or create a CloudFormation stack given a name and template + params'
'Update or create a stack given a name and template + params'
from __future__ import division, print_function, unicode_literals
from datetime import datetime
import logging
import json
import sys
import boto3
import botocore
@alexcasalboni
alexcasalboni / deploy.sh
Last active January 29, 2024 12:22
Simple AWS Lambda deployment script - Zip & upload Deployment Package with initial dependencies to S3
#!/bin/bash
BUCKET="YOUR_BUCKET_NAME" # bucket name
FILENAME="deployment-package.zip" # upload key
TMP_FOLDER="/tmp/lambda-env-tmp/" # will be cleaned
OUTPUT_FOLDER="/tmp/lambda-env/" # will be cleaned
HERE=${BASH_SOURCE%/*} # relative path to this file's folder
LAMBDA_FOLDER="$HERE/lambda/" # relative path
@yannhowe
yannhowe / .gitlab.ci.yml
Created September 26, 2016 18:06
.gitlab.ci.yml for SSH with private key.
# Image neeeds to have ssh-client
image: docker:git
services:
- docker:dind
stages:
- staging
before_script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY