Skip to content

Instantly share code, notes, and snippets.

View rupert-ong's full-sized avatar

Rupert Ong rupert-ong

  • Toronto, Ontario
View GitHub Profile
@rupert-ong
rupert-ong / 0_selector_hacks.scss
Created September 5, 2012 18:17 — forked from chriseppstein/0_selector_hacks.scss
This gist demonstrates some uses of the new sass feature: Passing content blocks to mixins.
@mixin ie6 { * html & { @content } }
#logo {
background-image: url("/images/logo.png");
@include ie6 { background-image: url("/images/logo.gif"); }
}
@rupert-ong
rupert-ong / gist:3209846
Created July 30, 2012 20:21
CSS: Micro Clearfix
/**
* For modern browsers
* 1. The space content is one way to avoid an Opera bug when the
* contenteditable attribute is included anywhere else in the document.
* Otherwise it causes space to appear at the top and bottom of elements
* that are clearfixed.
* 2. The use of `table` rather than `block` is only necessary if using
* `:before` to contain the top-margins of child elements.
*/
.cf:before,
@rupert-ong
rupert-ong / snippet.js
Created July 9, 2012 14:44 — forked from necolas/snippet.js
Optimised async loading of cross-domain scripts
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],
@rupert-ong
rupert-ong / CSS3 Shadow
Created July 6, 2012 14:53
CSS3: Angled Drop Shadows
div {
background: rgba(255,255,255,1);
margin: 0 auto;
width: 200px;
padding: 100px;
text-align: center;
position: relative;
}
.shadow::before, .shadow::after {
@rupert-ong
rupert-ong / gist:3004405
Created June 27, 2012 14:28
Wordpress: Previous Next Post Link
<?php
previous_post_link('%link', '&laquo; Previous Post');
if (get_adjacent_post(false, '', false) && get_adjacent_post(false, '', true)) {
echo ' | ';
}
next_post_link('%link', 'Next Post &raquo;');
@rupert-ong
rupert-ong / gist:2995877
Created June 26, 2012 13:49
Wordpress: Remove Image Attributes
// Remove Image Attributes
add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10 );
add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 );
function remove_thumbnail_dimensions( $html ) {
$html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
return $html;
}
@rupert-ong
rupert-ong / gist:2991270
Last active August 3, 2017 13:35
Wordpress: Move Site SQL Command
UPDATE wp_options SET option_value = replace(option_value, 'http://oldsite.com', 'http://newsite.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://oldsite.com', 'http://newsite.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://oldsite.com', 'http://newsite.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://oldsite.com', 'http://newsite.com');
@rupert-ong
rupert-ong / gist:2570662
Created May 1, 2012 19:21
Wordpress: Short Loop
<?php
if (have_posts()) : while (have_posts()) : the_post();
the_content('Read the rest of this entry »');
?>
<?php
endwhile;
else:
echo 'Sorry, no posts were found.';
endif;
?>
@rupert-ong
rupert-ong / gist:2570660
Created May 1, 2012 19:20
Wordpress: Long Loop Snippet
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-">
<h2><a href="" rel="bookmark" title="Permanent Link to
<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<small><?php the_time('F jS, Y') ?> <!-- by --></small>
<div class="entry">
<?php the_content('Read the rest of this entry »'); ?>
</div>
@rupert-ong
rupert-ong / MySQL Commands
Created April 26, 2012 14:11
Wordpress: Migrate Site (MySQL + Functions.php)
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldsite.com', 'http://www.newsite.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldsite.com','http://www.newsite.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldsite.com', 'http://www.newsite.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://www.oldsite.com', 'http://www.newsite.com');