Skip to content

Instantly share code, notes, and snippets.

@cahnory
cahnory / package.json
Last active August 29, 2015 14:07
package.json boilerplate
{
"name": "{{name}}",
"version": "0.1.0",
"description": "",
"keywords": [],
"author": {
"name": "François Germain",
"email": "cahnory@gmail.com"
},
@cahnory
cahnory / index.html
Created September 15, 2014 07:55
Empty HTML5 doc
<!DOCTYPE html>
<html lang="fr-FR" dir="ltr">
<head>
<title>Untitled HTML5 document</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!--[if lt IE 9]><script src="assets/libs/html5shiv/html5shiv-prev3.7.2.js"></script><![endif]-->
<link rel="stylesheet" href="assets/main.css" />
@cahnory
cahnory / SassMeister-input.scss
Created August 5, 2014 12:36
Generated by SassMeister.com.
// ----
// Sass (v3.3.14)
// Compass (v1.0.0.rc.1)
// ----
// attribute used instead of `class`
$class-attr: 'data-g';
// return attribute selector
@function g($class) {
@cahnory
cahnory / SassMeister-input.scss
Created March 7, 2014 13:21
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.5)
// Compass (v1.0.0.alpha.18)
// ----
// https://docs.google.com/spreadsheet/ccc?key=0AgFzwMiAdIOfdDdkMVhPazVjMnI4eDdtM19VUzhOSVE&usp=sharing
@function nth-side($value, $n) {
@while length($value) < $n {
$value: append($value, nth($value, floor((length($value) + 1)/2)));
}
@cahnory
cahnory / absolutize.php
Last active December 30, 2015 18:59
HTML absolutizer
<?php
function absolutize($html, $base) {
// href, src, background attributes
$html = preg_replace('#(<[^>]+(href|src|background)=(?:3D)?")(?![a-z]+:)/?([^"]+)"#is', '$1'.$base.'$3"', $html);
// style attributes url(), src()
$html = preg_replace('#(<[^>]+style=(?:3D)?"[^"]*(url|src)\([\s\']*)(?![a-z]+:)/?([^)]+)\)#is', '$1'.$base.'$3)', $html);
// style tag
preg_match_all('#<style[^>]*>([^<]+)#is', $html, $styles);
@cahnory
cahnory / _split.scss
Created December 4, 2013 10:41
Split rule by selectors
@mixin split($selectors...) {
@each $selector in $selectors {
#{$selector} {
@content;
}
}
}
@cahnory
cahnory / _script.scss
Created November 6, 2013 11:05
PlastiCSS/helper/_script.scss Manage javascript specific styles. Output javascript only, no javascript only (separate sheets) or both with corresponding classes (single sheet).
// TODO: scope vars
@mixin script() {
@if $plasticss__helper__script--use_class {
#{$plasticss__helper__script--class} {
@content;
}
}
@else if $plasticss__helper__script {
@content;
}
@cahnory
cahnory / demo.scss
Created August 6, 2013 15:53
Sort of sprintf for Sass
@for $i from 1 through 12 {
@debug format(
('.on-', 2, '-columns-i-am-spanning-', 1),
(12, $i)
);
}
/*
DEBUG: .on-1-columns-i-am-spanning-12
DEBUG: .on-2-columns-i-am-spanning-12
@cahnory
cahnory / _apply.scss
Created July 24, 2013 13:53
Apply donne la possibilité d'utiliser @extend ou @include facilement. Il permet de définir un comportement par défaut au sein d'une mixin et d'en forcer un autre au besoin, facilement.
@mixin apply($placeholder: false) {
@if $placeholder {
@extend #{$placeholder};
}
@else {
@content;
}
}
@cahnory
cahnory / _pin.scss
Last active December 20, 2015 04:28
Next PlastiCSS pin mixin
@mixin pin($top: false, $right: false, $bottom: false, $left: false, $position: absolute, $all: false, $x: false, $y: false) {
// All the same value
@if relevant($all) {
bottom: $all;
left: $all;
right: $all;
top: $all;
}
@else {
// Left == right