Skip to content

Instantly share code, notes, and snippets.

@woganmay
woganmay / hook.sh
Created Jun 25, 2020
Cache node_modules between envoyer.io deploys
View hook.sh
#
# Use cached node_modules for faster frontend compile times
# on envoyer.io
#
# Rationale: If you don't want to set up node_modules caching on
# every server you deploy to, this drop-in deployment hook serves
# a similar purpose. It will symlink every new release to a shared
# node_modules folder, cutting out the installation time.
#
@woganmay
woganmay / bitbucket-pipelines.yml
Created Sep 11, 2019
Bitbucket CI Pipeline - Deploy Laravel Vapor
View bitbucket-pipelines.yml
# Prerequisites:
# 1. Have the laravel/vapor-cli dependency in your project, so that composer install catches it
# 2. Set the VAPOR_API_TOKEN environment variable to your Vapor API key
# Details in the documentation: https://docs.vapor.build/1.0/projects/deployments.html#deploying-from-ci
# This pipeline will build a PHP 7.2 environment with dependencies, run the standard
# phpunit tests, then deploy to the staging environment on Vapor.
image: php:7.2.22-alpine
@woganmay
woganmay / Harvest.gs
Created Aug 24, 2019
Read Harvest timesheet data into a Google Sheet
View Harvest.gs
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Integrations')
.addItem('Fetch Harvest', 'fetchHarvestData')
.addToUi();
}
function fetchHarvestData() {
// Update monthly, or read from another sheet
@woganmay
woganmay / api.php
Created Jun 12, 2019
Detect new versions of app.js automatically
View api.php
<?php
// Ugly as sin, but gets the latest version URL for the app.js file
// The Vue app will query this every 60 seconds
Route::get('/version', function(){
$manifest = file_get_contents(public_path('mix-manifest.json'));
$manifest = json_decode($manifest);
return response()->json([
'latest' => $manifest->{'/js/app.js'}
]);
@woganmay
woganmay / auto-project-manager.gs
Created Sep 7, 2018
Pull Toggl entries through the Reports API, into an incremental Sheet tab.
View auto-project-manager.gs
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('My Business')
.addItem('Refresh Timesheets', 'getTimesheets')
.addToUi();
}
function getTimesheets() {
// Read API token and Workspace ID from Configuration tab
@woganmay
woganmay / page.php
Created Nov 5, 2017
Simple HTTP POST request from an OctoberCMS form submission
View page.php
<?php
function onStart()
{
$flow = curl_init("https://prod-22.westeurope.logic.azure.com:443/...");
curl_setopt($flow, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($flow, CURLOPT_POST, TRUE);
curl_setopt($flow, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
@woganmay
woganmay / PixelController.php
Created Oct 2, 2017
Manage a tracking pixel
View PixelController.php
<?php
namespace App\Http\Controllers;
use App\Http\Requests;
use Illuminate\Http\Request;
use App\Jobs\SendOpened;
class PixelController extends Controller
View gist:de9bf6da8d23117e3f932c546f0581ae

This was all done on a Debian Linux server.

Speedtest

Install speedtest-cli by:

sudo easy_install speedtest-cli

That gives you a one-line command to run up/down tests via speedtest.net. To hit a specific server, check the main list at https://www.speedtest.net/speedtest-servers.php and provide the ID to test against:

@woganmay
woganmay / script.js
Last active Feb 2, 2018
Gscript for Sheets - get crypto tickers and maintain a history
View script.js
// Sample workbook here:
// https://docs.google.com/spreadsheets/d/1DPASIiKJw6x0n2eq7t4xRU_FQsizBH8Z8rXOfVk2Kb4/pubhtml
// Main function - does everything
// Triggered by Google every 15 minutes
function getAllTickers() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Crypto");
// Get all tickers
View bloop.js
(function() {
// Do not use this library. This is just a fun example to prove a
// point.
var Bloop = window.Bloop = {};
var mountId = 0;
function newMountId() {
return mountId++;
}