Skip to content

Instantly share code, notes, and snippets.

@Melindrea
Melindrea / Gruntfile.js
Created October 29, 2013 20:39
PHP tasks for grunt
'use strict';
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'
module.exports = function (grunt) {
// show elapsed time at the end
@Melindrea
Melindrea / pre-commit-grunt
Created September 27, 2013 06:37
List of Git hooks
#!/bin/sh
# http://gmurphey.com/2012/12/22/grunt-pre-commit-hook-for-release-tasks.html
# stash unstaged changes, run release task, stage release updates and
# restore stashed files
# Should now hopefully have correct line endings...
NAME=$(git branch | grep '*' | sed 's/* //')
# don't run on rebase
if [ $NAME != '(no branch)' ]; then
@Melindrea
Melindrea / menus.html
Last active November 30, 2016 15:55
Patterns to use aria roles, both HTML and a sketch for the CSS
<!-- navigational menubar (with drop down submenu, without works as well) -->
<nav aria-label="main" role="navigation"><!-- role explicit for older browsers, using aria-label to differentiate from other navs -->
<ul role="menubar" aria-activedescendant="home-menuitem">
<li role="presentation">
<a href="#" role="menuitem" aria-selected="true" id="home-menuitem">Home</a></li>
<li role="presentation">
<a href="#" role="menuitem" aria-selected="false" id="link-menuitem">Link</a>
</li>
<li role="presentation">
<!-- using button to be triggered on-click -->
/* Checks to make sure that all images have alt attributes, even if they're empty */
@all (content-type = /^text\/html/) {
img {
has-attribute(alt): true;
}
}
@Melindrea
Melindrea / elements.html
Last active December 16, 2015 10:29
HTML5 elements, as a base for testing styles
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<title>Test display of HTML elements</title>
<!-- Originally from: http://www.cs.tut.fi/~jkorpela/www/testel.html -->
</head>
@Melindrea
Melindrea / call.js
Last active December 16, 2015 07:59
jQuery Plugin for making boxes equal heights
// Window.load to avoid FOUC in some browsers
$(window).load( function() {
/* Make boxes same height */
$('.js-equal-height-columns-row').sameHeights();
});
@Melindrea
Melindrea / nav.php
Last active December 15, 2015 19:08
Unorganized (for now) elements of snippets/tools/stuff for WordPress
/**
* Remove the id="" on nav menu items
* Return 'menu-slug' for nav menu classes
* Set 'current-menu' etc to 'active', 'active-parent', 'active-ancestor'
* Based on roots
*/
function pb_nav_menu_css_class($classes, $item) {
$slug = sanitize_title($item->title);
$classes = preg_replace('/current-(menu|page)-(parent|ancestor)/', 'active-$2', $classes);
$classes = preg_replace('/(current([-_](menu|page)[-_])(item|parent|ancestor))/', 'active', $classes);
@Melindrea
Melindrea / git-prompt.sh
Last active December 13, 2015 21:18 — forked from presstube/gist:1299452
Main update from the fork and the awesome post by opinionated programmer is that the default prompt is based on the Ubuntu one, and allows to show Python's virtual environment. Add the snippet to .bash_profile or .bashrc
# Snazzy git prompt
#http://www.opinionatedprogrammer.com/2011/01/colorful-bash-prompt-reflecting-git-status/
function _git_prompt() {
local git_status="`git status -unormal 2>&1`"
if ! [[ "$git_status" =~ Not\ a\ git\ repo ]]; then
if [[ "$git_status" =~ nothing\ to\ commit ]]; then
local ansi=42
elif [[ "$git_status" =~ nothing\ added\ to\ commit\ but\ untracked\ files\ present ]]; then
local ansi=43