Skip to content

Instantly share code, notes, and snippets.

@alkrauss48
alkrauss48 / gulpfile.js
Last active February 17, 2020 12:45
Base gulpfile config for babel, browserify, and uglify - with sourcemaps and livereload
var gulp = require('gulp');
var browserify = require('browserify');
var babelify = require('babelify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var livereload = require('gulp-livereload');
@alkrauss48
alkrauss48 / google_calendar_color_map.php
Last active August 29, 2015 14:23
Google Calendar Color Map
<?php
// For some reason, when you embed a google calendar, the colors they
// display as background colors for the calendars don't fully match the colors
// that are in the embed code. This is a map from the hexadecimal color codes that
// are in the embed code to what they really render as in the embed
// This will help if you're building a custom legend, for example
$color_map = array(
@alkrauss48
alkrauss48 / change_multisite_url.sql
Last active August 29, 2015 14:18
SQL Script to handle changing the Wordpress MySQL DB when you need to change your Multisite primary domain
-- Run as:
-- mysql -uusername -p < change_multisite_url.sql
-- Set the db name, old site domain, and new site domain
use 'db_name';
SET @old_site = 'old_domain.com';
SET @site = 'new_domain.com';
@alkrauss48
alkrauss48 / Gruntfile.js
Created March 25, 2015 16:35
Base Browserify Configuration with Grunt Watching
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
browserify : {
app : {
files : {
'dist/app.js' : ['scripts/app.js']
}
@alkrauss48
alkrauss48 / wp_breadcrumbs.php
Created March 14, 2015 21:01
Easy breadcrumbs in wordpress
<aside class="breadcrumbs">
<?php the_breadcrumb(); ?>
</aside>
<?php
function the_breadcrumb() {
$anc = get_post_ancestors( $post->ID );
for($i = count($anc) - 1; $i >= 0; $i--){
echo "<a href=" . get_permalink($anc[$i]) . ">" . get_the_title($anc[$i]) . "</a>";
@alkrauss48
alkrauss48 / functions.php
Created March 2, 2015 17:14
Remove Comments in Wordpress - Completely
<?php
include 'remove-comments.php'
@alkrauss48
alkrauss48 / jquery.animations.js
Last active November 4, 2016 15:22
jQuery Scrolling Animations
// Shift the page to a div. Replace 'target' with a jquery selector query.
$('html,body').animate({
scrollTop: $(target).offset().top
}, 1000);
// Shift a div to your current browser window location - Replace 'target' with a jquery selector query.
$(target).animate({
top: $(document).scrollTop()
}, 800);
@alkrauss48
alkrauss48 / check_ie.js
Created January 14, 2015 20:46
Get Internet Explorer Version
getInternetExplorerVersion: function(){
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer')
{
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
@alkrauss48
alkrauss48 / post_to_google_sheet.gs
Created December 11, 2014 23:05
Use this if you want to read and post to a Google sheet using javascript
// 1. Enter sheet name where data is to be written below
var SHEET_NAME = "Sheet Name";
// 2. Run > setup
//
// 3. Publish > Deploy as web app
// - enter Project Version name and click 'Save New Version'
// - set security level and enable service (most likely execute as 'me' and access 'anyone, even anonymously)
//
// 4. Copy the 'Current web app URL' and post this in your form/script action
@alkrauss48
alkrauss48 / wordpress_url_change.sql
Last active September 4, 2016 03:33
Change Wordpress Base URL via SQL
# Changing the main site url and home url locations for Wordpress via SQL
# Useful when migrating database across environments
update wp_options set option_value = 'new_url' where option_name IN ('siteurl', 'home');