Skip to content

Instantly share code, notes, and snippets.

View chrisblackwell's full-sized avatar

Chris Blackwell chrisblackwell

View GitHub Profile
@chrisblackwell
chrisblackwell / gist:2004522
Created March 9, 2012 01:32
WordPress Blank Plugin
<?php
/*
Plugin Name: Plugin Name
Author: Chris Blackwell
Author URI: http://chrisblackwell.me
Description: Short description of the plugin's functionality
*/
?>
@chrisblackwell
chrisblackwell / whois-query.php
Last active April 22, 2016 19:43
WHOIS Query
function whois_query($domain) {
// fix the domain name:
$domain = strtolower(trim($domain));
$domain = preg_replace('/^http:\/\//i', '', $domain);
$domain = preg_replace('/^www\./i', '', $domain);
$domain = explode('/', $domain);
$domain = trim($domain[0]);
// split the TLD from domain name
@chrisblackwell
chrisblackwell / gist:2004526
Created March 9, 2012 01:33
Check if server is HTTPS
if ($_SERVER['HTTPS'] != "on") {
echo "This is not HTTPS";
}else{
echo "This is HTTPS";
}
@chrisblackwell
chrisblackwell / gist:2004527
Created March 9, 2012 01:33
Detect Location by IP
function detect_city($ip) {
$default = 'UNKNOWN';
if (!is_string($ip) || strlen($ip) < 1 || $ip == '127.0.0.1' || $ip == 'localhost')
$ip = '8.8.8.8';
$curlopt_useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)';
$url = 'http://ipinfodb.com/ip_locator.php?ip=' . urlencode($ip);
# Bot Blocker
<IfModule mod_setenvif.c>
SetEnvIfNoCase User-Agent ^$ keep_out
SetEnvIfNoCase User-Agent (pycurl|casper|cmsworldmap|diavol|dotbot) keep_out
SetEnvIfNoCase User-Agent (flicky|ia_archiver|jakarta|kmccrew) keep_out
SetEnvIfNoCase User-Agent (purebot|comodo|feedfinder|planetwork) keep_out
<Limit GET POST PUT>
Order Allow,Deny
Allow from all
Deny from env=keep_out
@chrisblackwell
chrisblackwell / gist:2004535
Created March 9, 2012 01:34
Latest Tweets
<?php
include_once(ABSPATH . WPINC . '/feed.php');
$rss = fetch_feed('https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=chrisblackwell');
$maxitems = $rss->get_item_quantity(3);
$rss_items = $rss->get_items(0, $maxitems);
?>
<ul>
<?php if ($maxitems == 0) echo '<li>No items.</li>';
else
@chrisblackwell
chrisblackwell / hack.sh
Created March 31, 2012 14:59 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@chrisblackwell
chrisblackwell / gist:2710331
Created May 16, 2012 13:28
Remove Width and Height from WordPress Uploader
add_filter( 'post_thumbnail_html', 'remove_width_attribute', 10 );
add_filter( 'image_send_to_editor', 'remove_width_attribute', 10 );
function remove_width_attribute( $html ) {
$html = preg_replace( '/(width|height)="\d*"\s/', "", $html );
return $html;
}
@chrisblackwell
chrisblackwell / gist:2731193
Created May 19, 2012 15:19
Blank jQuery Plugin
(function($, window, undefined){
$.fn.myPlugin = function(opts) {
var defaults = {
// setting your default values for options
}
// extend the options from defaults with user's options
var options = $.extend(defaults, opts || {});
return this.each(function(){ // jQuery chainability
@chrisblackwell
chrisblackwell / gist:3865698
Created October 10, 2012 13:37 — forked from JeffreyWay/gist:3185773
PHP Installation Options
./configure \
--prefix=/usr \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--sysconfdir=/private/etc \
--with-apxs2=/usr/sbin/apxs \
--enable-cli \
--with-config-file-path=/etc \
--with-libxml-dir=/usr \
--with-openssl=/usr \