Skip to content

Instantly share code, notes, and snippets.

View atelierbram's full-sized avatar

Bram de Haan atelierbram

View GitHub Profile
@atelierbram
atelierbram / Gruntfile.js
Last active August 27, 2015 22:11
Add Compass to your Grunt task
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
compass: {
dist: {
options: {
sassDir: 'sass',
cssDir: 'css'
@atelierbram
atelierbram / gist-shortcode-embed.php
Created February 24, 2014 19:08
Using some server-side magic (PHP in this case) and regular expressions, we can utilize GitHub's Gist API to display external code
<?php
/*
http://davidwalsh.name/gist-shortcode
Embed format: <script src="https://gist.github.com/4575399.js"></script>
*/
function embedGists($string) {
$regex1 = '/https:\/\/gist.github.com\/(\d+)/';
$regex2 = '/\[gist (\d+)\]/';
$replace = '<script src="https://gist.github.com/${1}.js"></script>';
// http://www.creativebloq.com/html5/create-fluid-width-videos-8112993
$(function() {
var $allVideos = $("iframe[src^='http://player.vimeo.com'], iframe[src^='http://www.youtube.com'], object, embed"),
$fluidEl = $("figure");
$allVideos.each(function() {
$(this)

Rewrite a domain alias to subfolder of target site:

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^subdomain.domain.com [NC]
RewriteCond %{REQUEST_URI} !^/subdomain/.*
RewriteRule ^(.*) /subdomain/$1 [L]

Disable a testing URL/Alias by rewriting to target domain:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
# 480 weeks
<filesMatch "\.(ico|jpg|jpeg|png|gif|js|css)$">
Header set Cache-Control "max-age=290304000, public"
</filesMatch>
# 2 HOURS
<html>
<head>
<title>Select styles with CSS only</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
/* Some basic page styles */
body {
background-color: #fff;
font-family: helvetica, sans-serif;
margin: 4% 10%
(function($) {
$.organicTabs = function(el, options) {
var base = this;
base.$el = $(el);
base.$nav = base.$el.find(".nav");
base.init = function() {
@atelierbram
atelierbram / DrodownHeight-v1.js
Last active August 29, 2015 14:06
Generated by SassMeister.com.
// here we set a class "itemcount-[number]" in order to calculate the height in Sass for the height (= padding-bottom) of the submenu
$(function() {
// "use strict";
var nmbrItemsHome = ($("#tt-home li").length);
var nmbrItemsBlog = ($("#tt-blog li").length);
var nmbrItemsBooks = ($("#tt-books li").length);
var nmbrItemsGoodies = ($("#tt-goodies li").length);
var nmbrItemsMedia = ($("#tt-media li").length);
var nmbrItemsNews = ($("#tt-news li").length);
var nmbrItemsContact = ($("#tt-contact li").length);
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Simple AJAX Demo</title>
<!-- link to jQuery -->
<!-- You might want to
download local copy
of this file, otherwise
you'll need internet