Skip to content

Instantly share code, notes, and snippets.

View tillsanders's full-sized avatar
💪
Working on something better.

Till Sanders tillsanders

💪
Working on something better.
View GitHub Profile
@tillsanders
tillsanders / resize-images-sips
Last active August 29, 2015 14:07
Quickly replacing (!) images with proportionally resized versions on OS X Terminal
sips -Z 640 *.jpg
@tillsanders
tillsanders / main.js
Created October 14, 2014 15:11
Obfuscating Mailtos in Laravel 4
$(document).ready(function() {
// Hidden Mailtos
$('span.inyourfacespambot').click(function() {
var str = $(this).text();
var re = /^(.+?@).*@(.*)$/gmi;
var m;
while ((m = re.exec(str)) !== null) {
if (m.index === re.lastIndex) {
re.lastIndex++;
}
@tillsanders
tillsanders / generate-mobile-first-sass-stylesheets-for-ie.markdown
Last active August 29, 2015 14:11
Generate mobile-first SASS-Stylesheets for IE

Generate mobile-first SASS-Stylesheets for IE

I copied this code from chriseppstein, because it is great :)

Okay, here we go: Put this somewhere in your SASS-files. E.g. _vars.scss oder _helpers.scss, etc.

$media-queries: true !default;
$media-query-free-breakpoint: 1300px;
@mixin respond-to($min-width, $max-width: false) {
@tillsanders
tillsanders / jquery.adjustat.js
Last active August 29, 2015 14:13
Execute javascript layout adjustments based on breakpoints only once
(function ($) {
$.fn.adjustAt = function(options) {
var elements = $(this);
// Default settings merged with received options
var settings = $.extend({
width: 0,
above: function(element) {},
below: function(element) {},
aboveRepeat: function(element) {},
belowRepeat: function(element) {}
@tillsanders
tillsanders / center-position.jquery.js
Created January 12, 2015 08:22
Center position with jQuery
$.fn.centerPosition = function() {
"use strict";
var $targets = $(this);
if (!$targets.length) {
$targets = $('.centered:visible');
}
$targets.each(function() {
@tillsanders
tillsanders / slideshow-notes.markdown
Last active August 29, 2015 14:13
Very simple slideshow plugin for jquery

Notes

  • div.controls is vital for autoplay functionality
@tillsanders
tillsanders / main.js
Created March 29, 2015 21:57
Update active nav item while scrolling
$(window).scroll(function() {
var current = $('main section').map(function(){
if($(this).offset().top < $(window).scrollTop() + $(window).height() / 2) {
return $(this);
}
});
current = current.last().get(0);
$('nav.main a').removeClass('active');
$('a[href=#' + current.attr('id') + ']').addClass('active');
});
@tillsanders
tillsanders / max-height.js
Created June 11, 2015 12:38
Get max height of a jquery collection
// Found at Stackoverflow: http://stackoverflow.com/questions/6060992/element-with-the-max-height-from-a-set-of-elements
// Credits to http://stackoverflow.com/users/139010/matt-ball
var maxHeight = Math.max.apply(null, $("li").map(function ()
{
return $(this).height();
}).get());
@tillsanders
tillsanders / regex-stuff.markdown
Last active August 29, 2015 14:23
Useful regex stuff

Useful regex stuff I wrote

Make links clickable:

$re = "/((?:http:\/\/|www\.).*)(?:\s|$)/U";
$html = preg_replace($re, '<a href="$1" target="_blank">$1</a> ', $plain);

@tillsanders
tillsanders / checklist.markdown
Last active September 19, 2015 06:39
You-will-be-in-mortal-danger-if-you-dont-follow-this-checklist-checklist

The You-will-be-in-mortal-danger-if-you-dont-follow-this-checklist-checklist

Common pitfalls

  • Caching and temporary directories accessible (permissions!) by webserver
  • Webfonts available for production domain

Security

  • Are email adresses (a little) protected?
  • Do you need a captcha somewhere?
  • Debug disabled