Skip to content

Instantly share code, notes, and snippets.

<?php
$rg = "/[0-9]{3}/";
preg_match($rg, '208') //true
preg_match($rg, '2098') //false
preg_match($rg, 234) //false
?>
<?php
/**
* Adds a view to the post being viewed
*
* Finds the current views of a post and adds one to it by updating
* the postmeta. The meta key used is "tpost_views".
*
* @global object $post The post object
* @global WP_Query $wpdb
* @return integer $new_views The number of views the post has
@sophy
sophy / index.html
Created July 2, 2012 08:51
A web page created at CodePen.io
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Piggy &middot; CodePen</title>
<link rel="stylesheet" href="http://codepen.io/stylesheets/css/normalize.css">
@sophy
sophy / jCarousel.js
Created February 16, 2012 04:44
Slide show
/*!
* jCarousel - Riding carousels with jQuery
* http://sorgalla.com/jcarousel/
*
* Copyright (c) 2006 Jan Sorgalla (http://sorgalla.com)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* Built on top of the jQuery library
* http://jquery.com
<?php
/**
* Define google url shortener api
*/
define("API_URL", "https://www.googleapis.com/urlshortener/v1/url?key=");
class GoogleURL
{
/**
*