Skip to content

Instantly share code, notes, and snippets.

View callumacrae's full-sized avatar

Callum Macrae callumacrae

View GitHub Profile
@callumacrae
callumacrae / show-between.directive.js
Last active August 29, 2015 14:02
showBetweenHours directive
'use strict';
/* global angular */
var app = angular.module('playground', []);
app.directive('showBetweenHours', function () {
return {
restrict: 'AC',
link: function (scope, element, attrs) {
@callumacrae
callumacrae / build-tools.md
Last active October 25, 2023 15:14
Build tools written in JavaScript
function* forEachGen(arr, func) {
for (let i = 0; i < arr.length; i++) {
yield func(arr[i]);
}
}
function* multiplyNums(num, ...arr) {
yield* forEachGen(arr, x => x * num);
}
  • Item one
  • Item two
  • Item three
PROMPT=$'\n┌─<%~> %{$fg[green]%}<%n@%m %*> \n%{$reset_color%}└─> '
RPROMPT='%{$fg_bold[blue]%}$(git_prompt_info)%{$reset_color%}'
if [[ $TERM = "xterm-256color" ]];
then DIRTY_MARK="✗"; CLEAN_MARK="✔"
else DIRTY_MARK="X"; CLEAN_MARK="Y"
fi
ZSH_THEME_GIT_PROMPT_PREFIX="<"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg_bold[blue]%}>"
@callumacrae
callumacrae / gist:8171299
Created December 29, 2013 15:09
gulpfile.js
'use strict';
var gulp = require('gulp');
gulp.task('build', function () {
gulp.run('less');
});
gulp.task('less', function () {
var less = require('gulp-less'),
var fs = require('fs');
/* jshint camelcase: false */
module.exports = function (grunt) {
'use strict';
var DEBUG = grunt.cli.tasks[0] !== 'build';
var config = {
var MyToolbox = function (query) {
var el = document.querySelectorAll(query), i;
for (i = 0; i < el.length; i++) {
this[i] = el[i];
}
this.length = i;
};
var $ = function (query) {
return new MyToolbox(query);
@callumacrae
callumacrae / rand.js
Created March 29, 2013 12:52
Random number generator.
/**
* Returns random numbers. See individual functions for docs.
*
* This function can be used as a shortcut function: by default, it will call
* rand.int() using the arguments given to it. You can change which method it
* will call by changing the rand.default string to any of the method names.
*/
function rand(length) {
"use strict";
callumacrae@callum-imac [06:12:41] [~]
-> % curl http://area51.phpbb.com/phpBB/ > /dev/null
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 38594 100 38594 0 0 19718 0 0:00:01 0:00:01 --:--:-- 22321
callumacrae@callum-imac [06:12:44] [~]
-> % curl https://www.phpbb.com/community/ > /dev/null
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 51132 0 51132 0 0 31547 0 --:--:-- 0:00:01 --:--:-- 74645