Skip to content

Instantly share code, notes, and snippets.

View oosby's full-sized avatar

Olivia Osby oosby

  • San Jose, CA by way of NC
View GitHub Profile
@oosby
oosby / EFIfq.markdown
Created April 4, 2014 19:41
A Pen by Olivia Osby.
@oosby
oosby / FjnrI.markdown
Created October 22, 2014 15:23
A Pen by Olivia Osby.
@oosby
oosby / prefixFinder.markdown
Created January 9, 2015 18:48
prefixFinder
function curryMe(x, y, z) {
return x / y * z;
};
function currier() {
var f = Array.prototype.shift.call(arguments);
var a = Array.prototype.slice.call(arguments);
function maker () {
var b = Array.prototype.slice.call(arguments),
c = a.concat(b);
@oosby
oosby / GraphWidget.js
Created November 2, 2015 04:58
React canvas widget for plotting simple points
var Graph = React.createClass({
displayName: 'graphWidget',
getDefaultProps() {
return {
backgroundColor: 'aliceblue',
canvasHeight: 200,
canvasWidth: 200,
clickThreshold: 10,
colorMatrix: {
<snippet>
<content><![CDATA[
gulp.task('${1}', function(){
gulp.${2:src}(${3})
.pipe(${4});
});
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>gt</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
const mutationObserver = new MutationObserver((e) => {
if (e[0].removedNodes) {
console.log('%cremoved nodes %o', 'color:aquamarine', e[0].removedNodes);
}
});
// watch just the child nodes
mutationObserver.observe(document.querySelector('main'), { childList: true });
@oosby
oosby / singletonmaker.js
Created October 17, 2016 20:47
Singleton Maker
function singletonMaker(key, klassname, namespace) {
if (!window[namespace]) {
window[namespace] = {};
}
const keySymbol = Symbol.for(key);
const globalSymbols = Object.getOwnPropertySymbols(namespace);
const hasKey = (globalSymbols.indexOf(keySymbol) > -1);
if (!hasKey) {
@oosby
oosby / enum
Last active February 17, 2017 20:29
javascript enum
function enummaker(obj = {}) {
let newEnum = obj;
newEnum[Symbol.iterator] = function() {
let i = 0;
let keys = Object.keys(this);
return {
next: function() {
let value = keys[i];
i++;
import { SOME_VALUE } from '../constants';
jest.mock('../constants', () => ({ SOME_VALUE: 'abc123test' }));