Skip to content

Instantly share code, notes, and snippets.

@rossharper
rossharper / IncludeBlogShareScript.html
Created March 19, 2012 23:03
Including sharing.php in my blog
<div class="postfeaturebox">
<?php include(TEMPLATEPATH.'/sharing.php'); ?>
</div>
@rossharper
rossharper / Sharing01.html
Created March 19, 2012 23:15
Twitter, Facebook, and Google+ share buttons for Wordpress
<div class="twitterbutton">
<a href="http://twitter.com/share"
class="twitter-share-button"
data-url="<?php the_permalink() ?>"
data-text="<?php the_title(); ?>"
data-count="none"
data-via="rossharper">
</a><!--<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>-->
</div>
<div class="facebookbutton">
@rossharper
rossharper / functions01.php
Created March 19, 2012 23:40
Registering sharing scripts with Wordpress
<?php
function register_sharing_scripts()
{
if( is_single() || is_home() )
{
wp_enqueue_script('twitter-share', 'http://platform.twitter.com/widgets.js', null, null, true);
wp_enqueue_script('facebook-share', 'http://static.ak.fbcdn.net/connect.php/js/FB.Share', null, null, true);
wp_enqueue_script('google-plusone', 'https://apis.google.com/js/plusone.js', array(), null, true);
}
}
@rossharper
rossharper / sharing01.css
Created March 19, 2012 23:41
Sharing buttons CSS styling
.twitterbutton,
.googleplusonebutton,
.facebookbutton {
float: left;
margin: 0px 10px 0px 0px;
}
.facebookbutton {
padding: 1px 0px 0px 0px;
}
@rossharper
rossharper / pinterest_button.html
Created March 19, 2012 23:52
Pinterest Button for Wordpress
<div class="pinterestbutton">
<a href="http://pinterest.com/pin/create/button/?url=<?php the_permalink() ?>&media=<?php rh_article_image() ?>&description=<?php the_title(); ?>"
class="pin-it-button"
count-layout="none">
<img border="0" src="http://assets.pinterest.com/images/PinExt.png" title="Pin It" />
</a>
</div>
@rossharper
rossharper / functions02.php
Created March 20, 2012 00:03
Registering sharing scripts with Wordpress (inc Pinterest)
<?php
function register_sharing_scripts()
{
if( is_single() || is_home() )
{
wp_enqueue_script('twitter-share', 'http://platform.twitter.com/widgets.js', null, null, true);
wp_enqueue_script('facebook-share', 'http://static.ak.fbcdn.net/connect.php/js/FB.Share', null, null, true);
wp_enqueue_script('google-plusone', 'https://apis.google.com/js/plusone.js', array(), null, true);
wp_enqueue_script('pinterest', 'http://assets.pinterest.com/js/pinit.js', array(), null, true);
}
@rossharper
rossharper / pinterest.css
Created March 20, 2012 00:05
Pinterest button CSS Styling
.pinterestbutton {
float: left;
margin: 0px 10px 0px 0px;
}
@rossharper
rossharper / articleImageFunction.php
Created March 21, 2012 20:43
Getting an article image on WordPress
<?php
function rh_article_image()
{
// If there is an image attached to the post...
if(has_post_thumbnail())
{
// .. get its uri and echo it
$imgarr = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full', false );
echo $imgarr[0];
}
@rossharper
rossharper / RomanNumeralGeneratorTest.kt
Created February 20, 2016 21:36
First two simple tests for Kotlin Roman Numerals Kata
class RomanNumeralGeneratorTest {
private var generator: RomanNumeralGenerator = RomanNumeralGenerator()
@Test
fun shouldReturnIfor1() {
assertThat(generator.arabicToRoman(1), equalTo("I"));
}
@Test
fun shouldReturnIIfor2() {
@rossharper
rossharper / ParameterizedJavaTest.java
Created February 20, 2016 21:45
Java example of a parameterized test for the Roman Numerals Kata
@RunWith(Parameterized.class)
public class JavaTest {
private final int paramOne;
private final String paramTwo;
@Parameterized.Parameters
public static List<Object[]> data() {
return Arrays.asList(new Object[][] {
{1, "I"}, // First test: (paramOne = 1, paramTwo = "I")
{1999, "MCMXCIX"} // Second test: (paramOne = 1999, paramTwo = "MCMXCIX")