Skip to content

Instantly share code, notes, and snippets.

@jhaus
jhaus / .htaccess
Created November 22, 2011 09:16
Simple Apache rewrite for index.html to the root url. Source/discussion: http://www.webmasterworld.com/google/3105248.htm
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{THE_REQUEST} ^.*\/index\.html?
RewriteRule ^(.*)index\.html?$ http://example.com$1 [R=301,L]
# More resources:
#
# http://old.justinshattuck.com/2007/01/19/apache-mod_rewrite-cheat-sheet/
# http://net.tutsplus.com/tutorials/other/a-deeper-look-at-mod_rewrite-for-apache/
@jhaus
jhaus / .htaccess
Created March 21, 2011 21:55
Apache mod_rewrite parameters for local wordpress HTaccess file on XAMPP - otherwise, may redirect to 404 page
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /path/to/front/of/site/under/root/directory/local_example_com/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /path/to/front/of/site/under/root/directory/local_example_com/index.php [L]
</IfModule>
<div id="feedbackGadget" style="left: 359px; top: 20px; visibility: hidden; display: none; " class="gn-gaiabar-gadget">
<div id="feedbackIframe">
<iframe id="feedbackIframeId" name="feedbackIframeId" class="gn-gaiabar-iframe" src="https://spreadsheets.google.com/embeddedform?key=pPo2nzr1TywUz6Kp4cvV6NA&amp;hl=en&amp;gridId=0" frameborder="0" style="height: 320px; width: 480px;">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Feedback</title>
<?php
$url = "http://icanhascheezburger.com";
$html = file_get_contents($url);
$dom = new DomDocument();
@$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$img = $xpath->evaluate("//div[@class='entry']//img")->item(0);
$imgSrc = $img->getAttribute('src');
print("<img src=\"$imgSrc\" />");
@jhaus
jhaus / google-weather-api.php
Created January 4, 2011 23:05
Prints current + 3 day weather forecast - via: googleapihelp.com (slightly modified)
<?php
$weather_loc = 10001;
function getWeather( $weather_loc ) {
// weather data url, location based
$requestAddress = 'http://www.google.com/ig/api?weather=$weather_loc&hl=en';
// Parse XML
$xml_str = file_get_contents($requestAddress,0);
@jhaus
jhaus / class.TTT_Contactfields.php
Created December 30, 2010 06:18 — forked from anonymous/class.TTT_Contactfields.php
Manage WordPress contact fields
<?php
/**
* Manage WordPress contact fields.
* Usage:
require './class.TTT_Contactfields.php';
$TTT_Contactfields = new TTT_Contactfields(
array (
'Twitter'
, 'Facebook'
@jhaus
jhaus / class.View_All_Posts.php
Created December 30, 2010 06:31 — forked from thefuxia/class.View_All_Posts.php
Adds a view all posts page to any archive
<?php
/**
* Adds a view all posts page to any archive.
*
* @author Thomas Scholz http://toscho.de
* @version 1.1
* @license: GPL2
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
Using Wordpress XMLRPC services Jul 5th, 2009 | By admin | Category: Featured, PHP, Tutorials
(1 votes, average: 4.00 out of 5)
Wordpress is a great blogging platform. With tons of plugins available, Wordpress is quickly become a good choice not only for personal blogging purpose but also for making content oriented sites. There are also many sites want to add ‘blog’ feature into it and WP one more time is the chosen one. Although WP’s plugin architecture is really not good, the WP’s team have added in a really interesting tool that help integration between WP blog and hosting site easier. It’s XMLRPC services.
Here are some scenarios if you has a WP blog and you want to integrate it with another site, you will found XMLRPC helpful:
Showing latest posts/comments on the site homepage
Provide links to categories in your blog
Turning your WP blog into a collaborative environment for your site’s authors
@jhaus
jhaus / default-wp-config.php
Created December 5, 2010 01:39
WP Config file with some useful default settings
<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. Get MySQL settings from web host.
* You can find more information by visiting the Codex page:
*
* @link http://codex.wordpress.org/Editing_wp-config.php
*
<?php
set_time_limit(0);
require_once("IXR_Library.php.inc");
$client->debug = true; // Set it to fase in Production Environment
// Create the client object
$client = new IXR_Client('Your Blog URL/xmlrpc.php');
$username = "Blog Admin/Editor/Author User Name";