Skip to content

Instantly share code, notes, and snippets.

View kevinchisholm's full-sized avatar

Kevin Chisholm kevinchisholm

View GitHub Profile
@kevinchisholm
kevinchisholm / console-to-dom.js
Last active November 21, 2017 19:50
Show console.log output in the DOM
(function () {
var $consoleLog = $('<div id="console-log"></div>'),
newLine = function(){return $('<p class="console-line"></p>'); },
cssText = '.console-line{margin:10px;padding:10px;background-color:#ededed;border:1px solid #ccc;font-weight:700;font-family:monospace;color:#333;font-size:18px}.dir{background-color:#80e5a6}.info{background-color:#cff}.warn{background-color:#fdfd96}.error{background-color:#ff6961}',
$style = $('<style>' + cssText + '</style>');
//reminder: jQuery is a dependency!
$('body').prepend($consoleLog);
$('body').append($style);
@kevinchisholm
kevinchisholm / getYoutubeVideoId.js
Last active December 24, 2017 14:35
Get the ID from a YouTube Video URL
//set variables
var videoId = '',
youTubeUrlBase = 'https://www.youtube.com/watch?v=',
youTubeUrl = 'https://www.youtube.com/watch?v=JMP3MUwoEmw';
//returns the youtube ID from a URL
function getYoutubeId (url){
var myregexp = /(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/ ]{11})/i,
retArr = url.match(myregexp);
@kevinchisholm
kevinchisholm / angular2-http-observables-five-minutes.md
Last active December 24, 2017 15:00
Angular2 HTTP Observables in Five Minutes

RxJS Logo

Example code for the blog post: Angular2 HTTP Observables in Five Minutes

@kevinchisholm
kevinchisholm / _mapbox-maps-sdk-for-react-native.md
Last active December 24, 2017 21:37
Getting Started with the Mapbox Maps SDK for React Native
@kevinchisholm
kevinchisholm / _JavaScript-LET-vs-CONST.md
Last active January 3, 2018 00:04
What is the difference between LET and CONST in JavaScript?
@kevinchisholm
kevinchisholm / _angular-click-event-handler.md
Last active January 5, 2018 09:45
How do I set up an Angular click-event handler?