Skip to content

Instantly share code, notes, and snippets.

View james2doyle's full-sized avatar

James Doyle james2doyle

View GitHub Profile
@james2doyle
james2doyle / load-image-array.js
Created May 2, 2014 21:27
load an array of image URLs and call a function when the all the images have finished loading
var set = [
'http://lorempixel.com/200/200/food/1', 'http://lorempixel.com/200/200/food/2', 'http://lorempixel.com/200/200/food/3', 'http://lorempixel.com/200/200/food/4', 'http://lorempixel.com/200/200/food/5'
];
function done() {
var div = document.createElement('div');
div.innerHTML = "<p>Images Loaded</p>";
document.body.appendChild(div);
document.body.style.background = 'white';
}
var counter = 0; // start at 0
@james2doyle
james2doyle / rename-and-count.sh
Last active August 29, 2015 14:01
bash rename files to a number using a counter
#!/usr/bin/env bash
# start at 1
COUNTER=1
for FILE in *.jpg
do
echo "file - $FILE"
if [[ "$COUNTER" -lt "10" ]]; then
NUM=0
@james2doyle
james2doyle / square.svg
Created May 7, 2014 20:51
the most simple square svg element
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@james2doyle
james2doyle / circle.svg
Created May 7, 2014 20:53
the most simple svg circle element
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@james2doyle
james2doyle / triangle.svg
Created May 7, 2014 20:59
the most simple triangle svg element
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@james2doyle
james2doyle / arrow.svg
Created May 7, 2014 21:08
the most simple arrow svg element
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@james2doyle
james2doyle / circle-image.svg
Created May 8, 2014 18:31
a simple example of an image inside of a SVG element
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@james2doyle
james2doyle / color-loop.scss
Created May 9, 2014 15:30
A small loop for iteration over an array of colours and their names
$colors: $red, $green, $dark, $blue, $orange;
$color-names: red, green, dark, blue, orange;
// count of $colors starts at 1
@for $i from 1 through 5 {
$color: nth($colors, $i);
$name: nth($color-names, $i);
.btn.#{$name}-bg:hover, .btn.#{$name}-bg:active {
background-color: darken($color, 10%);
}
}
@james2doyle
james2doyle / random-color.php
Created May 24, 2014 14:34
Randomly generate CSS-safe colors.
<?php $randomcolor = '#' . strtoupper(dechex(rand(256, 16777215)));
@james2doyle
james2doyle / self-filename.php
Created May 25, 2014 14:12
Echo out the the name of the current PHP file in use
<?php echo pathinfo($_SERVER['PHP_SELF'])['filename'] ?>