Skip to content

Instantly share code, notes, and snippets.

View devinrhode2's full-sized avatar
😀

Devin Rhode devinrhode2

😀
View GitHub Profile
@RSNara
RSNara / decorators.js
Last active July 7, 2019 00:24
An example of using decorators in ES5.
function memoize(object, name, descriptor) {
var fn = descriptor.value;
var memoized = function() {
memoized.cache = memoized.cache || {};
var key = JSON.stringify(arguments);
return memoized.cache[key] = memoized.cache[key]
? memoized.cache[key]
: fn.apply(this, arguments);
}
descriptor.value = memoized;
@belohlavek
belohlavek / binaryUtil.js
Last active January 3, 2023 16:37
ASCII to Binary and Binary to ASCII Utility functions in Javascript.
var Util = {
toBinary: function(input) {
var result = "";
for (var i = 0; i < input.length; i++) {
var bin = input[i].charCodeAt().toString(2);
result += Array(8 - bin.length + 1).join("0") + bin;
}
return result;
},
@alexis89x
alexis89x / broadcast-channel-es6.js
Last active February 21, 2024 16:56
Broadcast Channel API polyfill
/**
@class BroadcastChannel
A simple BroadcastChannel polyfill that works with all major browsers.
Please refer to the official MDN documentation of the Broadcast Channel API.
@see <a href="https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_Channel_API">Broadcast Channel API on MDN</a>
@author Alessandro Piana
@version 0.0.6
*/
/*

A small sampling of external projects initially built for Ember use but designed to be used standalone:

@dgraham
dgraham / fetch.js
Last active March 24, 2023 15:44
Simple window.fetch wrapper.
(function() {
function status(response) {
if (response.ok) {
return response
} else {
var error = new Error(response.statusText || response.status)
error.response = response
throw error
}
}
Hi David
I'm impressed with your back ground and your responsibilities at 37signals. When researching your profile I also found that you have 4.8K followers and have been starred 29 times on GitHub. This speaks volumes to your work and your high technical expertise. I'd love the opportunity to speak with you about a Ruby Engineering role I'm currently working on for Heroku. I'd like to share more details about the position and find out if you or anyone you know would be interested.
Heroku is a Platform as a Service (PaaS) that lets you deploy, run and manage applications written in Ruby, Node.js, Java, Python, Clojure and Scala. Heroku is owned by Salesforce however, we operate as a completely separate entity. This allows us to maintain our technology, culture and the formula that has made us so successful.
Anyway, it would be great to set up sometime to chat. I am more than happy to answer any questions that you might have and it would be great for me to hear about what you are looking for in any potentia
@devinrhode2
devinrhode2 / StrictjQuery.js.markdown
Last active November 27, 2018 17:12
warn on empty jquery selection badSelectorAction devinrhode2

warn on empty jquery selection

Graduated to github: https://github.com/devinrhode2/StrictjQuery.js

But for the simple version (quite possibly better): (wait no its broke use the one on GH)

Warns when you have an empty jQuery selection, unless you do $('foo', failsafe);

 $.badSelectorAction = function badSelectorActionFn( selector, context ) {
@devinrhode2
devinrhode2 / TraceKitSupplement.js
Last active October 23, 2023 12:49
Stuff I've added to my error reporting/handling stuff in addition to TraceKit.js, ideally in a few months I don't write any of this code
function exceptionalException(message) {
'use strict';
if (exceptionalException.emailErrors !== false) {
exceptionalException.emailErrors = confirm('We had an error reporting an error! Please email us so we can fix it?');
}
}
//test
//exceptionalException('try 1!');
//exceptionalException('try 2!');
//THIS IS NOW SHIELD.JS github.com/devinrhode2/shield.js
/**
* (function(){
* ..code..
* }).runInTryCatch();
* Shorthand to run function in a TraceKit try/catch block.
*
* Prototype is less loud than:
* runInTryCatch(function(){
* ..code..
@devinrhode2
devinrhode2 / typeCheck.js
Last active November 19, 2018 21:14
Working on a typeCheck function
function postTweet(tweet /*string*/, from /*string*/) {
typeCheck(arguments);
}
postTweet('string', 'asdf');
postTweet('string', 222); //TypeError! run in console to see a nice error message!
function typeCheck(a) {
var newArr = [].slice.call(a);
var types = [];
var f = a.callee.toString();