Skip to content

Instantly share code, notes, and snippets.

View ScottPhillips's full-sized avatar

Scott Phillips ScottPhillips

  • Los Angeles, CA
View GitHub Profile
301 moved permanently (redirect):
<?php
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.example.com');
die();
?>
302 moved temporarily(redirect):
<?php
header('Location: http://www.example.com');
@ScottPhillips
ScottPhillips / consume-rss-feed.php
Created June 30, 2012 22:43
Consume an RSS Feed with PHP
<?php
$doc = new DOMDocument();
$doc->load('http://www.softarea51.com/rss/windows/Web_Development/XML_CSS_Utilities.xml');
$arrFeeds = array();
foreach ($doc->getElementsByTagName('item') as $node) {
$itemRSS = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
@ScottPhillips
ScottPhillips / purge-wp-transients.php
Created June 10, 2012 23:40
WordPress Plugin to Purge Transients
<?php
/*
Plugin Name: Purge Transients
Description: Purge old transients
Version: 0.1
Author: Seebz
*/
@ScottPhillips
ScottPhillips / detect-bot.php
Created June 10, 2012 08:15
Detects a few common Search Bots
<?php
/* Detects some common web bots */
function detectBot($USER_AGENT) {
$crawlers_agents = strtolower('Bloglines subscriber|Dumbot|Sosoimagespider|QihooBot|FAST-WebCrawler|Superdownloads Spiderman|LinkWalker|msnbot|ASPSeek|WebAlta Crawler|Lycos|FeedFetcher-Google|Yahoo|YoudaoBot|AdsBot-Google|Googlebot|Scooter|Gigabot|Charlotte|eStyle|AcioRobot|GeonaBot|msnbot-media|Baidu|CocoCrawler|Google|Charlotte t|Yahoo! Slurp China|Sogou web spider|YodaoBot|MSRBOT|AbachoBOT|Sogou head spider|AltaVista|IDBot|Sosospider|Yahoo! Slurp|Java VM|DotBot|LiteFinder|Yeti|Rambler|Scrubby|Baiduspider|accoona');
$crawlers = explode("|", $crawlers_agents);
if(is_array($crawlers) {
foreach($crawlers as $crawler) {
if (strpos(strtolower($USER_AGENT), trim($crawler)) !== false) {
return true;
}
@ScottPhillips
ScottPhillips / inspect_hooks.php
Created May 30, 2012 00:11 — forked from franz-josef-kaiser/inspect_hooks.php
Inspect hooks in WP by adding &debug=true&hook=my_hook_name to the request URl
<?php
/**
* Plugin Name: Hook Debug Output
* Plugin URI: http://unserkaiser.com
* Description: Debug Hooked filter callback functions with adding <code>?debug=secret&hook=your_hook_name</code> to the URl
* Version: 0.1
* Author: Stephen Harris, Franz Josef Kaiser
* Author URI: http://unserkaiser.com
*/
// Prevent loading this file directly - Busted!
@ScottPhillips
ScottPhillips / s3-public-bucket-policy.json
Created May 23, 2012 01:57
Amazon S3 Bucket Policy : Restrict Access to Specific Referer
{
"Version":"2008-10-17",
"Id":"http referer policy example",
"Statement":[
{
"Sid":"Allow get requests referred by www.mysite.com and mysite.com",
"Effect":"Allow",
"Principal":"*",
"Action":"s3:GetObject",
"Resource":"arn:aws:s3:::YOUR_S3_BUCKET_NAME/*",
@ScottPhillips
ScottPhillips / readme.txt
Created May 23, 2012 01:54
Amazon S3 Bucket Policy : Restrict Access to 1 IP Adress
This statement grants permissions to any user to perform any S3 action on objects in the specified bucket. However, the request must originate from the range of IP addresses specified in the condition. The condition in this statement identifies 192.168.143.* range of allowed IP addresses with one exception, 192.168.143.188.
Note that the IPAddress and NotIpAddress values specified in the condition uses CIDR notation described in RFC 2632. For more information, go to http://www.rfc-editor.org/rfc/rfc4632.txt.
@ScottPhillips
ScottPhillips / s3-public-bucket-policy.json
Created May 22, 2012 01:19
Amazon S3 Bucket Policy : Default Everything to Public
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
$(document).ready(function() {
/* Hide all elements outside the visible window */
$('body *').each( function(){
var top_of_object = $(this).position().top;
var bottom_of_window = $(window).scrollTop() + $(window).height();
if( bottom_of_window < top_of_object ){
@ScottPhillips
ScottPhillips / all-uris.php
Created May 9, 2012 03:19 — forked from thefuxia/all-uris.php
Plugin T5 All URIs
<?php # -*- coding: utf-8 -*-
declare ( encoding = 'UTF-8' );
/**
* Plugin Name: T5 All URIs
* Description: Creates a plaintext list of all URIs on your blog.
* Version: 2012.03.08
* Required: 3.3
* Author: Thomas Scholz <info@toscho.de>
* Author URI: http://toscho.de
* License: MIT