Skip to content

Instantly share code, notes, and snippets.

View BrendonKoz's full-sized avatar

BrendonKoz BrendonKoz

View GitHub Profile
@LewisJEllis
LewisJEllis / getRelativeTimeString.ts
Last active March 6, 2024 13:31
Simplified getRelativeTimeString
// from https://twitter.com/Steve8708/status/1504131981444980739
// simplified to a function body of 8 tidy lines
// no loop needed, no 2d array of 3-tuples needed
// just 2 arrays, a findIndex call, and some indexing :)
export function getRelativeTimeString(
date: Date | number,
lang = "en"
): string {
const timeMs = typeof date === "number" ? date : date.getTime();
@millipedia
millipedia / calculate_reading_time.php
Last active December 20, 2021 12:23
Processwire hook to calculate article reading time
<?php
/**
*
* Calculate reading time on page save.
* Add this to your ready.php file.
* Uses a field called 'article_read_time' to store the value
* and the field 'page_content' as the readable content.
* You'll need to update those field names if yours are different.
*
@renekreijveld
renekreijveld / sphp
Last active January 10, 2024 15:54
Easy PHP version switching command-line script for devilbox
#!/bin/bash
# sphp - Easy PHP version switching command-line script for devilbox
# Written by: René Kreijveld, email[at]renekreijveld.nl
# Version
version=1.1
# Available PHP versions in devilbox
php_array=(5.2 5.3 5.4 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0)
# Devilbox folder
devilbox=/Users/yourusername/devilbox
@noelboss
noelboss / git-deployment.md
Last active May 2, 2024 15:47
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

@jasonclark
jasonclark / social-media-share-markup
Last active January 27, 2017 15:43
Minimum viable social metadata markup - opengraph and twitter; Based on: https://dev.twitter.com/cards/getting-started#opengraph
<meta property="og:title" content="EmbedThis (Oembed)"/>
<meta property="og:description" content="Utility app that checks for an Oembed endpoint & returns HTML embed code."/>
<meta property="og:image" content="http://www.lib.montana.edu/~jason/files/oembed-this/meta/img/share-code-small.png"/>
<meta property="og:url" content="http://www.lib.montana.edu/~jason/files/oembed-this/index.php"/>
<meta property="og:type" content="website"/>
<meta name="twitter:creator" property="og:site_name" content="@jaclark"/>
<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:site" content="http://www.jasonclark.info"/>
@lmccart
lmccart / gist:2273a047874939ad8ad1
Last active February 18, 2024 21:57
p5.js + p5.dom.js + clmtracker.js
<html>
<head>
<script src="clmtrackr.js"></script>
<script src="model_pca_20_svm.js"></script>
<script src="p5.js"></script>
<script src="p5.dom.js"></script>
<script>
var ctracker;
@addyosmani
addyosmani / README.md
Last active April 2, 2024 20:18 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@craigrodway
craigrodway / FieldtypeForms.module
Created November 17, 2013 17:11
Very simple Fieldtype that lists FormBuilder forms in a select box on editing pages.
<?php
/**
* ProcessWire Form Fieldtype.
* Stores reference to a single FormBuilder Form to allow easy selection on pages.
*
* ProcessWire 2.x
* Copyright (C) 2012 by Ryan Cramer
* Licensed under GNU/GPL v2, see LICENSE.TXT
*
@ShirtlessKirk
ShirtlessKirk / luhn.js
Last active February 12, 2024 05:09
Luhn validation algorithm
/**
* Luhn algorithm in JavaScript: validate credit card number supplied as string of numbers
* @author ShirtlessKirk. Copyright (c) 2012.
* @license WTFPL (http://www.wtfpl.net/txt/copying)
*/
var luhnChk = (function (arr) {
return function (ccNum) {
var
len = ccNum.length,
bit = 1,
@oodavid
oodavid / README.md
Last active April 6, 2024 18:45 — forked from aronwoost/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/