Skip to content

Instantly share code, notes, and snippets.

@rossharper
rossharper / keybase.md
Created June 22, 2018 13:02
Keybase Proof

Keybase proof

I hereby claim:

  • I am rossharper on github.
  • I am rossharper (https://keybase.io/rossharper) on keybase.
  • I have a public key ASB7SOI_OLbTEDcIZ2gsKHfa0FSXCj9eMt5SHtCN_tBxiwo

To claim this, I am signing this object:

@rossharper
rossharper / ParameterizedKotlinTest.kt
Created February 20, 2016 21:51
Parameterized JUnit4 test example in Kotlin
@RunWith(Parameterized::class)
class KotlinTest(val paramOne: Int, val paramTwo: String) {
companion object {
@JvmStatic
@Parameterized.Parameters
fun data() : Collection<Array<Any>> {
return listOf(
arrayOf(1, "I"), // First test: (paramOne = 1, paramTwo = "I")
arrayOf(1999, "MCMXCIX") // Second test: (paramOne = 1999, paramTwo = "MCMXCIX")
@rossharper
rossharper / KotlinStaticMethod.kt
Created February 20, 2016 21:50
Kotlin Static Method
class C {
companion object {
@JvmStatic
fun foo() {
}
}
}
@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")
@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 / 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 / pinterest.css
Created March 20, 2012 00:05
Pinterest button CSS Styling
.pinterestbutton {
float: left;
margin: 0px 10px 0px 0px;
}
@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_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 / 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;
}