Skip to content

Instantly share code, notes, and snippets.

@bennylope
bennylope / migrate.py
Last active July 18, 2023 05:43
PostgreSQL migration script, Heroku -> Crunchy
#!/usr/bin/env python
import argparse
import os
import subprocess
import sys
import time
# Required so we don't generate tons of logs during restore
disable_logging_sql = "ALTER USER postgres RESET pgaudit.log;"
defmodule Broker.Workers.Appsignal do
@moduledoc false
alias Appsignal.Error
alias Appsignal.Transaction
def handle_event([:oban, event], measurement, meta, _) when event in [:success, :failure] do
transaction = record_event(measurement, meta)
if event == :failure && meta.attempt >= meta.max_attempts do
{reason, message, stack} = normalize_error(meta)
@atotto
atotto / ssh.go
Last active August 11, 2023 02:43
golang ssh terminal client
package main
import (
"context"
"flag"
"fmt"
"log"
"os"
"os/signal"
"syscall"
@trevphil
trevphil / KalmanFilter.swift
Created June 3, 2019 13:24
Kalman Filter for CLLocation
import Foundation
import CoreLocation
extension CLLocation {
// Alias for `horizontalAccuracy` (more readable)
var uncertainty: Double {
return horizontalAccuracy
}
}
@Luzifer
Luzifer / README.md
Last active November 18, 2023 17:22
Running docker-compose as a systemd service

Running docker-compose as a systemd service

Files

File Purpose
/etc/compose/docker-compose.yml Compose file describing what to deploy
/etc/systemd/system/docker-compose-reload.service Executing unit to trigger reload on docker-compose.service
/etc/systemd/system/docker-compose-reload.timer Timer unit to plan the reloads
/etc/systemd/system/docker-compose.service Service unit to start and manage docker compose
@navinpai
navinpai / README.md
Last active May 24, 2017 07:03
Boostrap Scripts to Install and Test Setup for Deep Learning Applications

Boostrap Scripts to Install and Test Setup for Deep Learning Applications

This gist is simply a set of scripts to install and test everything you need to get started with Deep Learning. This includes:

  • TensorFlow
  • Theano
  • Keras
  • CUDNN
  • CUDA Toolkit
  • Misc. linux Tools like tmux.
@dyerc
dyerc / exdeploy
Created January 7, 2016 15:36
A script to handle deploying a Phoenix web app
#!/bin/bash
APP="my-app"
REMOTE_USER="deployer"
SERVER="example.com"
BUILD_DIR="/usr/src/${APP}"
DEPLOY_DIR="/opt/${APP}"
############
# Elixir v1.0
defmodule Rules do
defmacro __using__(_) do
quote do
import unquote(__MODULE__)
@before_compile unquote(__MODULE__)
@rules []
end
end

Warning: Like the shitty OSS person I am, I forgot to update this. This particular iteration is exploitable in a really basic way that I missed. I will update this with the updated version hopefully soon

Reasoning

While authing against our Google Apps domain has worked pretty well up until now, we really needed a way to auth against out Github organization. Not everyone who is accessing some of our protected development content has an email account in our Google Apps domain. They do, however, have access to our github org.

Sadly it seems that apache and nginx modules for doing oauth are lacking.

I was hoping to avoid the whole lua approach (and mod_authnz_external was a no go from the start). However I realized that Brian Akins (@bakins) had done some fancy omnibus work that got me 90% of the way there.

From there it was a matter of patching up the omnibus repo to bring it to current versions as well as adding in a few additional components.

@burke
burke / remotepaste.md
Last active September 26, 2023 11:04
This sets up keybindings in tmux that allow you to copy/paste to/from your OS X clipboard from tmux running inside an SSH connection to a remote host. Partially borrowed from http://seancoates.com/blogs/remote-pbcopy

Local (OS X) Side

~/Library/LaunchAgents/pbcopy.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
     <key>Label</key>
     <string>localhost.pbcopy</string>