Skip to content

Instantly share code, notes, and snippets.

View chrismcg's full-sized avatar

Chris McGrath chrismcg

View GitHub Profile
Looking up modules in dialyze_erlang-18.2.1_elixir-1.2.0-rc.1_deps-dev.plt
Looking up modules in dialyze_erlang-18.2.1_elixir-1.2.0-rc.1.plt
Looking up modules in dialyze_erlang-18.2.1.plt
Finding applications for dialyze_erlang-18.2.1.plt
Finding modules for dialyze_erlang-18.2.1.plt
Creating dialyze_erlang-18.2.1.plt
Looking up modules in dialyze_erlang-18.2.1.plt
Checking 10 modules in dialyze_erlang-18.2.1.plt
Adding 146 modules to dialyze_erlang-18.2.1.plt
Finding applications for dialyze_erlang-18.2.1_elixir-1.2.0-rc.1.plt
@chrismcg
chrismcg / spike.rb
Created November 3, 2013 20:51
Playing with TracePoint and PlantUML Sequence Diagrams.
class Worker
def actually_do_work
puts "workin!"
end
end
class Bar
def nope_maybe_this_does(worker = Worker)
worker.new.actually_do_work
worker.new.actually_do_work
@chrismcg
chrismcg / resaurants.rb
Created June 10, 2013 10:37
Stockholm to Dublin plane hacking with @paulca
require 'csv'
class Restaurant
attr_accessor :name, :country, :scores
def initialize(name)
@scores = Array.new(11, 0)
@name = name
end
@chrismcg
chrismcg / plantuml.sh
Created April 17, 2013 13:11
PlantUML helper script for OSX. Generates a png and opens it
#!/bin/sh
# You need to download the jar from http://plantuml.sourceforge.net/ and put in ~/plantuml
# or alter the path below
java -jar ~/plantuml/plantuml.jar -tpng $@
open ${@%plantuml}png
[5] pry(main)> str = "The voucher entitles you to:> a kir> input> dish> dessert> coffee> a glass of wine"
=> "The voucher entitles you to:> a kir> input> dish> dessert> coffee> a glass of wine"
[6] pry(main)> str.split(/>/)[1..-1]
=> [" a kir", " input", " dish", " dessert", " coffee", " a glass of wine"]
chris@luath % dig a +short www.rubyireland.com
rubyireland.com.
204.232.175.78
chris@luath % dig ns +short www.rubyireland.com
rubyireland.com.
ns2.dnsimple.com.
ns3.dnsimple.com.
ns1.dnsimple.com.
ns4.dnsimple.com.
@chrismcg
chrismcg / gist:5212237
Created March 21, 2013 11:01
Simple ember jasmine spec
describe "StateLabelView", ->
stateLabelView = null
beforeEach ->
stateLabelView = App.StateLabelView.create()
Ember.run -> stateLabelView.append()
afterEach ->
Ember.run -> stateLabelView.remove()
@chrismcg
chrismcg / date_helper_patch.rb
Created January 16, 2013 13:04
Monkey patch Rails 2.3.x to not require symbol keys for date.order
require 'action_view/helpers/date_helper'
class ActionView::Helpers::DateTimeSelector
def translated_date_order
order = I18n.translate(:'date.order', :locale => @options[:locale]) || []
order.map { |item| item.to_sym }
end
end
@chrismcg
chrismcg / gist:5ea3d6d58ee708a5e285
Created October 16, 2015 22:56
Nerves make failure
>>> linux d64fa8121fca9883d6fb14ca06d2abf66496195e Downloading
Doing full clone
Cloning into bare repository 'linux-d64fa8121fca9883d6fb14ca06d2abf66496195e'...
POST git-upload-pack (gzip 1590 to 829 bytes)
remote: Counting objects: 4522912, done.
remote: Compressing objects: 100% (7/7), done.
--2015-10-16 22:52:27-- http://sources.buildroot.net/linux-d64fa8121fca9883d6fb14ca06d2abf66496195e.tar.gz
Resolving sources.buildroot.net (sources.buildroot.net)... 176.9.16.109, 176.9.16.109
Connecting to sources.buildroot.net (sources.buildroot.net)|176.9.16.109|:80... connected.
HTTP request sent, awaiting response... 404 Not Found

I'm struggling with a problem related to using partial_fields and nested data. The examples below are a simplification of my actual problem but are enough I hope to demonstrate it.

Say I'm building a CMS and it supports multiple languages. In the editor for this CMS I'd like to show all the content the user can access and this access is restricted by the locales they can see and whether a particular piece of content has been set as visible yet.

Below are two ways I tried unsuccessfully to map this. Am I going to need to use parent/child documents?

curl -XDELETE 'http://localhost:9201/test_cms'

curl -XPUT 'http://localhost:9201/test_cms'