Skip to content

Instantly share code, notes, and snippets.

View banjeremy's full-sized avatar

Jeremy Jones banjeremy

  • pnw
  • 17:03 (UTC -07:00)
View GitHub Profile
@banjeremy
banjeremy / isDayAnOccurance.js
Last active May 24, 2016 17:54
checks if a given day is an occurance in a recurrence rule
export function isDayAnOccurance(day, recurrenceRule) {
const rule = RRule.fromString(recurrenceRule);
// Convert all dates into UTC before comparison
const today = moment(day).utc().startOf('day');
const nextOccurrence = moment(rule.after(today, true)).utc();
const match = moment(nextOccurrence).isSame(today, 'day');
return match;
}
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
@banjeremy
banjeremy / hello-world-threejs.html
Last active April 10, 2023 01:58
Hello World with Three.js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello, Three.js!</title>
<style>
body { margin: 0; }
canvas { width: 100%; height: 100%; }
</style>
</head>
@banjeremy
banjeremy / light
Created January 26, 2015 00:16
Firefox Light Sensor Events
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.darklight {
background-color: #000;
color: #fff;
@banjeremy
banjeremy / checkMediaSource.js
Created January 21, 2015 00:40
Detect if MediaSource API is available
(function(){
if (typeof MediaSource === typeof undefined){
alert('You must be on FireFox or some old IE bullshit');
} else {
alert('You are running a MediaSource API capable browser');
}
})();
@banjeremy
banjeremy / thumbnail-directive.js
Last active August 29, 2015 14:13
Angular directive for thumbnail hover previews.
'use strict';
app.directive('thumbnail', function($interval){
return {
restrict: 'E',
scope: {
thumbs: '&thumbs',
speed: '&speed'
},
template: '<div class="thumbnail"><img ng-src="assets/images/thumbnails/{{thumb}}"/></div>',
@banjeremy
banjeremy / queryparams.js
Last active August 29, 2015 14:05
Here is a useful little function to grab the query string parameters from the window.location object.
function getQueryParams() {
var params = [];
var query = window.location.search;
query = query.slice(1, query.length);
var nv = query.split('&');
for (var i = 0; i < nv.length; i++) {
var q = nv[i].split('=');
params[q[0]] = q[1];
}