Skip to content

Instantly share code, notes, and snippets.

View welt's full-sized avatar
😊
Focusing

_welt welt

😊
Focusing
  • Agent Software Ltd
  • Manchester
  • 04:22 (UTC -12:00)
View GitHub Profile
@welt
welt / AWS_S3_Presign_Download.php
Created October 28, 2022 12:44 — forked from anthonyeden/AWS_S3_Presign_Download.php
AWS S3: Pre-sign Upload & Download Requests [PHP]
<?php
function AWS_S3_PresignDownload($AWSAccessKeyId, $AWSSecretAccessKey, $BucketName, $AWSRegion, $canonical_uri, $expires = 8400) {
// Creates a signed download link for an AWS S3 file
// Based on https://gist.github.com/kelvinmo/d78be66c4f36415a6b80
$encoded_uri = str_replace('%2F', '/', rawurlencode($canonical_uri));
// Specify the hostname for the S3 endpoint
if($AWSRegion == 'us-east-1') {
@welt
welt / LitElementDialogExample.js
Created February 11, 2020 13:58 — forked from ErikHellman/LitElementDialogExample.js
Basic dialog example with LitElement
import { LitElement, html } from '@polymer/lit-element'
import { classMap } from 'lit-html/directives/classMap'
class MyDialog extends LitElement {
constructor () {
super()
this.opened = false
}
@welt
welt / router.js
Created February 10, 2020 10:17 — forked from fr0gs/router.js
//ROUTER
//Silly small javascript router to help me learn how they worked in a very simple way
// https://medium.com/@fro_g/routing-in-javascript-d552ff4d2921
(function (){
const appDiv = "app";
// Both set of different routes and template generation functions
let routes = {};
let templates = {};
@welt
welt / Autoloader.php
Last active November 14, 2019 22:35 — forked from schlessera/Autoloader.php
Generic Autoloader
<?php
namespace Generic;
use RuntimeException;
/**
* Class Autoloader.
*
* This is a custom autoloader to replace the functionality that we would

Custom Gutenberg Block

This is a basic custom Gutenberg block. Files explained below.

  • block.js — We register Custom Gutenberg block here.
  • editor.css _ Block CSS for the editor.
  • style.css — Block CSS for the front end.
  • index.php — Enqueue block's assets for editor and the front end.
@welt
welt / haiku
Created January 16, 2019 20:30 — forked from friggeri/haiku
random heroku-like name generator
haiku = ->
adjs = [
"autumn", "hidden", "bitter", "misty", "silent", "empty", "dry", "dark",
"summer", "icy", "delicate", "quiet", "white", "cool", "spring", "winter",
"patient", "twilight", "dawn", "crimson", "wispy", "weathered", "blue",
"billowing", "broken", "cold", "damp", "falling", "frosty", "green",
"long", "late", "lingering", "bold", "little", "morning", "muddy", "old",
"red", "rough", "still", "small", "sparkling", "throbbing", "shy",
"wandering", "withered", "wild", "black", "young", "holy", "solitary",
"fragrant", "aged", "snowy", "proud", "floral", "restless", "divine",
@welt
welt / star-wars-planets.html
Created November 16, 2018 17:32 — forked from richard-flosi/star-wars-planets.html
Web Component using Custom Element, Shadow DOM, fetch, async/await, and the Star Wars API
<html>
<head>
<script>
customElements.define("star-wars-planets", class extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: "open" });
}
static get observedAttributes() { return ["loading", "planets"]; }
@welt
welt / data-bind.js
Created September 6, 2018 09:07 — forked from tkh44/data-bind.js
Automatically bind events from data-attribute. This is based off of sparky.js, but ported to YUI3.
/*Automatic binding handler
*Attribute data-handler is the function in Events.handlers that handles the event
*Attribute data-event is the event to bind to element. Defaults to click if none is provided
* -To attach multiple events seperate them with '|'. Ex. data-event="click|focus"
*Attribute data-binded can be set to false to prevent the event from being attached to the element at run time.
* -Set attribute to true then run Events.bindEvents() to bind the event. Elements that have already been bound are skipped.
*/
Events = {
handlers: {
# Install brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install composer
brew install homebrew/php/composer
### PHPCS
composer global require "squizlabs/php_codesniffer=*"
# Add to your .bash_profile
@welt
welt / Swipe-Example.js
Created July 14, 2017 08:22 — forked from Tam/Swipe-Example.js
Vanilla JavaScript Swipe Detection
new Swipe(document.getElementById("gallery"), function(event, direction) {
event.preventDefault();
switch (direction) {
case "up":
// Handle Swipe Up
break;
case "down":
// Handle Swipe Down
break;