Skip to content

Instantly share code, notes, and snippets.

View adamprescott's full-sized avatar

Adam Prescott adamprescott

View GitHub Profile
@adamprescott
adamprescott / README.md
Created September 9, 2022 11:05
Serverless AWSv4 Auth Example / Test
  • npm i
  • npm i -g serverless
  • Do the whole AWS Credentials thing on your terminal
  • serverless deploy --stage dev
  • Update <replace with APIGW URL after first deploy> with the URL returned on first deploy.
  • Hit the /test endpoint

Example deploy output

╭─adam@LAPTOP-VC8JGUGJ ~/awsv4test
@adamprescott
adamprescott / docker-compose.yml
Last active May 26, 2021 23:17
Elastic Search with App Search / Enterprise Search
# Place this in an empty directory and just run `docker compose up -d` For ease of use, keep an eye on Docker Desktop
# Clicking on the running enterprisesearch container will display logs on the container, showing once the Web application and API is up and running. This might take upto 2mins (java application)
# Login is enterprise_search / letmein1234
# Once logged in, select "Launch App Search" and follow setup
version: '3'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.10.1
@adamprescott
adamprescott / Dockerfile
Last active January 22, 2019 09:45
PHP 7.1 Docker + SSL & MySQL
FROM php:7.1-apache
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public_html \
APACHE_SSL_CERT_FILE=/etc/ssl/certs/ssl-cert-snakeoil.pem \
APACHE_SSL_KEY_FILE=/etc/ssl/private/ssl-cert-snakeoil.key
RUN cd /tmp \
&& openssl genrsa -des3 -passout pass:lamepassword -out snakeoil.pass.key 2048 \
&& openssl rsa -passin pass:lamepassword -in snakeoil.pass.key -out snakeoil.key \
&& openssl req -new -subj "/C=US/ST=California/L=San Francisco/O=Dis/CN=localhost" -key snakeoil.key -out snakeoil.csr \
-- Change delimiter so that the function body doesn't end the function declaration
DELIMITER //
CREATE FUNCTION uuid_v4()
RETURNS CHAR(32)
BEGIN
-- Generate 8 2-byte strings that we will combine into a UUIDv4
SET @h1 = LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0');
SET @h2 = LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0');
SET @h3 = LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0');

Keybase proof

I hereby claim:

  • I am adamprescott on github.
  • I am adamprescott (https://keybase.io/adamprescott) on keybase.
  • I have a public key ASDccDTC-NctTIXIM-8yuMkifT062NIvaopv9JRKv1CxcQo

To claim this, I am signing this object:

attrcolor b ".I"
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
defbce "on"
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c:%s %{g}]'
Vagrant.configure(2) do |config|
config.vm.box = "chef/centos-6.6"
config.vm.network "public_network"
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
end
#
config.vm.provision "shell", inline: <<-SHELL
var net = require('net');
var phpjs = require('phpjs');
var mysql = require('mysql');
var server = net.createServer(function(c) {
c.setEncoding('ascii');
var sqlconn = mysql.createConnection({
host: 'localhost',
user: '[somedbuser]',
<?php
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <adam.prescott@datascribe.co.uk> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Adam Prescott
* ----------------------------------------------------------------------------
*/