Skip to content

Instantly share code, notes, and snippets.

Avatar
🐾
Doing what I love to do!

Iván Corrales Solera ivancorrales

🐾
Doing what I love to do!
View GitHub Profile
View books.py
from models.model import Book
class BookDB:
ID = 0
def __init__(self):
self.books = []
self.insert(Book('Don Quijote de la Mancha', 'Miguel de Cervantes'))
self.insert(Book('Romeo y Julieta', 'William Shakespeare'))
View books.py
# books.py
__author__ = "Iván Corrales Solera <developer@wesovi.com>"
__written_date = "24/04/2016"
import falcon
import json
from database.book import BookDB
View test_book_database.py
from database.book import BookDB,Book
class TestBookDatabase:
def setup(self):
self.bookDatabaseClient = BookDB()
def test_default_database_length(self):
assert self.bookDatabaseClient.books.__len__() is 2
View test_book_resource.py
import json
import falcon
from resources.books import BookResource
import falcon.testing as testing
from falcon import Request,API
class TestBookResource(testing.TestBase):
@ivancorrales
ivancorrales / ex
Created Aug 6, 2016
Reading a file With Elixir
View ex
defmodule Mix.Tasks.Elixchool.FileProcessor do
use Mix.Task
def run(filePath) do
case File.read(filePath) do
{:ok, body} -> process(body)
{:error, reason} -> errorHandler(reason)
end
end
@ivancorrales
ivancorrales / result.exs
Last active Aug 10, 2016
Implement a function that takes three arguments. If the first two are zero, return “FizzBuzz.” If the first is zero, return “Fizz.” If the second is zero, return “Buzz.” Otherwise return the third argument.
View result.exs
test_fn = fn
(0, 0, _) -> "FizzBuzz"
(0, _, _) -> "Fizz"
(_, 0, _) -> "Buzz"
(_, _, c) -> c
end
IO.puts test_fn.(0,0,1)
IO.puts test_fn.(0,1,1)
IO.puts test_fn.(1,0,1)
@ivancorrales
ivancorrales / Dockerfile
Created Aug 11, 2016
Dockerfile for pass-through autentication
View Dockerfile
FROM phusion/baseimage:0.9.8
MAINTAINER Iván Corrales Solera <developer@wesovi.com>
EXPOSE 389
ENV HOME /root
ENV LDAP_ORGANISATION Wesovi Labs
ENV LDAP_DOMAIN wesovilabs.com
ENV LDAP_BASE dc=wesovilabs,dc=com
ENV LDAP_ROOTPASS s3cr3t
ENV LDAP_LOG_LEVEL 256
View slapd.conf
mech_list: plain
pwcheck_method: saslauthd
saslauthd_path: /var/run/saslauthd/mux
View saslatuhd.conf
# saslauthd.conf
# for pass through authentication with central IT LDAP
# connection information (here using SSL, adjust accordingly)
ldap_servers: ldap://*******:389/
# where are we looking
ldap_search_base: ou=users,cn=ad,cn=Wesovilabs,dc=com
ldap_filter: (uid=%u)
View saslauthd
START=yes
DESC="SASL Authentication Daemon"
NAME="saslauthd"
MECHANISMS="ldap"
MECH_OPTIONS=""