Skip to content

Instantly share code, notes, and snippets.

View LoicGoyet's full-sized avatar

Loïc Goyet LoicGoyet

View GitHub Profile
@LoicGoyet
LoicGoyet / get-hypotenuse.scss
Created March 10, 2016 13:56
The get-hypotenuse() is a sass function to calc the hypotenuse width on a triangle rectangle
// http://www.antimath.info/css/sass-sqrt-function/
@function sqrt($r) {
$x0: 1;
$x1: $x0;
@for $i from 1 through 10 {
$x1: $x0 - ($x0 * $x0 - abs($r)) / (2 * $x0);
$x0: $x1;
}
@LoicGoyet
LoicGoyet / get-diff-to-align.scss
Last active March 8, 2016 09:31
A sass function that returns a value to apply to a margin in order to vertically or horizontally align two elements.
/// Contexts
/// @author Loïc Goyet
/// @param {Unit} $element1
/// @param {Unit} $element2
/// @param {Bool} $invert
/// @warn the params $big-element & $small-element must share the same type of
/// unit
@function get-diff-to-align($element1, $element2, $invert: true) {
$big-element: if($element1 > $element2, $element1, $element2);
$small-element: if($element1 > $element2, $element2, $element1);
@LoicGoyet
LoicGoyet / gulpfile.js
Last active January 14, 2016 16:57
Basic usage of gulp-inject plugin
var gulp = require('gulp');
var inject = require('gulp-inject');
gulp.task('inject', function () {
var target = gulp.src('index.html');
// It's not necessary to read the files (will speed up things), we're only after their paths:
var sources = gulp.src(['style.css', 'script.js'], {read: false});
return target.pipe(inject(sources))
.pipe(gulp.dest('result.html'));