Skip to content

Instantly share code, notes, and snippets.

View siriokun's full-sized avatar

Rio Purnomo siriokun

View GitHub Profile
@thefuxia
thefuxia / function.is_local.php
Created October 8, 2009 13:55
function is_local()
<?php
function is_local()
{
return ( '127.0.0.1' == $_SERVER["REMOTE_ADDR"]) ? TRUE : FALSE;
}
@mathiasbynens
mathiasbynens / Playing sounds on mouseover using jQuery
Created November 27, 2009 10:41
Playing sounds on mouseover using jQuery. Using <embed>, because who needs <audio> anyway‽
var $sound = $('<div id="sound" />').appendTo('body');
$('#special-links-that-play-annoying-sounds-when-hovered a').hover(function() {
$sound.html('<embed src="foo.mp3" hidden="true" autostart="true" loop="false">');
}, function() {
// We could empty the innerHTML of $sound here, but that would only slow things down.
});
@mathiasbynens
mathiasbynens / toggleAttr() jQuery plugin
Created February 8, 2010 21:20
toggleAttr() jQuery plugin
/*!
* toggleAttr() jQuery plugin
* @link http://github.com/mathiasbynens/toggleAttr-jQuery-Plugin
* @description Used to toggle selected="selected", disabled="disabled", checked="checked" etc…
* @author Mathias Bynens <http://mathiasbynens.be/>
*/
jQuery.fn.toggleAttr = function(attr) {
return this.each(function() {
var $this = $(this);
$this.attr(attr) ? $this.removeAttr(attr) : $this.attr(attr, attr);
/*
* jQuery fasterTrim Plugin
* version: 1.0.1
* @requires jQuery v1.0.x or later
*
* licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* @version $Id: jquery.fastertrim.js 2 2010-03-04 12:00:00Z $
* @author Travis Hardiman https://forum.jquery.com/user/travis.hardiman http://travis.servebeer.com
*::selection {
background: transparent;
}
@mathiasbynens
mathiasbynens / jquery.preload.js
Created April 22, 2010 17:11
JavaScript preload() function
/*!
* $.preload() function for jQuery – http://mths.be/preload
* Preload images, CSS and JavaScript files without executing them
* Script by Stoyan Stefanov – http://www.phpied.com/preload-cssjavascript-without-execution/
* Slightly rewritten by Mathias Bynens – http://mathiasbynens.be/
* Note that since this script relies on jQuery, the preloading process will not start until jQuery has finished loading.
*/
jQuery.preload = function(array) {
var length = array.length,
@thefuxia
thefuxia / post-cats-to-css-classes.php
Created July 24, 2010 23:26
Converts post categories into CSS classes
<?php
function categories_to_classes()
{
$out = '';
$cats = get_the_category();
foreach ( $cats as $cat_object )
{
$out .= $cat_object->slug . ' ';
}
// Original code from David Walsh
jQuery(document).ready(function() {
/* fetch elements */
jQuery('form.follow-form').each(function() {
/* stop form event */
jQuery(this).bind('submit',function(e) {
/* stop event */
e.preventDefault();
/* "on request" */
jQuery(this).find('i').addClass('active');
@mathiasbynens
mathiasbynens / jquery.togglefade.js
Created September 2, 2010 14:56
jQuery toggleFade()
jQuery.fn.toggleFade = function(speed, callback) {
speed = ~~speed || 400;
callback = callback || jQuery.noop;
return this.each(function() {
var $this = jQuery(this);
$this[$this.is(':hidden') ? 'fadeIn' : 'fadeOut'](speed, callback);
});
};
<?php
/*
Plugin Name: Employee List
Description: Leverages an existing "employee" custom post type to create a shortcode for a list of employees
Version: 0.1
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/
function tampa_employee_list() {