Skip to content

Instantly share code, notes, and snippets.

defmodule PossibleCombinations do
@digits_map %{"1" => ["a", "b", "c"], "2" => ["d", "e", "f"], "3" => ["g", "h", "i"]}
def permutation(list) do
list_of_lists =
list
|> Enum.map(fn digit -> @digits_map[digit] end)
_do_combinations(list_of_lists, "")
|> List.flatten
@andrelip
andrelip / estados-cidades.json
Created December 6, 2018 13:15 — forked from letanure/estados-cidades.json
JSON estados cidades
{
"estados": [
{
"sigla": "AC",
"nome": "Acre",
"cidades": [
"Acrelândia",
"Assis Brasil",
"Brasiléia",
"Bujari",
------------
CODE
------------
books_scope = from(b in Book,
where: b.layout == "dynamic")
from(n in ViewedBook,
join: b in subquery(books_scope),
on: b.id == n.book_id,
where: n.book_id == b.id,
# works
def get_ranking_position(reader_id) do
from(n in Cache, where: n.reader_id == ^reader_id, select: n)
end
# don't work
def get_ranking_position(reader_id, neighbors) do
player_position = from(n in Cache, where: n.reader_id == ^reader_id)
from(n in Cache,
join: p in ^player_position,
def get_list do
from(p in Pages,
join: v in ViewedBook,
join: r in Reader,
where: p.viewed_book_id == v.id and v.profile_id == r.id,
where: p.time_spent > 5,
group_by: r.id,
select: %{reader_id: r.id, entity_id: r.entity_id, root_id: r.root_id, time_spent: sum(p.time_spent)})
|> Repo.all
end
defmodule Arvore.Graphql.Reader.AccountMutationQueryTest do
use Arvore.Web.ConnCase
alias Arvore.Repo
alias Arvore.Accounts.User
alias Arvore.GraphQL.UserSchema
test "should log with their credentials and receive a jwt back", info do
%User{ email: "test@gmail.com", username: "test",
encrypted_password: "$2a$10$LVa1Lc0P343lFuby.e.F2eAkRjlMUPB3xVQdggXcfg5Smb0jvxTJq" } # 12345678
|> Repo.insert
[debug] ABSINTHE schema=nil variables=%{}
---
{
user(email: "joao@escola.com.br") {
name
email
id
reader{
entity {
name
chan.join()
.receive("ignore", () => console.log("auth error"))
.receive("ok", () => console.log("join ok"))
.receive("timeout", () => console.log("Connection interruption"))
JQ = (function(){
/*! jQuery v1.11.2 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.2",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.
content = function(){return 'phI6JfTb2VzWytg4xvLwFLvddksCsUm29m1ioCUF8KNLT46wyZ450bRRABpL
LyO7TxqNLqzkm3h9nwdK6GpMOVfxWB9ZOh8PbZs1O8lj4dmdgrWaqwICtIL0
zORUJLQZ6KSclfQsTrUCvQCit7dP7AE9OlWWgUl6SK1AnvXUH1iDiMyJlah0
gt7+tDoS3Kau42qQZ/a+hLjci9cXjQTNIOFt6SmcRHUU5W/tvfLvGafsvCsm
Nwk0NR4TEngzJ+F+VRs4UlqJ5iU2U3wWbOQyYKrzlURRI5dHer8QJgjZMWmy
2AlDjS/RGK9VfuXELwE532x0ZbXOUyzrievex6iD5KbHTtvC6nQnDctXrh7u
qXqpBAWe5Xds8Kc/ibyKzv6h+Jto9BgMzMzCWvBTq6BjpG6r6S9sLdlh3YNM
e+J1FURhSMDiIIA4xL6N0MD9552GWt3NLVgWqw2h5NVLMqx1I06bHBADkoUK
GRKyWIuUbXythNIT3Tw3Y1JUhQcvvV+Dfb5Ge4txwZW6BYvtuRZKqpEEUd9p
lvz5T1h4wPnNOGWIRSxIM1N7raCGaY7m1/qh8mjOU82nZ/wqEXVJjkneEcHJ