mix new ecto_tut --module EctoTut
* creating README.md
* creating .gitignore
* creating mix.exs
* creating config
* creating config/config.exs
* creating lib
* creating lib/ecto_tut.ex
This file contains hidden or 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
var casper = require('casper').create(); | |
var url = 'http://apps.ohiodnr.gov/oilgas/rbdmsreports/Downloads_PermitAndPlug.aspx'; | |
casper.userAgent("Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36"); | |
casper.start(url); | |
casper.then(function(arg) { | |
//this.capture('a.png', {top: 100, left: 100, width: 700, height: 500}); | |
this.fillSelectors('#aspnetForm', { | |
'#ctl00_ContentPlaceholder1_rdp_ApplicationIssuedStart_dateInput': '12/1/2014', |
This file contains hidden or 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 Brote.Ledger do | |
@moduledoc """ | |
This is the module where most of the transactions happen | |
""" | |
use Brote.Web, :model | |
import Ecto.Query | |
alias Brote.{Category, Contact, Payment, Organization, Ledger, Repo} | |
@derive {Poison.Encoder, only: [:id, :amount, :balance, :date, :contact_id, :category_id, :description, :currency, |
This file contains hidden or 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
alias Cart.{Repo, Item, Invoice, InvoiceItem} | |
Repo.insert(%Item{name: "Chocolates", price: Decimal.new("5")}) | |
Repo.insert(%Item{name: "Gum", price: Decimal.new("2.5")}) | |
Repo.insert(%Item{name: "Milk", price: Decimal.new("1.5")}) | |
Repo.insert(%Item{name: "Rice", price: Decimal.new("2")}) | |
This file contains hidden or 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 Bonsai.Payment do | |
use Bonsai.Web, :model | |
alias Bonsai.{User, Ledger, Repo} | |
@zero Decimal.new(0) | |
@primary_key {:id, :binary_id, autogenerate: true} | |
embedded_schema do | |
field :amount, :decimal | |
field :date, Ecto.Date |
This file contains hidden or 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
class UserSession | |
class << self | |
attr_reader :user | |
delegate :id, :email, to: :user | |
# Stores using de application_controller the current_user for devise | |
def user=(usr) | |
raise 'You must pass a User class' unless usr.is_a?(User) | |
@user = usr | |
end |
Attemp to make work react with elm on a phoenix project.
The project directory for elm is
web
├── channels
├── controllers
│ └── api
│ └── v1
This file contains hidden or 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
alias Hello.User | |
user = Repo.get!(User, 1) | |
umap = Map.delete(Map.from_struct(user), :__meta__) | |
to_string Poison.Encoder.encode(umap, []) |
This file contains hidden or 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
$.ajax({ | |
headers: {token: 'OUy_IJxQveSiKGYPPqYQnAumNCSJSilBAX5A9upF4JU'}, | |
method: "POST", | |
url: "http://demo.bonsaierp.com/api/v1/incomes", | |
data: { | |
income: { | |
"date":"2015-11-13", | |
"due_date":"2015-11-16", | |
"contact_id":1, | |
"currency":"BOB", |
This file contains hidden or 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
class CodigoControlGen | |
# Verhoeff Digit table variables | |
TABLE_D = [ | |
[0,1,2,3,4,5,6,7,8,9], | |
[1,2,3,4,0,6,7,8,9,5], | |
[2,3,4,0,1,7,8,9,5,6], | |
[3,4,0,1,2,8,9,5,6,7], | |
[4,0,1,2,3,9,5,6,7,8], | |
[5,9,8,7,6,0,4,3,2,1], | |
[6,5,9,8,7,1,0,4,3,2], |