Skip to content

Instantly share code, notes, and snippets.

View robfletcher's full-sized avatar

Rob Fletcher robfletcher

View GitHub Profile
@robfletcher
robfletcher / YamlEncodingSpec.groovy
Created August 31, 2012 12:03
Demonstrates problem with reading back yaml containing corrupted UTF-8 characters
package yaml.encoding
import org.yaml.snakeyaml.Yaml
import spock.lang.*
@Unroll
class YamlEncodingSpec extends Specification {
Yaml yaml = new Yaml()
File file
package spock.extensions.state
class StateMachine<E extends Enum> {
private final String name
private E currentState
StateMachine(String name, E initialState) {
this.name = name
currentState = initialState
@robfletcher
robfletcher / _safe-rgba.scss
Created May 17, 2013 08:45
SASS mixin that uses modernizr to output fallback color property for browsers that don't support RGBA.
/*
* Outputs a color property with an opaque fallback for browsers that do not support RGBA.
*/
@mixin safe-rgba($property, $color, $fallback-color: opacify($color, 1)) {
@if opacity($color) == 1 {
#{$property}: $color;
} @else {
#{$property}: $fallback-color;
.rgba & {
#{$property}: $color;
@robfletcher
robfletcher / gist:5598073
Created May 17, 2013 09:43
Validate HTML files from the terminal with curl
curl http://validator.w3.org/check -i -F output=json -F uploaded_file=@<path-to-html-file>

Keybase proof

I hereby claim:

  • I am robfletcher on github.
  • I am robfletcher (https://keybase.io/robfletcher) on keybase.
  • I have a public key whose fingerprint is B0DA 4426 D1D5 1AF0 2D93 F480 9376 AE14 4362 B58E

To claim this, I am signing this object:

@robfletcher
robfletcher / TumblrToMiddleman.groovy
Last active November 5, 2019 14:15
Scrape markdown posts from a Tumblr blog and export for Middleman
/*
* This script will scrape text posts from a Tumblr blog and export them as `.md`
* files with YAML frontmatter ready to be used in a Middleman blog.
*
* Aliases are added for the _middleman-alias_ gem so Tumblr style URLs like
* `/post/{id}/{slug}` will redirect to the Middleman-style URL.
*
* Although I built this for migrating to Middleman it should be pretty easy to
* adapt this for any similar static site generator.
*/
@robfletcher
robfletcher / gist:6c049a4c807cedc0e844
Last active August 29, 2015 14:03
This is a list of smaller, lesser-known libraries that I've used and vouch for. It has bookmark value for me as much as anything but I'm keeping it here in the hope someone might find it useful.

Libraries

JVM

Strongly-typed Java interfaces for REST endpoints. Supports returning RxJava Observables. Similar to Feign which is by Netflix but doesn’t support Rx.

@robfletcher
robfletcher / gist:5d9c79aec1c7bb694517
Last active August 29, 2015 14:05
Is this supposed to be able to compile?
import groovy.transform.*
@CompileStatic
class A {
private final String name
A(String name) {
this.name = name
}
}
@robfletcher
robfletcher / build.gradle
Created October 29, 2014 23:51
Example of trying to execute a script from a gem using JRubyExec
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "com.github.jruby-gradle:jruby-gradle-plugin:0.1.3+"
}
}
def "subscriber receives message"() {
given: "An async event bus"
def eventBus = new AsyncEventBus(Executors.newCachedThreadPool())
and: "A Fake Service"
def vars = new BlockingVariables()
def fakeService = Stub(FictionalService) {
process(_) >> { PersonMessage message -> vars.message = message }
}