Skip to content

Instantly share code, notes, and snippets.

View jonobr1's full-sized avatar
🐌
Petit à petit ça avance

Jono jonobr1

🐌
Petit à petit ça avance
View GitHub Profile
@jonobr1
jonobr1 / sound.js
Last active May 1, 2018 01:53
Handle loading, playing, and managing WebAudio API buffers as "simple" sound.
/**
* @jonobr1 / http://jonobr1.com/
*/
(function() {
var root = this;
var previousSound = root.Sound || {};
var ctx, analysis, has;
@jonobr1
jonobr1 / xhr.js
Created August 1, 2016 17:53
A nano JavaScript object that abstracts xhr requests into jQuery style methods.
(function() {
var root = this;
var previousXhr = root.xhr || {};
var xhr = root.xhr = {
noConflict: function() {
root.xhr = previousXhr;
return xhr;
@jonobr1
jonobr1 / google-sheet-to-json.js
Last active April 26, 2024 15:41
A node.js script to convert a Google Sheet into a JSON object
/**
* Simple Node.js script to turn a specific page on a Google Sheet
* into a JSON object for the main purpose of HTML Templating.
*
* @author jonobr1 / http://jonobr1.com
*
*/
var https = require('https');
var path = require('path');
@jonobr1
jonobr1 / auto-capture.scpt
Last active March 21, 2024 02:34
A small AppleScript to take a screenshot every 30 seconds for 8 hours. Saves to an Image Sequence in a desktop folder. Great for recording your workday.
set dFolder to "~/Desktop/screencapture/"
do shell script ("mkdir -p " & dFolder)
set i to 0
repeat 960 times
do shell script ("screencapture " & dFolder & "frame-" & i & ".png")
delay 30 -- Wait for 30 seconds.
set i to i + 1
end repeat
@jonobr1
jonobr1 / easing.js
Last active March 12, 2021 17:46
A collection of Easing functions
/**
* Port of Penner Easing Equations into human legible dot-notation syntax.
*
* @author Robert Penner / http://robertpenner.com/easing/
* @author jonobr1 / http://jonobr1.com/
*
* License: http://robertpenner.com/easing_terms_of_use.html
*
*/
(function() {
@jonobr1
jonobr1 / tween.easing.seat.js
Last active February 5, 2016 19:41
Seat easing for tween.js
TWEEN.Easing.Seat = {
In: function(t) {
return Math.pow(t - 1, 3) + 1;
},
Out: function(t) {
return Math.pow(t, 3);
},
InOut: function(t) {
return (Math.pow(2 * t - 1, 3) + 1) / 2;
}
@jonobr1
jonobr1 / Export Class
Last active August 29, 2015 14:05
Export private class to external object.
/*
* Base class
*/
(function() {
var root = this;
var previousBase = root.Base || {};
var foo = 1;
@jonobr1
jonobr1 / Preferences.sublime-settings
Last active December 24, 2015 15:09
Personal preferences when editing in Sublime Text.
{
"color_scheme": "Packages/Color Scheme - Default/Twilight.tmTheme",
"detect_indentation": true,
"draw_white_space": "all",
"font_face": "Monaco",
"font_size": 12.0,
"highlight_line": true,
"ignored_packages":
[
"All Autocomplete",
@jonobr1
jonobr1 / bezier-util.js
Created June 28, 2013 22:40
Cubic bezier curve utility methods in JavaScript.
function getPointOnCurve(v1, c1, c2, v2, t) {
return {
x: bezierPoint(t, v1.x, c1.x, c2.x, v2.x),
y: bezierPoint(t, v1.y, c1.y, c2.y, v2.y)
};
}
function bezierPoint(t, o1, c1, c2, e1) {
@jonobr1
jonobr1 / interpret.js
Last active April 24, 2020 16:11
Interpret any valid css string and return an r, g, b, (a) object with normalized values.
/**
* Interpret any valid css string as an r, g, b, (a) object.
* If nothing found then it returns an object that is black with
* no alpha.
*
* Usage: interpret('red'); // { r: 1, g: 0, b: 0 };
* interpret('#f00'); // { r: 1, g: 0, b: 0 };
* interpret('#ff000'); // { r: 1, g: 0, b: 0 };
* interpret('rgb(255, 0, 0)'); // { r: 1, g: 0, b: 0 };
* interpret('rgba(255, 0, 0, 1)'); // { r: 1, g: 0, b: 0, a: 1 };