Skip to content

Instantly share code, notes, and snippets.

View 9ete's full-sized avatar
😃

Pete Lower 9ete

😃
View GitHub Profile
@9ete
9ete / create-mysql-usr-db.sh
Last active August 29, 2015 14:06
Create MySQL database via the command line. Pass it a short db and user name, then enter db pass.
#!/bin/bash
echo "Enter Short Name for Database:"
read DATABASENAME
echo "Enter Short Name for User:"
read USERNAME
DATE=$(date +%s)
PASSWORD1=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 4 | head -n 1)
@9ete
9ete / passgen.sh
Last active August 29, 2015 14:06
Command line password generator. Setup an alias and you're good to go.
#!/bin/bash
echo " "
echo "Password Length(#1-100):"
read PLENGTH
#return date in number format
DATE=$(date +%s)
#create password string of 4 letters
@9ete
9ete / WordPress Return Pretty Permalink Slug
Created September 15, 2014 22:45
WordPress Return Pretty Permalink Slug
@9ete
9ete / cust-post-type-func.php
Last active August 29, 2015 14:07
WordPress Custom Post Type Generic Function, w/ pass in vars
/**
* Custom Post Types
*
**/
function lm_custom_post_type_creator($post_type_name, $description, $public, $menu_position, $supports, $has_archive, $irreg_plural) {
if ($irreg_plural) {$plural = 's';} else {$plural = '';}
$labels = array(
'name' => _x( $post_type_name, 'post type general name' ),
'singular_name' => _x( $post_type_name, 'post type singular name' ),
@9ete
9ete / admin-bar-bottom.css
Created October 16, 2014 21:19
CSS move WordPress admin bar to bottom on front end
body.admin-bar {
margin-top: -28px;
padding-bottom: 28px;
}
#wpadminbar {
top: auto !important;
bottom: 0;
}
#wpadminbar .quicklinks>ul>li {
position:relative;
@9ete
9ete / gist:13a4e944581ddd2b1603
Created April 8, 2015 16:17
Phone Number Shortcode
// Add [phonenumber] shortcode
function phonenumber_shortcode( $atts ){
//retrieve phone number from database
$lm_array = get_option('lowermedia_phone_number');
//check if user is on mobile if so make the number a link
if (wp_is_mobile())
{
return '<a href="tel:+'.$lm_array["id_number"].'">'.format_phonenumber($lm_array["id_number"]).'</a>';
} else {
@9ete
9ete / gist:f337a87b7e704b58dfb0
Last active August 29, 2015 14:20
Print directories in current directory with links
<?php
$dirs = array_filter(glob('*'), 'is_dir');
foreach ($dirs as $dir) {
if ($dir !== 'scp_dump' || $dir !== 'scp_dump') {
echo "<a href='http://".$dir.".devdomain.com/'>".$dir.'</a><br/>';
}
}
?>
@9ete
9ete / gist:73167bdb3c4680a9d2b8
Created May 7, 2015 16:05
Output all directories w/in current directory
<?php
$dirs = array_filter(glob('*'), 'is_dir');
foreach ($dirs as $dir) {
echo $dir;
}
?>
@9ete
9ete / gist:4f06b2786fc8c93bd61c
Created May 8, 2015 22:12
Create database quickly
#!/bin/bash
BTICK='`'
EXPECTED_ARGS=3
E_BADARGS=65
MYSQL=`which mysql`
Q1="CREATE DATABASE IF NOT EXISTS ${BTICK}$1${BTICK};"
Q2="GRANT ALL ON ${BTICK}$1${BTICK}.* TO '$2'@'localhost' IDENTIFIED BY '$3';"
Q3="FLUSH PRIVILEGES;"
@9ete
9ete / wp-checkbox-setting.php
Created July 22, 2015 19:00
WordPress Checkbox Admin Setting Functions
<?php
// register setting
function ma_theme_init() {
register_setting( 'ma-settings-group', 'ma_show_setting' );
add_settings_section( 'ma_setting_section', 'MA Settings:', 'ma_setting_section_callback', 'wpsettings' );
add_settings_field( 'ma_setting_checkbox', 'CheckBox', 'ma_setting_checkbox_callback', 'wpsettings', $section = 'ma_setting_section');
}
add_action('admin_init', 'ma_theme_init');