Skip to content

Instantly share code, notes, and snippets.

@dannyconnolly
dannyconnolly / htaccess rules for better page speed results
Last active August 29, 2015 13:56
htaccess rules for better page speed results
FileETag MTime Size
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
@mixin box-shadow($top, $left, $blur, $color, $inset: false) {
@if $inset {
-webkit-box-shadow:inset $top $left $blur $color;
-moz-box-shadow:inset $top $left $blur $color;
box-shadow:inset $top $left $blur $color;
} @else {
-webkit-box-shadow: $top $left $blur $color;
-moz-box-shadow: $top $left $blur $color;
box-shadow: $top $left $blur $color;
}
@dannyconnolly
dannyconnolly / Sass Mixins
Created February 27, 2014 23:32
Sass Mixins
@mixin breakpoint($point) {
@if $point == large {
@media (min-width: 64.375em) { @content; }
}
@else if $point == medium {
@media (min-width: 50em) { @content; }
}
@else if $point == small {
@media (min-width: 37.5em) { @content; }
}
@dannyconnolly
dannyconnolly / Check if is child page, parent page or ancestor page
Created March 2, 2014 13:56
Check if is child page, parent page or ancestor page
/**
* Check if is child page, parent page or ancestor page
*/
function is_in_heirarchy() {
global $wp_query;
if (empty($wp_query->post->post_parent)) {
$parent = $wp_query->post->ID;
} else {
$parent = array_reverse(get_post_ancestors($post->ID));
$parent = $parent[0];
@dannyconnolly
dannyconnolly / Only load contact form 7 script when needed
Last active August 29, 2015 13:57
Only load contact form 7 scripts when needed in wordpress
/**
* Only load contact form 7 script when needed
*/
function cf7_dequeue_scripts() {
$load_scripts = false;
if( is_singular() ) {
$post = get_post();
@dannyconnolly
dannyconnolly / Detecting touch events with js
Created March 29, 2014 08:01
Detecting touch events with js
(function(window){
// check for touch
if (Modernizr.touch) {
// run the forEach on each figure element
[].slice.call(document.querySelectorAll("figure")).forEach(function(el,i){
// check if the user moves a finger
var fingerMove = false;
@dannyconnolly
dannyconnolly / Check if page is parent, child in wordpress
Created April 30, 2014 15:00
Check if page is parent, child in wordpress
function is_tree($pid) {
// $pid = The ID of the page we're looking for pages underneath
global $post;
// load details about this page
if(is_page()&&($post->post_parent==$pid||is_page($pid)))
return true; // we're at the page or at a sub page
else
return false; // we're elsewhere
};
@dannyconnolly
dannyconnolly / Create an admin user in wordpress with SQL
Created June 12, 2014 13:21
Create an admin user in wordpress with SQL
INSERT INTO `databasename`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('ID', 'USERNAME', MD5('PASSWORD'), 'USERNICENAME', 'USEREMAIL', '', '0000-00-00 00:00:00', '', '0', 'DISPLAYNAME');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, 'ID', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, 'ID', 'wp_user_level', '10');
@dannyconnolly
dannyconnolly / SassMeister-input.sass
Created June 14, 2014 00:13
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.2)
// Compass (v1.0.0.alpha.17)
// ----
// Add vendor prefixes to keyframes
@mixin keyframe ($animation-name)
@-webkit-keyframes #{$animation-name}
@content
@-moz-keyframes #{$animation-name}
@dannyconnolly
dannyconnolly / Smooth Scroll On Anchor Links
Created June 16, 2014 23:06
Smooth Scroll On Anchor Links