Skip to content

Instantly share code, notes, and snippets.

Avatar

James Doyle james2doyle

View GitHub Profile
@james2doyle
james2doyle / chose_color.scpt
Created Mar 30, 2020 — forked from mariocesar/chose_color.scpt
Apple Script / Start the color choose, convert the selected color to HEX and copy to the clipboard
View chose_color.scpt
# 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 Apr 12, 2016 — forked from anonymous/my.css
CSS Gradient Animation
View my.css
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 Mar 8, 2016 — forked from AllThingsSmitty/readyState.js
Using readyState to show document state
View readyState.js
// 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 Sep 27, 2020 — forked from Badgerati/levenshtein_algorithm.lua
An implementation of the Levenshtein distance algorithm in Lua
View levenshtein.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
View minify.php
<?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
View has3d.js
function has3d(){
var el = document.createElement('p'),
has3d,
transforms = {
'webkitTransform':'-webkit-transform',
'OTransform':'-o-transform',
'msTransform':'-ms-transform',
'MozTransform':'-moz-transform',
'transform':'transform'
};
View lesswatch.js
#!/usr/bin/env node
var fs = require('fs');
var exec = require('child_process').exec;
/*
* lesswatch usage:
*
* `lesswatch` to watch the current directory
View $.js
// 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){}
};
View $.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 Dec 15, 2015 — forked from brandonb927/gist:4580977
JS lazyloading that is non-blocking, shamefully stolen from http://friendlybit.com/js/lazy-loading-asyncronous-javascript/
View async_load.js
(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) {