Skip to content

Instantly share code, notes, and snippets.

View spikeheap's full-sized avatar

Ryan Brooks spikeheap

View GitHub Profile
@spikeheap
spikeheap / gist:8019649
Last active December 31, 2015 17:19
Script to purge large files from a git repository history
FILE_TO_DELETE="target"
# Filter the history
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch ${FILE_TO_DELETE' --prune-empty --tag-name-filter cat -- --all
# Purge the local repository and force garbage collection
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now
@spikeheap
spikeheap / Gruntfile.js
Created December 20, 2013 17:39
Configuration and setup for AngularJS, LessCSS and CoffeeScript, using Bootstrap
// Generated on 2013-12-20 using generator-angular 0.6.0
'use strict';
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'
module.exports = function (grunt) {
@spikeheap
spikeheap / build.gradle
Last active April 11, 2020 19:05
Gradle build script to install NodeJS packages and Bower dependencies. This assumes you create package.json (nodejs) and bower.json files in the root of your project.
import org.gradle.api.tasks.Exec
defaultTasks 'bower'
// Get the path for the locally installed binaries
task npmBin << {
new ByteArrayOutputStream().withStream { os ->
def result = exec {
executable = 'npm'
args = ['bin']

Simple AngularJS directive - delete confirmation

An example of an AngularJS directive with state. This directive provides a delete confirmation widget, and the state is managed in the directive's controller.

A Pen by Ryan Brooks on CodePen.

License.

@spikeheap
spikeheap / Readme.md
Last active August 29, 2015 13:56
Demo of double-click event handling in Geb
@spikeheap
spikeheap / Readme.md
Last active August 29, 2015 13:56
Geb context clicks

Geb context click example

A simple test demonstrating how to do a context click in Geb.

@spikeheap
spikeheap / MongoConnection.groovy
Last active August 29, 2015 13:56
Sample mongo connection in Groovy using gmongo
def credential = MC.createMongoCRCredential( "server", "db", "pass".toCharArray() )
def mongoClient = new MongoClient( new ServerAddress("ds033429.mongolab.com", 33429), [ credential ] )
def mongo = new GMongo( mongoClient )
def db = mongo.getDB("CloudFoundry_8sbeqjqe_6hqm0ehp")
map.each { key, value ->
db.riverlevelsgroovy << value
}
@spikeheap
spikeheap / 1_obvious_approach.groovy
Last active August 29, 2015 13:56
Using Grails 'respond' for HTML, JSON and XML responses
def show(Widget widget){
// renders a blank page for null objects
respond widget, [model: [widget: widget]]
}
@spikeheap
spikeheap / Readme.md
Created February 27, 2014 18:56
Disqus for your homepage

Disqus homepage comments

I really do get on well with docpad. Despite wanting to move to a JVM-based static site generator, docpad does too many things to make me want to leave. It's not perfect, but it has plugins to solve mosts of your basic problems, and is nicely hackable. Plus it's written in CoffeScript, which is always a plus. Adding comments to the homepage blog entry was a little tricky though

The services plugin provides a neat way to inject Disqus comment threads into your pages. It's almost no configuration, and works reliably, but it doesn't work when you're rendering dynamic content, for example the latest blog post on your home page.

Everything worked well until Disqus got confused. First it displayed the comments from a blog post on the homepage when it was no longer correct. Then it just started displaying the comment thread on all pages which didn't have their own threads already. Not so good.

@spikeheap
spikeheap / LittleFunctionSpec.groovy
Created March 27, 2014 14:16
Using Spock and Gradle to test JavaScript running on Rhino. See http://ryanbrooks.co.uk/posts/2014-03-27-testing-rhino-js-spock/ for the context.
package my.package
class LittleFunctionSpec extends Specification{
Context context
Scriptable scope
/**
* Setup, prior to every spec test
*/
void setup(){