Skip to content

Instantly share code, notes, and snippets.

View robpataki's full-sized avatar

Rob Pataki robpataki

  • Valtech
  • York UK
View GitHub Profile
@robpataki
robpataki / svg-connector.js
Created May 4, 2017 18:40
SVG Connector helps with drawing connections between coordinates using dots and lines
// Colour scheme: https://coolors.co/f61067-5e239d-00f0b5-6decaf-f4f4ed
var NS = 'http://www.w3.org/2000/svg';
var Victor = function(artboardElementSelector) {
if (typeof artboardElementSelector === 'string') {
this.setArtboard(artboardElementSelector);
}
this.connections = {
@robpataki
robpataki / time-string.js
Last active April 16, 2020 14:02
Convert time in milliseconds to human readable hours:minutes:seconds formatedt string
var getTimeString = function(timeInMs) {
var delim = ":";
var hours = Math.ceil(timeInMs / (1000 * 60 * 60) % 60);
var minutes = Math.floor(timeInMs / (1000 * 60) % 60);
var seconds = Math.floor(timeInMs / 1000 % 60);
hours = hours < 10 ? '0' + hours : hours;
minutes = minutes < 10 ? '0' + minutes : minutes;
seconds = seconds < 10 ? '0' + seconds : seconds;
return hours + delim + minutes + delim + seconds;
@robpataki
robpataki / addup.js
Created May 11, 2017 16:23
Add up numbers in an array
function addUp(arr) {
return arr.reduce(function(a, b){return a+b;}, 0)
}
var arr = [1, 2, 3, 4, 5];
var sum = addUp(arr); //15
@robpataki
robpataki / dotcon.js
Created May 12, 2017 11:41
Betterer version of SVGConnector
/*!
* Dot Connector
* Rob Pataki [[email protected]] [https://robp.io]
* Date: 2017-05-04
* Demo: https://jsfiddle.net/robertp/zsrn3e5o/
*/
var NS = 'http://www.w3.org/2000/svg';
var DotCon = function(artboardElement) {
@robpataki
robpataki / name_changer-notes.md
Last active May 21, 2017 18:30
Notes for the NameChanger app for Mac

Notes for NameChanger App for Mac

Regular Expressions

Insert a '-' after the track number

  • Example: change - 01 Blah to - 01 - Blah
  • Original Text field: ( - [0-9][0-9] )
  • New Text field: $1-
@robpataki
robpataki / _easing-functions.scss
Last active August 10, 2022 18:51
Easing functions to be used in SCSS
// Easing function variables - http://easings.net/#easeOutQuint
// SINE
$ease-in-sine: cubic-bezier(0.47, 0, 0.745, 0.715);
$ease-out-sine: cubic-bezier(0.39, 0.575, 0.565, 1);
$ease-in-out-sine: cubic-bezier(0.445, 0.05, 0.55, 0.95);
// QUAD
$ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53);
$ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);
@robpataki
robpataki / MySQL-Notes.md
Last active November 8, 2017 17:33
MariaDB / MySQL notes

Important MySQL Commands

Enter MySQL

$ sudo mysql

List databases

$ show databases;
@robpataki
robpataki / ssl-certbot.md
Last active November 8, 2017 09:32
SSL certificate notes

SSL certificates on Linode instance

Use certbot

Auto renew certificates

./certbot-auto renew --dry-run
...
./certbot-auto renew --quiet --no-self-upgrade
@robpataki
robpataki / vagrant-notes.md
Created November 9, 2017 12:29
Vagrant notes

Vagrant notes

Get the currently used environment and auth credentials from Vagrant

  $ vagrant ssh
  $ cd /srv/www/[project_name]/current
  $ cat .env
@robpataki
robpataki / class-twiddler.js
Last active April 6, 2018 08:40
Vanilla JavaScript utility functions to manipulate DOM element class names (IE6 compatible)
(function() {
function pruneSpaces(el) {
el.className = el.className.replace(/^\s+|\s+$/g, '');
}
function toggleClass(el, className) {
if (hasClass(el, className)) {
removeClass(el, className);
} else {
addClass(el, className);