Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Rodrigo Carranza DrecDroid

🏠
Working from home
View GitHub Profile
View utils.py
from os.path import basename
class EditImgUploadS3:
def __init__(self):
self.s3 = boto3.resource('s3')
self.region = os.getenv('AWS_STORAGE_REGION')
self.bucket = os.getenv('AWS_STORAGE_BUCKET_NAME')
def upload_object(self, image):
new_image = self.draw_rectangle(image)
View python-wathever.py
from typing import Callable, Dict
def map_dict(func: Callable, dictionary: Dict):
'''
Returns a dict with the same keys as `dictionary` and with its
values mapped over `func`
wallet = {'Peter': 20, 'John': 35}
wallet_squared = map_dict(lambda m: m**2, wallet)
'''
View sam.ts
export abstract class Action {
args : any = {}
constructor(public name?:string){}
abstract do(propose : Propose)
toString(){
return `Action "${this.name}"(${this.args})`
View Component.ts
import { Action, AsyncNap} from '__libs__/sam'
export class Component {
children : Component[] = []
rootComponent : ComponentRoot
root : HTMLElement
View Component.ts
abstract class Component {
rootComponent : ComponentRoot;
children : Array<Component> = new Array<Component>();
root : Element;
action : ActionExecutor;
abstract init() : void;
protected _receive(data : Object){
View SAMSystem.ts
interface ActionExecutor {
(action : Action) : void;
}
interface Propose {
(proposal : any);
}
interface Nap {
View example.js
//First approach
function acceptor(model, proposal){
if(proposal.text){
if(proposal.text !== model.layer.text){
model.layer.text = proposal.text
model.state.TEXT_CHANGED = true
}
}
}
@DrecDroid
DrecDroid / per_inline_model_converter.py
Last active Apr 9, 2021
Usually in flask-admin inline-models use the same converter. You can set a different converter setting 'inline_converter' in the ModelView but this will apply the same converter for every Model in the inline_models list.So I've overridden the 'scaffold_inline_form_models' method from ModelView just to check for every inline model in the list if …
View per_inline_model_converter.py
from flask_admin.form import FormOpts
from flask_admin.contrib.sqla.form import InlineModelFormList, \
InlineModelConverter, \
get_form
from flask_admin.contrib.sqla.tools import get_primary_key
from flask_admin.contrib.sqla import ModelView
from flask_admin.model.fields import InlineModelFormField
from flask_admin.model.form import InlineFormAdmin
from flask_admin._compat import iteritems
@DrecDroid
DrecDroid / 0_reuse_code.js
Last active Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View gist:8210916

Lo que se logrará:

  • Crear una máquina virtual linux en windows con virtualbox
  • Conectar un cliente ssh con una máquina virtual linux
  • Instalar un IDE para navegador (ICEcoder) usando apache

Primeros pasos

Descargar Putty : http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe