Skip to content

Instantly share code, notes, and snippets.

View CITguy's full-sized avatar

Ryan Johnson CITguy

View GitHub Profile
@CITguy
CITguy / ChildNode.js
Last active January 14, 2019 18:24
Web API Polyfills
// Modified from https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/remove#Polyfill
[
Element.prototype,
CharacterData.prototype,
DocumentType.prototype,
].forEach(function (proto) {
if (!proto.hasOwnProperty('remove')) {
Object.defineProperty(proto, 'remove', {
configurable: true,
enumerable: true,
@CITguy
CITguy / medly-wordcloud.js
Created November 19, 2018 08:32
Rapid D3.js - Section 6 - Word Cloud example code
var fill = d3.scale.category20();
var layout = d3.layout.cloud()
.size([500, 500])
.words([
"Hello", "world", "normally", "you", "want", "more", "words",
"than", "this"].map(function(d) {
return {text: d, size: 10 + Math.random() * 90, test: "haha"};
}))
.padding(5)
.rotate(function() { return ~~(Math.random() * 2) * 90; })
@CITguy
CITguy / fix-base-anchor-links-es5.js
Last active October 29, 2017 17:45
Use vanilla JavaScript to fix in-page anchors when using <base>
@CITguy
CITguy / hexo.js
Last active August 11, 2017 18:14
Using Browsersync + Hexo to run a local development server
#!/usr/bin/env node
'use strict';
const Hexo = require('hexo');
const YAML = require('js-yaml');
const fs = require('fs');
const cwd = process.cwd();
exports.hexo = new Hexo(cwd);
@CITguy
CITguy / webplatform.md
Last active July 17, 2019 22:18
Web Platform
@CITguy
CITguy / currencyToPennies.js
Last active October 9, 2015 15:13
String manipulation of currency to acquire penny amount
function currencyToPennies (currency) {
// ensure string
var strCurrency = currency.toString();
// ignore any character that's not part of a number
var wholeAmount = strCurrency.replace(/[^0-9.]/g, '');
// locate decimal
var decimalIndex = wholeAmount.indexOf('.');
var normalizedAmount;
@CITguy
CITguy / component.js
Last active July 17, 2019 22:31
Deprecating AngularJS directives via console.warn()
app.directive('myOldDirective', function (myNewDirective) {
var warnMsg = 'DEPRECATION WARNING: myOldDirective has been marked as deprecated ' +
'and will be removed in a future release. ' +
'Please use myNewDirective as a replacement.';
console.warn(warnMsg); // jshint ignore:line
return myNewDirective[0];
});
@CITguy
CITguy / tour.md
Last active February 18, 2016 23:05
Tour of Ruby Gems

Tour de Gems

Items in bold are those that I have the most experience.

Must Have Gems

  • bundler - It manages your project's gem versions, so you don't have to. If you aren't using it, see me after class ಠ_ಠ

Background Jobs