Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
#By Nate Flink
#Invoke on the terminal like this
#curl -s https://gist.github.com/nateflink/9056302/raw/findreplaceosx.sh | bash -s "find-a-url.com" "replace-a-url.com"
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: ./$0 [find string] [replace string]"
exit 1
fi
<script type="text/javascript">
function getCookie( name ) {
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ';', len );
if ( end == -1 ) end = document.cookie.length;
@nateflink
nateflink / new_gist_file
Created September 16, 2013 16:15
Bash send mail
cat <<EOF | sendmail -t
To: [email protected]
Subject: Testing
From: [email protected]
This is a test message
EOF
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)];
}
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); }
//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]
@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>
#!/bin/bash
WPPATH=$1
REMOTE_WPPATH=$2
SSH_USER=$3
SSH_URL=$4
LOCAL_HOSTNAME=$5
REMOTE_HOSTNAME=$6
#!/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
#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