Skip to content

Instantly share code, notes, and snippets.

View woganmay's full-sized avatar

Wogan May woganmay

View GitHub Profile
@woganmay
woganmay / api.php
Created June 12, 2019 01:21
Detect new versions of app.js automatically
<?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 September 7, 2018 09:40
Pull Toggl entries through the Reports API, into an incremental Sheet tab.
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 / script.js
Last active February 2, 2018 22:05
Gscript for Sheets - get crypto tickers and maintain a history
// 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
@woganmay
woganmay / page.php
Created November 5, 2017 12:33
Simple HTTP POST request from an OctoberCMS form submission
<?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 October 2, 2017 19:38
Manage a tracking pixel
<?php
namespace App\Http\Controllers;
use App\Http\Requests;
use Illuminate\Http\Request;
use App\Jobs\SendOpened;
class PixelController extends Controller
@woganmay
woganmay / bloop.js
Created May 14, 2017 20:20 — forked from jlongster/bloop.js
bloop
(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++;
}
@woganmay
woganmay / download.php
Created April 23, 2017 19:42
PHP code for downloading an entire ATOM timeline
<?php
// composer require phpoffice/phpexcel
require 'vendor/autoload.php';
// Webfinger
$url = "https://wogan.im/@wogan";
/**
* Start Webfinger lookup
@woganmay
woganmay / listen.js
Created April 25, 2017 10:11
Subscribe to a Mastodon streaming URL with NodeJS
// npm install websocket
var WebSocketClient = require('websocket').client;
var client = new WebSocketClient();
client.on('connectFailed', function(error) {
console.log('Connect Error: ' + error.toString());
});
client.on('connect', function(connection) {
/*
* Instructions:
* Open Mastodon, hit F11 (or whatever brings up your console)
* Paste this and hit enter
* http://i.imgur.com/LtQ5Zk3.gifv
*/
$(function(){
// Fetch the Emojione clientside library
$.getScript("https://cdnjs.cloudflare.com/ajax/libs/emojione/2.2.7/lib/js/emojione.min.js");
@woganmay
woganmay / sample-mailable.php
Created February 19, 2017 07:30
Send basic templated email with Mailable
<?php
public function build()
{
return $this
->subject('Mail Subject')
->view('vendor.notifications.email')->with([
"level" => "default",
"greeting" => "Hi, User!",
"introLines" => [