Skip to content

Instantly share code, notes, and snippets.

@salcode
salcode / .gitignore
Last active July 7, 2026 20:36
.gitignore file for a general web project - Bare Minimum Git
# -----------------------------------------------------------------
# .gitignore
# Bare Minimum Git
# https://salferrarello.com/starter-gitignore-file/
# ver 20221125
#
# From the root of your project run
# curl -O https://gist.githubusercontent.com/salcode/10017553/raw/.gitignore
# to download this file
#
@salcode
salcode / .gitignore
Last active September 27, 2025 02:50
See https://salferrarello.com/wordpress-gitignore/ for the latest version of my WordPress .gitignore file
# -----------------------------------------------------------------
# .gitignore for WordPress
# Bare Minimum Git
# http://ironco.de/bare-minimum-git/
# ver 20150227
#
# This file is tailored for a WordPress project
# using the default directory structure
#
# This file specifies intentionally untracked files to ignore
@salcode
salcode / wp-config-local.php
Created February 25, 2014 11:28
wp-config-local.php file for a WordPress project managed with Siteground git deployment (important to .gitignore this file)
<?php
define('DB_NAME', 'local_db_name');
define('DB_USER', 'local_db_user');
define('DB_PASSWORD', 'local_db_pwd');
define('DB_HOST', 'localhost');
define('WP_DEBUG', true);
@salcode
salcode / wp-config-snippet.php
Created February 25, 2014 11:21
wp-config.php modifications for a WordPress project managed with Siteground git deployment
// REPLACE EXISTING DB define lines with this code
// Technique taken from
// http://markjaquith.wordpress.com/2011/06/24/wordpress-local-dev-tips/
if ( file_exists( dirname( __FILE__ ) . '/wp-config-local.php' ) ) {
include( dirname( __FILE__ ) . '/wp-config-local.php' );
define( 'WP_LOCAL_DEV', true ); // We'll talk about this later
} else {
define('DB_NAME', 'production_db_name');
define('DB_USER', 'production_db_user');
@salcode
salcode / .gitignore
Last active February 4, 2018 21:27
.gitignore for a WordPress project managed with Siteground git deployment
# ignore all files starting with .
\.*
# include .gitignore (i.e. do NOT ignore)
!.gitignore
# ignore all files that start with ~
~*
# ignore node/grunt dependencies
@salcode
salcode / dump-mamp-mysql-dbs.sh
Created February 21, 2014 20:30
Shell Script to dump all MAMP DBs into separate files
# based on http://www.commandlinefu.com/commands/view/2916/backup-all-mysql-databases-to-individual-files
# but modified for the MAMP path and to include default root/root as username and password
for I in $(/Applications/MAMP/Library/bin/mysql -u root -proot -e 'show databases' -s --skip-column-names); do /Applications/MAMP/Library/bin/mysqldump -u root -proot $I | gzip > "$I.sql.gz"; done
@salcode
salcode / custom-tax-example.php
Last active January 4, 2016 05:59
Custom Tax for testing Custom Permalinks plugin for bug report.
<?php
// Register Custom Taxonomy
function custom_taxonomy() {
$labels = array(
'name' => _x( 'Taxonomies', 'Taxonomy General Name', 'text_domain' ),
'singular_name' => _x( 'Taxonomy', 'Taxonomy Singular Name', 'text_domain' ),
'menu_name' => __( 'Taxonomy', 'text_domain' ),
'all_items' => __( 'All Items', 'text_domain' ),
'parent_item' => __( 'Parent Item', 'text_domain' ),
@salcode
salcode / youtube-oembed-html5-param.php
Created January 22, 2014 21:36
Corrective code for WordPress YouTube oEmbed on a webpage that has CSS transform translate.
<?php
// add parameter html5=1 to oembed YouTube requests as per
// http://stackoverflow.com/questions/17747443/css-transform-translate-breaking-youtube-embedded-video
// using modified version of code on http://www.alittleofboth.com/2013/06/modifying-youtube-video-display-in-wordpress/
add_filter( 'oembed_result', 'youtube_oembed_html5_parameter', 10, 3);
function youtube_oembed_html5_parameter($data, $url, $args = array()) {
// add &html5=1 parameter
$data = preg_replace('/(youtube\.com.*)(\?feature=oembed)(.*)/', '$1?' . apply_filters("hyrv_extra_querystring_parameters", "feature=oembed&amp;html5=1&amp;") . 'rel=0$3', $data);
return $data;
}
@salcode
salcode / functions-snippet-sticky-posts-only.php
Last active January 2, 2016 12:19
Code to add to your functions.php to only display Sticky posts on your main blog page
<?php
// add the following code to your functions.php file
add_action( 'pre_get_posts', 'fe_pre_get_posts_sticky_only' );
function fe_pre_get_posts_sticky_only( $query ) {
if (
$query->is_main_query()
&& $query->is_home()
) {
@salcode
salcode / touch-device-detect.js
Created November 20, 2013 21:06
Touch Device Detection
// requires Modernizr be loaded http://modernizr.com/download/
// with Misc. => Touch Events support
function isTouchDevice() {
return (
// detects touch events (not present on Windows Mobile)
Modernizr.touch
||
// detects Windows Mobile touch support
navigator.msMaxTouchPoints