Skip to content

Instantly share code, notes, and snippets.

View RoryDuncan's full-sized avatar

Rory Duncan RoryDuncan

View GitHub Profile
@RoryDuncan
RoryDuncan / requestAnimationFrame
Created August 5, 2013 23:15
Paul Irish's requestAnimationFrame shim in coffeescript.
lastTime = 0
vendors = ['ms', 'moz', 'webkit', 'o']
for x in vendors and not window.requestAnimationFrame
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] or
window[vendors[x]+'CancelRequestAnimationFrame']
if not window.requestAnimationFrame
@RoryDuncan
RoryDuncan / Stack object
Created February 6, 2014 20:40
A stack object which can be used similar to a queue or whatnot.
var Stack = (function() {
var list = []; // Private to the instance.
var append = function() {
for ( var x = 0, xx = arguments.length; x< xx; x++ ) {
list.push( arguments[x] );
}
return this;
@RoryDuncan
RoryDuncan / extend
Created February 8, 2014 02:03
Extend the properties of one object into another.
// functionality similar (if not the same) as _'s extend method
var extend = function(){
if (arguments.length < 2) return;
var extended = arguments[0];
for (var _x = 1, _xx = arguments.length; _x < _xx; _x++) {
var base = arguments[_x];
for (var key in base) {
extended[key] = base[key];
var contains = function(text, word) {
if ( text.split(word).length > 1 ) return true;
return false;
};
@RoryDuncan
RoryDuncan / showBinary.hla
Created October 19, 2015 16:27
showBinary HLA procedure
// procedure forward declarations
procedure showBinary(value: byte); @forward;
// procedure definitions
procedure showBinary(value: byte);
begin showBinary;
push(eax);
push(ecx);
@RoryDuncan
RoryDuncan / eos-setup.sh
Created March 13, 2017 08:05
After a fresh install of a elementaryOS
steps=6
currentstep=1
function update() {
echo -e "\n================================================================================"
echo -e "\t\tStep $currentstep of $steps: $@"
echo -e "================================================================================\n"
currentstep=$((currentstep+1))
@RoryDuncan
RoryDuncan / editor.js
Last active June 13, 2019 01:32
Simple Focus-based Editor
//
// A class that manages the event lifecycle, sanitization, and UX resolution when editing an input.
// See `Editor.edit()` for primary API usage.
// Example code at bottom.
//
export default class Editor {
constructor(maxlength = 60) {
this.maxlength = maxlength;
this.el = null;
@RoryDuncan
RoryDuncan / kick-all-from-google-meet.js
Created September 13, 2020 22:42
Script for kicking all users from a google meet call
(() => {
let thenKickSelf = window.confirm("Kick yourself too?");
const wait = (ms) => new Promise(resolve => window.setTimeout(resolve, ms));
const click = (el) => (el.click(), wait(260));
const confirm = () => click(document.querySelector(`[data-id="EBS5u"]`));
const buttons = Array.from(document.querySelectorAll(`[data-tooltip="Remove from meeting"]`));
const kickSelf = () => document.querySelector(`[data-tooltip="Leave call"]`).click();
let init = wait(0);