Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Cristiam Diaz cdiaz

🏠
Working from home
  • Quantux, @Noders
  • Florencia, Caquetá, Colombia
View GitHub Profile
View Flutter_login_hooks.dart
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: LoginScreen(),
View Flutter_login.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: LoginScreen(),
);
@cdiaz
cdiaz / ProfileModule.ts
Last active Feb 9, 2021
Upload files with Multer & NestJS
View ProfileModule.ts
import { Module, RequestMethod } from '@nestjs/common';
import { MiddlewaresConsumer, NestModule } from '@nestjs/common/interfaces';
import { TypeOrmModule } from '@nestjs/typeorm';
import { MulterMiddleware } from './../common/middleware/multer.middleware';
@Module({
controllers: [..],
components: [..]
})
export class ProfileModule implements NestModule {
@cdiaz
cdiaz / git-auto-deploy.md
Created Jan 29, 2018 — forked from yosukehasumi/git-auto-deploy.md
Setting Up Git-Auto-Deploy on Digital Ocean
View git-auto-deploy.md

Install software-properties-common

sudo apt-get install software-properties-common

Add Repo

sudo add-apt-repository ppa:olipo186/git-auto-deploy
@cdiaz
cdiaz / onion-demo.md
Created Aug 27, 2017
Arquitectura cebolla
View onion-demo.md

Node.js y la arquitectura en capas de cebolla con InversifyJS

Este ejemplo demuestra cómo integrar InversifyJS con Express y como implementar aplicaciones que se adhieren a la arquitectura en capas de cebolla. Esta arquitectura de capas puede representarse en un diagrama como sigue:

onion

La principal diferencia entre una arquitectura de n-capas tradicional y la arquitectura cebolla es la dirección de las dependencias entre capas.

En la arquitectura cebolla aplicamos el principio de inversión de dependencias. Los detalles de la implementación (infraestructura) depende de las abstracciones (dominio):

@cdiaz
cdiaz / app.js
Last active Mar 7, 2018
get and post XMLHttpRequest
View app.js
function main() {
// ENVIAR DATOS AL SERVIDOR
let data = JSON.stringify({ title: 'foo', body: 'bar', userId: 1 });
SendJSON(data)
// PEDIR DATOS AL SERVIDOR
loadJSON((response) => {
console.log(response);
//ACA PUEDE MANIPULAR LA RESPUESTA
@cdiaz
cdiaz / getWeek.js
Last active Sep 16, 2016
Obtener los proximos 7 dias a partir del dia actual
View getWeek.js
function getweek(curr) {
if (curr instanceof Date){
curr.setDate(curr.getDate()-1);
var week=[];
for(var i = 0; i<7; i++) {
week.push({[i]:[getday(new Date( curr.setDate(curr.getDate() + 1)))]});
}
return week;
@cdiaz
cdiaz / groupby.js
Last active Sep 8, 2016
Json Object Group by column
View groupby.js
function sortOn( data, attribute ) {
data.sort(
function( a, b ) {
if ( a[ attribute ] <= b[ attribute ] ) {
return( -1 );
}
return( 1 );
}
View arraySortByCustomAlphabet.js
var dictionary = ['miel', 'extraterrestre', 'al', 'automovil', 'auto', 'revestir'];
var alphabet = "zyxwvutsrqponmlkjihgfedcba";
function sort(dictionary, alphabet) {
function translate(str, alphabet) {
var abc = "abcdefghijklmnopqrstuvwxyz";
return [].map.call(str, function(c) {
return alphabet[abc.indexOf(c)] || c;
}).join(" ");
View Flask_OAuth2.py
from requests_oauthlib import OAuth2Session
from flask import Flask, request, redirect, session, url_for
from flask.json import jsonify
from urlparse import urlparse, parse_qs
import os
app = Flask(__name__)
client_id = "2727775315301"
client_secret = ""