Skip to content

Instantly share code, notes, and snippets.

View n8kowald's full-sized avatar

Nathan n8kowald

  • Australia
  • 07:55 (UTC +09:30)
View GitHub Profile
@n8kowald
n8kowald / gist:4997158
Created February 20, 2013 17:10
.htaccess - Improve performance by copying and pasting this into your .htaccess (or better yet your VirtualHost config)
# Compress text, html, javascript, css, xml:
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
@n8kowald
n8kowald / functions.php
Last active February 5, 2019 16:38
Wordpress snippets
<?php
// --- Create a shortcode
// @Usage: [shortcode_name count="1"]
function theme_shortcode_add_name($args) {
$html = '';
$count = !empty($args['count']) ? $args['count'] : 5;
return $html;
}
add_shortcode( 'shortcode_name', 'theme_shortcode_add_name' );
@n8kowald
n8kowald / functions.php
Last active August 10, 2018 01:54
"Email Subscribers & Newsletters" WordPress Plugin - Add ability to subscribe/unsubscribe from backend
<?php
/* Email Subscribers & Newsletters - by Icegram (https://wordpress.org/plugins/email-subscribers)
These functions allow you to subscribe/unsubscribe a user to an email group without using a signup form. */
/**
* Subscribe a user to a given newsletter group
*
* @param $user_id
* @param $group
* @throws Exception
@n8kowald
n8kowald / wordpress-queries.sql
Last active November 2, 2017 01:18
Wordpress SQL queries
-- Delete all of posts of custom post type
DELETE FROM `wp_posts` WHERE `post_type` = 'post-type';
-- Delete all unpublished of custom post type
DELETE FROM `wp_posts` WHERE `post_status` = 'draft' and `post_type` = 'post-type';
@n8kowald
n8kowald / helpers.sh
Last active August 6, 2017 10:58
Bash shell script helpers
# Choose from an array of strings
echo "Please choose the environment"
local envs=('staging' 'pre-live' 'live')
select env in "${envs[@]}"
do
case $env in
"staging") break;;
"pre-live") break;;
"live") break;;
"Quit") break;;

Keybase proof

I hereby claim:

  • I am n8kowald on github.
  • I am n8kowald (https://keybase.io/n8kowald) on keybase.
  • I have a public key ASBo4VQ3KwN5Xys75sMXV2ez3KFlkEXdUCT7IjlzZMxYbAo

To claim this, I am signing this object:

@n8kowald
n8kowald / gist:2634304
Last active January 31, 2017 15:23 — forked from maciakl/gist:1584387
Git Workflow
# GIT WORKFLOW
# (c) Luke Maciak
# Initialize:
git init
# Check Out:
git clone username@host:/path/to/repository
# Add Origin:
@n8kowald
n8kowald / bash-cheatsheet.sh
Created August 28, 2016 19:40 — forked from LeCoupa/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
@n8kowald
n8kowald / date-widget-example.coffee
Created May 26, 2016 11:14
Übersicht date widget example
# This is a simple example Widget, written in CoffeeScript, to get you started
# with Übersicht. For the full documentation please visit:
#
# https://github.com/felixhageloh/uebersicht
#
# You can modify this widget as you see fit, or simply delete this file to
# remove it.
# this is the shell command that gets executed every time this widget refreshes
command: "echo $(whoami) && TZ=Australia/Adelaide date && TZ=Australia/Melbourne date"
@n8kowald
n8kowald / JavaScript Names and Rules
Last active December 11, 2015 05:59
Notes on the name of JavaScript syntax and also rules.
/* RULES */
- Variable and function declarations are hoisted (names are moved to the top of their current scope) by the JavaScript interpreter.
- Variable initialisations are not moved.
- Only functions create new scope
- Function Declarations are officially prohibited within non-function blocks (such as if)
var a; // variable declaration
a = 1; // variable initialisation