Skip to content

Instantly share code, notes, and snippets.

@tsi
tsi / lipsum.js
Last active July 4, 2022 09:19
Lorem ipsum generator bookmarklet
javascript: (function () {
function createLipsum() {
var p = document.createElement("textarea");
p.appendChild(
document.createTextNode(
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet."
)
);
p.setAttribute(
"style",
@tsi
tsi / imgProxy.js
Last active August 29, 2015 13:56
This script checks for images load errors and try to load the image from a fallback provided server name.
/**
* This script checks for image load errors.
* It will try to load the image from a fallback provided server name.
*
* Usage:
*
* - Include it:
* <script src="/js/imgProxy.js"></script>
*
* - Call it from your script (or un-comment the call below):
@tsi
tsi / show-tags
Created February 5, 2014 09:24
Pretty print Git tags by date
git log --tags --simplify-by-decoration --pretty='format:%ai %d'
@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,
@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 / 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 / _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 / 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>
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 / 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";