Skip to content

Instantly share code, notes, and snippets.

View pete-otaqui's full-sized avatar

Pete Otaqui pete-otaqui

View GitHub Profile
@pete-otaqui
pete-otaqui / bumpversion.sh
Created December 2, 2012 11:08
Bump a software project's VERSION, add the CHANGES, and tag with GIT
#!/bin/bash
# works with a file called VERSION in the current directory,
# the contents of which should be a semantic version number
# such as "1.2.3"
# this script will display the current version, automatically
# suggest a "minor" version update, and ask for input to use
# the suggestion, or a newly entered value.
@pete-otaqui
pete-otaqui / lloyds.css
Last active January 11, 2021 04:19
Lloyds Fonts
@font-face {
font-family: "Lloyds Jack Light";
src: url("https://www.lloydsbank.com/assets/fonts/LloydsBankJackLight/lloyds_bank_jack-lightWEB.woff") format('woff');
}
@font-face {
font-family: "Lloyds Jack Light";
src: url("https://www.lloydsbank.com/assets/fonts/LloydsBankJackMedium/lloyds_bank_jack-mediumWEB.woff") format('woff');
font-weight: bold;
}
@pete-otaqui
pete-otaqui / filterKeys.js
Last active August 14, 2019 10:14
Filter out keys from an object
const filterKeys = (obj, keys) =>
Object.entries(obj).reduce(
(acc, [k, v]) => (keys.includes(k) ? acc : { ...acc, [k]: v }),
{}
);
/**
// Usage:
const myObject = { foo: 'foo', bar: 'bar', baz: 'baz', eck: 'eck' };
@pete-otaqui
pete-otaqui / object.spawn.js
Created May 11, 2012 09:40
Prototypal inheritance in javascript using Object.create with functions getting a "parent" property to be able to call the method they overwrote
/**
* Object.spawn for a more terse form of Object.create,
* with the super added bonus of giving all overriden
* functions a "parent" property which refers back to
* thing it was overriding ... like "parent" or "super"
* in classical OOP
*
* @link http://howtonode.org/prototypical-inheritance
@pete-otaqui
pete-otaqui / download-website.sh
Created October 21, 2016 07:52
download a website for offline browsing with wget
#!/bin/bash
wget -E -k -r -p -e robots=off https://some-site.com/docs/
#### Note the following arguments:
# -E : converts downloaded HTML filenames to have a ".html" suffix
# -k : converts internal links within downloaded files to point to other downloaded files
# -r : recursively download by scanning for internal links in pages
# -p : download "page requisites", i.e. images, styles, scripts
# -e robots=off : ignore robots.txt (because some sites use it to avoid indexing)
@pete-otaqui
pete-otaqui / convert-img-to-base64.js
Created March 8, 2019 09:47
Convert Image to Base 64 WebDriver JS and Node style
// This runs in a browser,
// it's usable with WebDriver as an injected script
function convertImagetoBase64(selector) {
const image = document.querySelector(selector);
const canvas = document.createElement("canvas");
const context = canvas.getContext("2d");
const { width, height } = image;
canvas.width = width;
canvas.height = height;
context.drawImage(image, 0, 0, width, height);
@pete-otaqui
pete-otaqui / bump_version_number.php
Created May 13, 2013 13:45
Semantic version bumping in PHP
/**
* Semantically bump a version number, defaults to "minor".
*
* If your version number includes a prefix, (e.g. "v" in "v0.1.0")
* this will be preserved and returned. Any suffix (e.g. "-beta"
* in "v0.5.2-beta") will be lost.
*
* You can provide version numbers in the following formats:
* '0.1.2', 'v1.2-patched', '2.3', '3', 4.1, 5
* And you will get back (assuming a minor bump):
@pete-otaqui
pete-otaqui / Gulpfile.js
Created December 7, 2014 19:07
Simple Gulpfile with static serving and live reload
var gulp = require('gulp'),
connect = require('connect'),
serveStatic = require('serve-static'),
livereloadInjector = require('connect-livereload'),
livereloadTinyLR = require('tiny-lr'),
path = require('path'),
gutil = require('gulp-util');
var FOLDER_DEST = '.',
PORT_SERVER = process.env.PORT || 8888,
@pete-otaqui
pete-otaqui / happytime-amd.js
Last active February 10, 2018 18:00
A better setTimeout, setInterval and requestAnimationFrame, wrapped as an AMD module and fine for many JSHint setups.
/*
See http://paulirish.com/2011/requestanimationframe-for-smart-animating/
and http://blog.joelambert.co.uk/2011/06/01/a-better-settimeoutsetinterval/
*/
define([
],
function () {
'use strict';
@pete-otaqui
pete-otaqui / combos-and-pairs.js
Created July 12, 2017 06:23
Combinations and Pairs in javascript
const _ = require('lodash');
function getPairs(arr) {
let rCount = 0;
const results = arr.map(i => [i]);
const f = (base, rest) => {
for (let i = 0, max = rest.length; i < max; i += 1) {
const entry = [base, rest[i]];
results.push(entry);
}