Skip to content

Instantly share code, notes, and snippets.

View cdiaz's full-sized avatar
🏠
Working from home

Cristiam Diaz cdiaz

🏠
Working from home
  • Quantux, @Noders
  • Florencia, Caquetá, Colombia
View GitHub Profile
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(),
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 February 9, 2022 04:19
Upload files with Multer & NestJS
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 January 29, 2018 15:27 — forked from yosukehasumi/git-auto-deploy.md
Setting Up Git-Auto-Deploy on Digital Ocean

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 August 27, 2017 02:11
Arquitectura cebolla

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 March 7, 2018 00:12
get and post XMLHttpRequest
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 September 16, 2016 05:47
Obtener los proximos 7 dias a partir del dia actual
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 September 8, 2016 06:08
Json Object Group by column
function sortOn( data, attribute ) {
data.sort(
function( a, b ) {
if ( a[ attribute ] <= b[ attribute ] ) {
return( -1 );
}
return( 1 );
}
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(" ");
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 = ""