Skip to content

Instantly share code, notes, and snippets.

View dougo-chris's full-sized avatar

Chris Douglas dougo-chris

  • Melbourne Australia
View GitHub Profile
@dougo-chris
dougo-chris / mix.exs
Created September 10, 2019 21:54
Updating Elixir Versions with git sha
defmodule MyApp.App.Mixfile do
use Mix.Project
def project do
[
app: :my_app,
version: "0.0.1-#{sha()}",
...
def sha do
@dougo-chris
dougo-chris / 01-pheonix-prometheus-grafana.exs
Last active September 24, 2018 06:09 — forked from colinrymer/config-config.exs
Phoenix Prometheus Setup
...
defp deps do
[...
{:prometheus, "~> 4.0", override: true},
{:prometheus_ex, "~> 3.0"},
{:prometheus_phoenix, "~> 1.2"},
{:prometheus_plugs, "~> 1.1.5"},
{:prometheus_ecto, "~> 1.0.1"},
{:prometheus_process_collector, "~> 1.3.1"}
# see http://stackoverflow.com/questions/1698335/can-i-use-rspec-mocks-to-stub-out-version-constants
class Object
def self.with_constants(constants, &block)
saved_constants = {}
constants.each do |constant, val|
saved_constants[ constant ] = const_get( constant )
Kernel::silence_warnings { const_set( constant, val ) }
end
begin
@dougo-chris
dougo-chris / ghost_backbone.txt
Created August 4, 2012 02:56
How to create ghost pages with backbone templates
Why
---
My site is backbone.js and rails, including the static marketing content. I wanted this content to be readable by google and I don't want two copies.
Background
----------
I'm using the haml_assets gem so I can write backbone.js views in haml.
Routes
------
@dougo-chris
dougo-chris / everything
Created April 14, 2012 04:47
jasmine & jenkins
group :development, :test do
gem 'jasmine', '1.2.0.rc2', :git => 'https://github.com/pivotal/jasmine-gem.git', :require => false
# gem 'jasmine'
gem 'headless', :require => false
bundle install
bundle exec jasmine init
rm lib/tasks/jasmine.rake
@dougo-chris
dougo-chris / extension.js.coffee
Created March 22, 2012 12:01
Nested model in backbone.js
do ->
_parse = Backbone.Model.prototype.parse
_.extend Backbone.Model.prototype,
initNestedCollections: (nestedCollections) ->
@_nestedCollections = {}
_.each nestedCollections, (theClass, key) =>
@_nestedCollections[key] = new theClass([])
@resetNestedCollections()
@dougo-chris
dougo-chris / site.js
Created March 15, 2012 09:12
Extending my Existing project to handle a small sub app
## remember to add this file to application.rb
## config.assets.precompile << 'site.js'
#= require_self
#= require_tree ./site/template
#= require_tree ./site/view
window.Site =
@dougo-chris
dougo-chris / gist:1992666
Created March 7, 2012 11:42
remote file uploads
TEMPLATE
----
%form#uploadAsset{"accept-charset" => "UTF-8", :action => "/admin/assets", "data-remote" => "true", :enctype => "multipart/form-data", :method => "post"}
%div{:style => "margin:0;padding:0;display:inline"}
%input{:name => "utf8", :type => "hidden", :value => "✓"}/
%input{:name => "authenticity_token", :type => "hidden", :value => ""}/
.element
.avatar.thin
%label.hint#assetLabel
Your Asset
TEMPLATE
--------
%div{:style => "margin:0;padding:0;display:inline"}
%input{:name => "utf8", :type => "hidden", :value => "✓"}/
%input{:name => "authenticity_token", :type => "hidden", :value => ""}/
%input{:name => "_method", :type => "hidden", :value => "put"}/
VIEW
----
@dougo-chris
dougo-chris / gist:1333015
Created November 2, 2011 06:13
Pretty Formatter for RSpec
require 'rspec/core/formatters/base_formatter'
class FormatterPretty < RSpec::Core::Formatters::BaseFormatter
PENDING_FORMAT = "\e[1m\e[37m%s\n\e[33m [PENDING] %s\e[0m"
PENDING_FORMAT_MSG = " \e[34m%s\e[0m"
PENDING_FORMAT_CALLER = " \e[34m# %s\e[0m"
FAILURE_FORMAT = "\e[1m\e[37m%s\n\e[31m\e[1m[FAILURE] %s\e[0m"
FAILURE_FORMAT_LINE = " \e[31m%s\e[0m"