This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'json' | |
raise Exception, 'you must provide a json file' unless ARGV[0] | |
json = JSON.parse(File.open(ARGV[0]).read) | |
puts json.first.collect {|k,v| k}.join(',') | |
puts json.collect {|node| "#{node.collect{|k,v| v}.join(',')}\n"}.join |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Select box utilizing Select2 functionality that overrides Ember.Select; | |
// Define view in the same way that you would an Ember.Select view. | |
// Additional attributes supported are: width, allowClear, and closeOnSelect; | |
// Example view: | |
// {{ view App.Select2 | |
// viewName="fieldValueSelect2" | |
// prompt="Please select a value list" | |
// contentBinding="controller.fieldValuesLists" | |
// optionLabelPath="content.name" | |
// optionValuePath="content.id" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Select box utilizing Select2 functionality that overrides Ember.Select; | |
// Define view in the same way that you would an Ember.Select view. | |
// Additional attributes supported are: width, allowClear, and closeOnSelect; | |
// Example view: | |
// {{ view App.Select2 | |
// viewName="fieldValueSelect2" | |
// prompt="Please select a value list" | |
// contentBinding="controller.fieldValuesLists" | |
// optionLabelPath="content.name" | |
// optionValuePath="content.id" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(fizzbuzz). | |
-compile(export_all). | |
run() -> | |
run(lists:seq(1,100), []). | |
run([], Acc) -> | |
lists:reverse(Acc); | |
run([H|T], Acc) -> | |
run(T, [print_string(H)|Acc]). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run this app from Dynamo root with: | |
# mix run -r examples/rest.exs --no-halt | |
# | |
# Open a browser at URL http://localhost:3030 see the wonderment of rest. | |
# | |
defmodule Rest do | |
# Cowboy Rest Handler resources | |
# | |
# * User guide: http://ninenines.eu/docs/en/cowboy/HEAD/guide/rest_handlers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run this app from Dynamo root with: | |
# mix run -r examples/fruit_handler.exs --no-halt | |
# | |
# Open a browser at URL http://localhost:3030 see the wonderment of rest. | |
# | |
defmodule Fruit do | |
# Cowboy REST handler resources | |
# | |
# * User guide: http://ninenines.eu/docs/en/cowboy/HEAD/guide/rest_handlers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule FruitCollectionHandler do | |
use Dynamo.RESTHandler | |
allowed_methods ["GET", "POST", "OPTIONS"] | |
provide "application/json", :get_json | |
provide "text/html", :get_html | |
accept "application/json", :post_json | |
prepare do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule RESTRouter.FruitCollectionHandler do | |
provides "application/json" | |
provides "text/html" | |
provides "text/plain" | |
accepts "application/json" | |
defp fetch | |
Fruit.to_sequence.reverse | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Dynamo.Ecto.Resource do | |
def object | |
conn.fetch :params | |
id = conn.params[:id] | |
query = # Ecto DB Query creation | |
object = Ecto.execute query | |
end | |
end | |
defmodule Fruit do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In some dynamo project | |
defmodule MyProj.Mixfile do | |
def deps(:prod) do | |
[ :ecto ] | |
end | |
end | |
# Generate source, tests, dir structure, etc. | |
# mix ecto.gen.repo -> Generate a database respository in Ecto, |