Skip to content

Instantly share code, notes, and snippets.

View allanaguilar's full-sized avatar
🎯
Focusing

Allan Aguilar allanaguilar

🎯
Focusing
View GitHub Profile
//Genera un número aleatorio entre un rango de enteros
function patito(minimo, maximo)
{
var numero = Math.floor( Math.random() * (maximo - minimo + 1) + minimo );
return numero;
}
var opciones = ["Piedra", "Papel", "Tijera","Lagarto", "Spock"];
var opcionUsuario;
@allanaguilar
allanaguilar / Dictionary.ts
Created January 17, 2018 17:11 — forked from xperiments/Dictionary.ts
Typescript Dictionary
//http://stackoverflow.com/questions/15877362/declare-and-initialize-a-dictionary-in-typescript
interface IDictionary {
add(key: string, value: any): void;
remove(key: string): void;
containsKey(key: string): bool;
keys(): string[];
values(): any[];
}
@allanaguilar
allanaguilar / file_to_base64.py
Created June 28, 2018 19:48 — forked from maniartech/file_to_base64.py
A python function which converts file to base64 string.
def file_to_base64(file_path):
"""
A simple function which accepts the file_path and
converts and returns base64 string if specified file
exists. Returns blank string '' if file is not found.
"""
from os import path
if not path.exists(file_path):
return ''
return open(file_path, 'rb').read().encode('base64')
@allanaguilar
allanaguilar / FlaskFlashMessagesAsBootstrapAlert.html
Last active July 3, 2018 15:58
Flask flash messages as Bootstrap alert
{% with messages = get_flashed_messages(with_categories=true) %}
<!-- Categories: success (green), info (blue), warning (yellow), danger (red) -->
{% if messages %}
{% for category, message in messages %}
<div class="alert alert-{{ category }} alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<!-- <strong>Title</strong> --> {{ message }}
</div>
{% endfor %}
{% endif %}
@allanaguilar
allanaguilar / flaskapp.py
Last active July 3, 2018 21:46
Sample for micro web server
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#INSTALL FLASK WITH: pip install Flask
from flask import Flask, request
app = Flask(__name__)
@app.route('/saludo', methods=['GET'])
def hello():
@allanaguilar
allanaguilar / CouchDB_Python.md
Created July 16, 2018 23:12 — forked from marians/CouchDB_Python.md
The missing Python couchdb tutorial

This is an unofficial manual for the couchdb Python module I wish I had had.

Installation

pip install couchdb

Importing the module

@allanaguilar
allanaguilar / Pipfile
Created August 2, 2018 19:32
Heroku requirements for Flask
[packages]
flask = "*"
flask-sqlalchemy = "*"
"psycopg2" = "*"
gunicorn = "*"
[requires]
@allanaguilar
allanaguilar / deploying_django_to_heroku.md
Last active August 2, 2018 20:33 — forked from prodeveloper/deploying_to_heroku.md
Deploying Django app to a heroku server

For the lesson today, we are going to deploy our application to a live server.

The current workspace provided by cloud9 is meant only for development and not for production. By that, we mean you can use the service to write and even test your code but not to run your service.

For this we will be using a platform called heroku. Heroku is a PAAS (Platform As A Service).

This means you will not need to work VMs and such. Heroku will work with your code as long as you push it, which do using a similar technique.

The main things to consider when hosting your code will be:

@allanaguilar
allanaguilar / gist:0306ab99dbbc2bf81780a7ba6c30a916
Created August 13, 2018 14:26
How to set values to update records in odoo using json-RPC, odoorpc...
write(vals)
Updates all records in the current set with the provided values.
:param dict vals: fields to update and the value to set on them e.g::
{'foo': 1, 'bar': "Qux"}
will set the field ``foo`` to ``1`` and the field ``bar`` to
``"Qux"`` if those are valid (otherwise it will trigger an error).
:raise AccessError: * if user has no write rights on the requested object
* if user tries to bypass access rules for write on the requested object
:raise ValidateError: if user tries to enter invalid value for a field that is not in selection
:raise UserError: if a loop would be created in a hierarchy of objects a result of the operation (such as setting an object as its own parent)
@allanaguilar
allanaguilar / INSTALL_VIRTUAL_FLECTRA.md
Created August 15, 2018 17:48 — forked from robertrottermann/INSTALL_VIRTUAL_FLECTRA.md
Install flectra in a virtual env
Copyright (C) 2018  Robert Rottermann redO2oo.ch

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as
    published by the Free Software Foundation, either version 3 of the
    License, or (at your option) any later version.

 This program is distributed in the hope that it will be useful,