Skip to content

Instantly share code, notes, and snippets.

@efrenfuentes
efrenfuentes / numero_letras.py
Created September 26, 2012 02:29
Numero a letras (Python)
#!/usr/bin/python
# -*- coding: utf-8 -*-
__author__ = 'efrenfuentes'
MONEDA_SINGULAR = 'bolivar'
MONEDA_PLURAL = 'bolivares'
CENTIMOS_SINGULAR = 'centimo'
@efrenfuentes
efrenfuentes / calculator.py
Created September 8, 2022 01:20
Python simple calculator
def add(x, y):
return x + y
def sub(x, y):
return x - y
def mul(x, y):
return x * y
class Authorization:
def __init__(self, permissions, users):
self.permissions = permissions
self.users = users
def get_user(self, user_id):
for user in self.users:
if user_id == user["id"]:
return user
return None
@efrenfuentes
efrenfuentes / alpine-js-fetch-data-on-x-init.markdown
Created September 13, 2021 20:18 — forked from marcus-at-localhost/alpine-js-fetch-data-on-x-init.markdown
[Alpine.js fetch data on `x-init`] #js #alpinejs

Keybase proof

I hereby claim:

  • I am efrenfuentes on github.
  • I am efrenfuentes (https://keybase.io/efrenfuentes) on keybase.
  • I have a public key ASCaO5Z69pzBybyGSsWGl8U81z0J4qSyTn6x5NyNboCDfgo

To claim this, I am signing this object:

@efrenfuentes
efrenfuentes / ascii.txt
Created February 5, 2021 19:36
ASCII Art
,_,
(.,.)
( )
-"-"---
,_,
(O,O)
( )
-"-"---
@efrenfuentes
efrenfuentes / my_app.ex
Created May 19, 2020 15:35 — forked from alanpeabody/my_app.ex
Websockets in Elixir with Cowboy and Plug
defmodule MyApp do
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
Plug.Adapters.Cowboy.child_spec(:http, MyApp.Router, [], [
dispatch: dispatch
])
@efrenfuentes
efrenfuentes / gcd_and_lcm.py
Created March 28, 2020 21:45 — forked from endolith/gcd_and_lcm.py
GCD and LCM functions in Python for several numbers
# Greatest common divisor of 1 or more numbers.
from functools import reduce
def gcd(*numbers):
"""
Return the greatest common divisor of 1 or more integers
Examples
--------
@efrenfuentes
efrenfuentes / rename_phoenix_project.sh
Created December 20, 2019 20:54 — forked from krystofbe/rename_phoenix_project.sh
rename a phoenix 1.3 project
#!/bin/bash
set -e
CURRENT_NAME="Zauberantrag"
CURRENT_OTP="zauberantrag"
NEW_NAME="Wunderantrag"
NEW_OTP="wunderantrag"
@efrenfuentes
efrenfuentes / Phoenix JWT.md
Created December 13, 2019 13:26 — forked from odyright/Phoenix JWT.md
Elixir + Phoenix Framework 1.3 + Guardian + JWT(Refresh, Revoke, Recover) + Comeonin

Elixir + Phoenix Framework 1.3 + Guardian + JWT(Refresh, Revoke, Recover) + Comeonin

User model bootstrap

Let's generate User model and controller.

mix ecto.create
mix phoenix.gen.json Accounts User users email:string password_hash:string