Skip to content

Instantly share code, notes, and snippets.

@tsi
tsi / _triangle.scss
Last active November 27, 2016 14:16
Sass triangle
@mixin triangle(
$dir: top,
$pos: 50%,
$color1: #fff,
$color2: darken($color1, 30%),
$size1: 6px,
$size2: $size1
) {
$opos: map-get(( top: bottom, right: left, bottom: top, left: right ), $dir);
$transparent: if($dir == left or $dir == right, (top, bottom), (left, right));
@tsi
tsi / _pie.scss
Last active December 10, 2015 20:08
Extending the standard compass CSS3 mixins with CSS3PIE
///////////////////////////////////////////////////////////////////
// Extending the standard compass CSS3 mixins with CSS3PIE
///////////////////////////////////////////////////////////////////
$pie: url('/RELATIVE/PATH/TO/PIE.htc');
$pie-approach: relative;
@import "compass/css3";
@mixin pie-border-radius($radius, $position: $pie-approach) {
@tsi
tsi / css.css
Last active December 11, 2015 19:38
Comparing Sass vs CSS layout systems - using CSS
/* With a CSS grid system */
/* Using a Css system, you'll have in your mark-up something like that
*
* <div class="col span_1_of_2"></div>
* <div class="col span_1_of_2"></div>
*
* Then, for a simple rwd task, you'll have this in your CSS:
* (taken from http://www.responsivegridsystem.com/)
*/
@tsi
tsi / scss.scss
Created January 27, 2013 20:36
Comparing Sass vs CSS layout systems - using SCSS
// With Salsa
//
// Using a Sass based system, my mark-up can look something like this:
//
// <article></article>
// <aside><aside>
//
// and in my scss file, I'll do
@import "settings";
javascript:(function(){
function encodeString(string) {
return encodeURIComponent(string
.replace(/\\/g,"\\\\")
.replace(/\"/g, '\\"')
.replace(/\n\r?/g, '\\n')
.replace(/%/g, 'U0025')
.replace(/</g, '\\<')
.replace(/>/g, '\\>')
.replace(/script/ig, 'scr\"\+\"ipt')
@tsi
tsi / microTplEngine.js
Last active September 29, 2018 07:37
My micro jQuery templating engine
(function($) {
// My micro jQuery templating engine
// Include this script before your closing </body> tag.
// Usage:
//
// <section data-html="content"></section>
//
// This will load <html/content.html> into <section>
@tsi
tsi / _size.scss
Created August 22, 2013 06:55
Small and useful mixin to easily set width and height to your elements. It can be used with any kind of unit or even with an image name so it gets the dimensions from the image. See https://coderwall.com/p/2k3rgw for the full post.
@mixin size($x, $y: $x) {
@if type_of($x) == string {
width: image-width($x);
} @else {
width: $x;
}
@if type_of($y) == string {
height: image-height($y);
} @else {
height: $y;
@tsi
tsi / inlineDisqussions4drupal.php
Created September 17, 2013 07:43
Drupal implementation of inlineDisqussions
<?php
/**
* Put this in your template.php
* Change YOURTHEME to your theme name and YOUR_DISQUS_SHORTNAME to yours.
* Implements template_preprocess_page().
*/
function YOURTHEME_preprocess_page(&$variables, $hook) {
// inlineDisqussions
@tsi
tsi / template.php
Created October 20, 2013 16:01
Drupal Image API - Skip GIFs
function THEME_image_style($variables) {
// Skip GIFs.
$ext = pathinfo($variables['path'], PATHINFO_EXTENSION);
if ($ext == 'gif') {
return theme('image', $variables);
}
// Determine the dimensions of the styled image.
$dimensions = array(
@tsi
tsi / tooltip.scss
Last active August 27, 2017 12:25
Tooltip mixin to create a bordered and shaded tooltip.
///////////////////////////////////////////////////
// SASS & Compass tooltip mixin
///////////////////////////////////////////////////
@mixin tooltip(
$dir: top,
$pos: 50%,
$color1: #fff,
$color2: darken($color1, 30%),
$size1: 6px,