Skip to content

Instantly share code, notes, and snippets.

View thierryc's full-sized avatar
🦋
@anotherplanet.io on Bsky

Thierry Charbonnel 🦋 @anotherplanet.io thierryc

🦋
@anotherplanet.io on Bsky
View GitHub Profile
@thierryc
thierryc / gist:5dc31333e2224729f94200e2b33199e0
Created March 30, 2017 07:52 — forked from fwextensions/gist:2052247
Decomposing a 2D transformation matrix to find the skew
/*
This code takes a 2D transformation matrix described as a one-dimensional array
(in column order, top to bottom and left to right) and decomposes it using the dojo
matrix library. This input matrix should produce a 45-deg X skew:
1 1 0
0 1 0
0 0 1
The output of decompose() looks like this:
@thierryc
thierryc / getStyle.js
Created October 27, 2016 15:26 — forked from cms/getStyle.js
Get computed styles
function getStyle(el, styleProp) {
var value, defaultView = el.ownerDocument.defaultView;
// W3C standard way:
if (defaultView && defaultView.getComputedStyle) {
// sanitize property name to css notation (hypen separated words eg. font-Size)
styleProp = styleProp.replace(/([A-Z])/g, "-$1").toLowerCase();
return defaultView.getComputedStyle(el, null).getPropertyValue(styleProp);
} else if (el.currentStyle) { // IE
// sanitize property name to camelCase
styleProp = styleProp.replace(/\-(\w)/g, function(str, letter) {
@thierryc
thierryc / SASS_Color_Contrast.md
Created July 9, 2016 19:16 — forked from voxpelli/SASS_Color_Contrast.md
Pure SASS script for calculating contrast ratios of colors. An adaption of Lea Verou's contrast-ratio javascript.

Pure SASS-adaption of Lea Verou's contrast-ratio javascript. Can be useful when eg. generating colored buttons from a single supplied color as you can then check which out of a couple of text colors would give the best contrast.

This script currently lacks the support for alpha-transparency that Lea supports in her script though.

In addition to the color-contrast adaption there's also some math methods that were needed to be able to calculate the exponent of a number and especially so when the exponent is a decimal number. A 2.4 exponent is used to calculate the luminance of a color and calculating such a thing is not something that SASS supports out of the box and not something I found a good pure-SASS script for calculating and I much prefer pure-SASS over ruby extensions. The math methods might perhaps be unecessary though if you're running Compass or similar as they may provide compatible math methods themselves.

Normal usage: `color: pick_best_color(#f00

@thierryc
thierryc / angular-ap-lateral-slide-menu_howto
Last active August 29, 2015 14:16
angular-ap-lateral-slide-menu
(function(){
"use strict";
var app = angular.module('myApp',['ap.lateralSlideMenu']);
})();
<?php
echo "test";