Skip to content

Instantly share code, notes, and snippets.

View dereckmartin's full-sized avatar

Dereck Martin dereckmartin

  • Indianapolis, IN
View GitHub Profile
@dereckmartin
dereckmartin / HasTsids.php
Last active December 6, 2023 07:55
Laravel Trait to support TSID (string) primary key support that generates IDs automatically on insert.
<?php
/**
* Thank you to https://github.com/odan/tsid for this package.
*
* This isn't perfect, and I don't know any further method to test for
* for the validity of the TSID, but this is a start.
*
* I couldn't get Laravel 10 to play nice with bigIntegers as primary key.
* Laravel kept trying to add auto_increment on table create during migration.
@dereckmartin
dereckmartin / harbor-projects-to-puppet-harbor-hieradata.py
Created January 21, 2021 23:14
Export Harbor projects to puppet-harbor hieradata
#!/bin/python
import requests
from requests.auth import HTTPBasicAuth
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
'''
Translate Harbor projects data to Puppet Hieradata
@dereckmartin
dereckmartin / harbor-usergroups-to-puppet-harbor-hieradata.py
Last active January 21, 2021 23:16
Export Harbor LDAP usergroups to puppet-harbor hieradata
#!/bin/python
import requests
from requests.auth import HTTPBasicAuth
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
'''
Translate Harbor LDAP usergroup data to Puppet Hieradata
@dereckmartin
dereckmartin / packer-download-latest.py
Created March 7, 2017 21:43
Download latest packer version for linux
#!/usr/bin/env python3
import requests
from tqdm import tqdm
req = requests.get("https://api.github.com/repos/mitchellh/packer/tags")
data = req.json()
version = data[0]['name']
@dereckmartin
dereckmartin / phalcon-validation-example.php
Last active October 20, 2016 05:14
Snippet of using validation and filters for form submission data using phalcon
<?php
/**
* Snippet of using validation and filters for form submission
* data using phalcon.
*
* The "simple" project was created using phalcon dev tools
*/
/**
@dereckmartin
dereckmartin / bash_trap
Last active April 6, 2022 02:53
BASH trap gist
#!/usr/bin/env bash
##
# Trap Setup
#
# This trap setup allows for a ERRNO_MSG to be provided in any function
##
trap 'chute ${LINENO} $? "${ERRNO_MSG}"' ERR
function chute() {
echo "[ERROR] Line: ${1} Code: ${2} Message: ${3}"
@dereckmartin
dereckmartin / IpnController.ex
Last active October 22, 2017 09:39
Phoenix Framework: PayPal IPN Handshake
defmodule AppName.IpnController do
@moduledoc """
IPN Controller.
"""
use AppName.Web, :controller
def create(conn, params) do
# PayPal requires the params returned in the exact order given.
# The map needs to be a list. encode/1 keep the order of a list,