Skip to content

Instantly share code, notes, and snippets.

View richardsweeney's full-sized avatar

Richard Sweeney richardsweeney

View GitHub Profile
@richardsweeney
richardsweeney / lsgrep
Created October 24, 2012 06:55
Find and list files/folder via ls |grep
ls |grep .css
@richardsweeney
richardsweeney / drupal-cols-fixed-width.scss
Created November 10, 2012 11:37
A mixin for creating grid columns on the fly (pixel based: non-responsive)
$columns: 16;
$gridWidth: 960px;
@mixin drupalCols($rows: 4, $padding: 0 10px) {
width: ($gridWidth / $columns) * $rows;
float: left;
padding: $padding;
@include box-sizing(border-box);
}
.my-div {
@richardsweeney
richardsweeney / drupal-cols-flexible-width.scss
Created November 10, 2012 11:41
A mixin for creating percentage based grid columns on the fly.
$columns: 12;
$gridWidth: 100%;
@mixin drupalCols($rows: 4, $padding: 0 10px) {
width: ($gridWidth / $columns) * $rows;
float: left;
padding: $padding;
@include box-sizing(border-box);
}
.my-div {
@richardsweeney
richardsweeney / responsive-grid.scss
Created November 10, 2012 12:07
A responsive CSS grid system in SCSS/Compass
@mixin clearfix {
&:after {
content: " ";
display: table;
clear: both;
}
}
$columns: 12;
@while $columns > 0 {
@richardsweeney
richardsweeney / wordpress_menu_filter.php
Last active December 14, 2015 15:28
WordPress menu filter
<?php
/** Show children only of current page */
add_filter( 'wp_nav_menu_objects', 'olab_nav_menu_objects_start_in', 10, 2 );
function olab_nav_menu_objects_start_in( $sorted_menu_items, $args ) {
global $wp_query;
switch ( $args->menu_id ) {
case 'sidebar-menu' : // change this to the ID of the menu you want to target
$current = false;
#!/bin/bash
# Create a folder + download latest WordPress.
# Create a database with the same name + add the whole
# shebang to gitlab.
# For this to work the directory contining the repo has
# to have the same name as the gitlab repo
basedir="/Users/richardsweeney/s/"
MYSQL=`which mysql`
@richardsweeney
richardsweeney / google.maps.js
Last active December 14, 2015 16:29
Google maps JavaScript only API exampte
if ( $( "#map-canvas" ).length ) { // or whatever - only add if the map container exists
var address = $(".company-address").text() // get the address from somewhere
var geocoder = new google.maps.Geocoder()
// geocode the address
geocoder.geocode({ 'address': address }, function( results, status ) {
if ( status == google.maps.GeocoderStatus.OK ) {
var location = results[0].geometry.location
// Encode the coordinates
@richardsweeney
richardsweeney / .gitignore
Last active December 15, 2015 16:58
WordPress .gitignore
.htaccess
wp-config.php
wp-content/uploads/
wp-content/blogs.dir/
wp-content/upgrade/
wp-content/backup-db/
wp-content/advanced-cache.php
wp-content/wp-cache-config.php
sitemap.xml
*.log
@richardsweeney
richardsweeney / replace-germanic.js
Last active December 15, 2015 20:19
Replace foreign letters used in field labels when dynamically creating field names. There's only a few here, these are the ones that are used in scandinavia.
$('#acf_fields tr.field_label input.label').live('blur', function()
{
var label = $(this);
var name = $(this).closest('tr').siblings('tr.field_name').find('input.name');
if(name.val() == '')
{
var val = label.val();
var ex = {
'ä': 'a',
@richardsweeney
richardsweeney / wp-install-script.sh
Last active December 16, 2015 05:09
Install latest WordPress, setup database, get latest ölab starter theme, commit it all to gitlab, setup virtual host, makes you a coffee (ok not the last one)
#!/bin/bash
# Initializes a git repo & adds gitlab repo as origin.
# For this to work the directory contining the repo has
echo "Enter the directory/database directory name:"
read directory
basedir="/Users/richardsweeney/s/"
MYSQL=`which mysql`