Skip to content

Instantly share code, notes, and snippets.

View michaelcarter's full-sized avatar

Mike Carter michaelcarter

View GitHub Profile
@michaelcarter
michaelcarter / gist:42e31149a7debc4390be
Created March 24, 2015 08:45
Holiday Extras Pull Request Template

What does this PR do?

What unit or integration tests does this PR have?

What selenium tests does this PR have?

How should a developer review this?

How should this be manually tested?

Any background context you want to provide?

What are the relevant tickets?

Screenshots (if appropriate)

What gif best describes how you feel about this work?


@michaelcarter
michaelcarter / gist:e3479beae896743fbd9d
Created August 10, 2014 18:36
Mixpanel Data Export JS in your browser
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>title</title>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/md5.js"></script>
<script src="mixpanel_data_export_min.js"></script>
<script type="text/javascript">
panel = new MixpanelExport({
api_key: "api_key_here",
@fetch
success: (collection, response, options) ->
# Do some stuff on success
error: (collection, response, options) ->
# Do some sfucc on error
@michaelcarter
michaelcarter / dotted_getters.coffee
Created November 26, 2013 10:14
Gives you dotted getters for Backbone. E.g. `@model.get("foo.bar")` vs `@model.get("foo").bar`
define (require, exports, module) ->
DottedGetters =
get: (string) ->
if !!string.match(/\./)
console.log string
@_attrFromDottedString(string)
else
@attributes[string]
@michaelcarter
michaelcarter / gist:4985109
Created February 19, 2013 11:42
Custom validator for CSS hex color codes. I use the American spelling of colour as that's how it appears in CSS...
class CssHexColorValidator < ActiveModel::EachValidator
def validate_each(object, attribute, value)
unless value =~ /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/i
object.errors[attribute] << (options[:message] || "must be a valid CSS hex color code")
end
end
end