Skip to content

Instantly share code, notes, and snippets.

@nateflink
nateflink / gist:5199461
Created March 19, 2013 19:45
Why use a Wordpress theme when you can do all the work yourself from scratch? A Bash script to create empty files for all the reserved files for a standard theme, with a comment about what that file does.
echo -e "/*\nTheme Name: Custom Theme\nTheme URI: http://codex.wordpress.org/Theme_Development\nDescription: This is a custom theme\nAuthor: Nate Flink\nAuthor URI: http://nateflink.com/\nVersion: 1.0\nTags: custom, theme, awesome\n\nLicense:\nLicense URI:\n\nGeneral comments (optional).\n\nThe main stylesheet. This must be included with your Theme, and it must contain the information header for your Theme.*/" > style.css ;\
echo -e "/*The rtl stylesheet. This will be included automatically if the website's text direction is right-to-left. This can be generated using the the RTLer plugin.*/" > rtl.css ;\
echo -e " <?php /*The main template. If your Theme provides its own templates, index.php must be present. */ ?>" > index.php ;\
echo -e " <?php /*The comments template. */ ?>" > comments.php ;\
echo -e " <?php /*The front page template, it is only used if you use a static front page. */ ?>" > front-page.php ;\
echo -e " <?php /*The home page template, which is the front page by default. If you use a static fr
@nateflink
nateflink / addmysqluser.sh
Last active December 18, 2015 12:49
A bash script that adds a mysql user, and creates a database with the same name as the user and echos the generated password
#!/bin/bash
#By Nate Flink
# Adds a mysql user, and creates a database with the same name as the user and echos the generated password
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
echo "Usage: ./$0 [mysql db username] [mysql user password] [new identifier] [optional password]"
exit 1
fi
#!/bin/bash
#by Nate Flink
mysqldump -u $2 -p$3 --extended-insert=false -h $4 $1 > $5
MINSIZE=3
ACTSIZE=$(du -k $5 | cut -f 1)
if [ $ACTSIZE -le $MINSIZE ]; then
echo "Error: the database backup is ${ACTSIZE} kilobytes, needs to be at least ${MINSIZE}"
exit 1
#!/bin/bash
#By Nate Flink
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
echo "Usage: ./$0 [path to files] [find string] [replace string]"
exit 1
fi
DIRPATH=$1
FIND=$2
#!/bin/bash
#By Nate Flink
#
# get the wp-config mysql variables
#
DIRPATH=$1
VAR=$(curl -s https://gist.github.com/nateflink/06c5f5f99002374fe628/raw/readwpconfig.sh | bash -s "${DIRPATH}/wp-config.php")
STATUS=$?; [[ $STATUS == 0 ]] || { echo "${0} line:${LINENO} exit:$STATUS ${VAR}"; exit 1; }
#!/bin/bash
WPPATH=$1
REMOTE_WPPATH=$2
SSH_USER=$3
SSH_URL=$4
LOCAL_HOSTNAME=$5
REMOTE_HOSTNAME=$6
@nateflink
nateflink / boilerplate_quickie
Created July 17, 2013 15:20
My own boilerplate html for quickies
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Web</title>
<link rel="stylesheet" href="css/style.css">
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
//RGB color macro
#define UIColorFromRGB(rgbValue) [UIColor \ colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \ green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \ blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]  
//RGB color macro with alpha
#define UIColorFromRGBWithAlpha(rgbValue,a) [UIColor \ colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \ green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \ blue:((float)(rgbValue & 0xFF))/255.0 alpha:a]
static inline BOOL IsEmpty(id thing) { return thing == nil || ([thing respondsToSelector:@selector(length)] && [(NSData *)thing length] == 0) || ([thing respondsToSelector:@selector(count)] && [(NSArray *)thing count] == 0); }
static inline NSString *hexFromUIColor(UIColor * _color) {
if (CGColorGetNumberOfComponents(_color.CGColor) < 4) {
const CGFloat *components = CGColorGetComponents(_color.CGColor);
_color = [UIColor colorWithRed:components[0] green:components[0] blue:components[0] alpha:components[1]];
}
if (CGColorSpaceGetModel(CGColorGetColorSpace(_color.CGColor)) != kCGColorSpaceModelRGB) {
return [NSString stringWithFormat:@"#FFFFFF"];
}
return [NSString stringWithFormat:@"#%02X%02X%02X", (int)((CGColorGetComponents(_color.CGColor))[0]*255.0), (int)((CGColorGetComponents(_color.CGColor))[1]*255.0), (int)((CGColorGetComponents(_color.CGColor))[2]*255.0)];
}