Skip to content

Instantly share code, notes, and snippets.

Avatar

Donovan Hutchinson donovanh

View GitHub Profile
@donovanh
donovanh / database.js
Created Jul 6, 2021
Example Movies and Actors Database
View database.js
'use strict';
const actors = {
a01: {
id: 'a01',
name: 'Harvey Keitel'
},
a02: {
id: 'a02',
name: 'Tim Roth'
View Gulpfile for Mocha & Node.js
// Include gulp
var gulp = require('gulp');
// Include Our Plugins
var jshint = require('gulp-jshint');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var mocha = require('gulp-mocha');
View list-items.js
var randomColours = ['3c6dd1', 'd13c9e', '3cd19e'];
var currentColour = 0;
var currentDemoColour = 0;
$(function() {
$('.add-to-list button').click(function(e) {
addLI($(e.target).parent(), false);
});
$('.add-to-list li').each(function(index, item) {
bindNewLI($(item));
});
View test.js
console.warn('Sending an error to browser')
BOOM
@donovanh
donovanh / gulpfile.js
Created Jul 28, 2014
Gulp file for Jekyll, with Sass, Autoprefixer, and browsersync
View gulpfile.js
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
clean = require('gulp-clean'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
View twitter-entities.js
/*
* twitter-entities.js
* This function converts a tweet with "entity" metadata
* from plain text to linkified HTML.
*
* See the documentation here: http://dev.twitter.com/pages/tweet_entities
* Basically, add ?include_entities=true to your timeline call
*
* Copyright 2010, Wade Simmons
* Licensed under the MIT license
@donovanh
donovanh / app.js
Last active Jan 18, 2016
Cat -> Dog (Node.js)
View app.js
/*
This is a Node application that generates paths between two words. Spec:
Write some code that will, given a word, e.g. dog, and another word, e.g. cat, will output a sequence of valid words (in a dictionary), where each pair of adjacent words are only different by 1 character. e.g. dog -> dot -> cot -> cat. If you can, also output the entire list of all such paths between two words.
Usage:
* Install Node
* Place "app.js" and "dictionary.js" files in a directory
* In terminal, navigate to the directory and run "node app"
The method (cat2DogAllPaths) accepts 3 arguments:
@donovanh
donovanh / 0_reuse_code.js
Created Oct 3, 2013
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@donovanh
donovanh / gist:5814722
Last active Dec 18, 2015 — forked from oisin/gist:4444722
A handy bash prompt customization that shows the working directory followed by the current branch, and an asterisk if the branch is dirrrrty.
View gist:5814722
# Highlighting on prompt
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
COLOR_NONE="\[\e[0m\]"
parse_git_branch() {
git_status="$(git status 2> /dev/null)"
branch_pattern="^# On branch ([^${IFS}]*)"
@donovanh
donovanh / Animation & text mixins
Created Apr 20, 2013
Mixins for SASS including: - Animation - Keyframes - Text fill/stroke
View Animation & text mixins
/* Mixins to extend what Compass provides */
=animation($values...)
-webkit-animation: $values
-moz-animation: $values
-o-animation: $values
-ms-animation: $values
animation: $values
=keyframes($name)