Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View james2doyle's full-sized avatar

James Doyle james2doyle

View GitHub Profile
@james2doyle
james2doyle / chose_color.scpt
Created March 30, 2020 20:42 — forked from mariocesar/chose_color.scpt
Apple Script / Start the color choose, convert the selected color to HEX and copy to the clipboard
# Open the color picker
on convertRGBColorToHexValue(theRGBValues)
set theHexList to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
set theHexValue to ""
repeat with a from 1 to count of theRGBValues
set theCurrentRGBValue to (item a of theRGBValues) div 256
if theCurrentRGBValue is 256 then set theCurrentRGBValue to 255
set theFirstItem to item ((theCurrentRGBValue div 16) + 1) of theHexList
set theSecondItem to item (((theCurrentRGBValue / 16 mod 1) * 16) + 1) of theHexList
set theHexValue to (theHexValue & theFirstItem & theSecondItem) as string
@james2doyle
james2doyle / my.css
Last active April 12, 2016 20:48 — forked from anonymous/my.css
CSS Gradient Animation
body {
background: linear-gradient(293deg, #aad8cb, #dc654d, #f7d66c, #372e36, #1a1919);
background-size: 1000% 1000%;
-webkit-animation: background 30s ease infinite;
-moz-animation: background 30s ease infinite;
-o-animation: background 30s ease infinite;
animation: background 30s ease infinite;
height: 1vh;
width: 1vw;
}
@james2doyle
james2doyle / readyState.js
Created March 8, 2016 15:25 — forked from AllThingsSmitty/readyState.js
Using readyState to show document state
// credit: Louis Lazaris
document.onreadystatechange = function () {
switch (document.readyState) {
case 'loading':
console.log('loading...');
break;
case 'interactive':
console.log('DOM is ready...');
break;
case 'complete':
@james2doyle
james2doyle / levenshtein.lua
Last active November 24, 2022 21:52 — forked from Badgerati/levenshtein_algorithm.lua
An implementation of the Levenshtein distance algorithm in Lua
-- Returns the Levenshtein distance between the two given strings
-- Lower numbers are better
local function levenshtein(str1, str2)
local len1 = #str1
local len2 = #str2
local matrix = {}
local cost = 1
local min = math.min;
-- quick cut-offs to save time
<?php
// specify your css-files and their order here
$cssFiles = array(
'normalize.css', 'style.css', 'print.css', 'colorbox.css'
);
// the file to write the compressed css to
$minFileName = 'minified.css';
// thats all, just call this file in your browser and it will
// build you a minimized css-file. then just link to this single
function has3d(){
var el = document.createElement('p'),
has3d,
transforms = {
'webkitTransform':'-webkit-transform',
'OTransform':'-o-transform',
'msTransform':'-ms-transform',
'MozTransform':'-moz-transform',
'transform':'transform'
};
#!/usr/bin/env node
var fs = require('fs');
var exec = require('child_process').exec;
/*
* lesswatch usage:
*
* `lesswatch` to watch the current directory
// Based on https://github.com/james2doyle/saltjs
window.$ = function(s) {
try {return document[{
'#': 'getElementById',
'.': 'getElementsByClassName',
'@': 'getElementsByName',
'=': 'getElementsByTagName',
'?': 'querySelectorAll'
}[s[0]]](s.slice(1));}catch(e){}
};
@james2doyle
james2doyle / $.3.js
Created May 14, 2013 16:20 — forked from ofca/$.3.js
// based on https://gist.github.com/Potfur/5576225 & https://github.com/james2doyle/saltjs
// more info: https://plus.google.com/109231487156400680487/posts/63eZzzrBSb6
window.$ = function(s) {
var c = {
'#': 'ById',
'.': 'sByClassName',
'@': 'sByName',
'=': 'sByTagName'}[s[0]];
return document[c?'getElement'+c:'querySelectorAll'](s.slice(1))
};
@james2doyle
james2doyle / async_load.js
Last active December 15, 2015 18:58 — forked from brandonb927/gist:4580977
JS lazyloading that is non-blocking, shamefully stolen from http://friendlybit.com/js/lazy-loading-asyncronous-javascript/
(function() {
function async_load(){
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = 'http://yourdomain.com/script.js';
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
}
if (window.attachEvent) {