Skip to content

Instantly share code, notes, and snippets.

View YonathanMeguira's full-sized avatar
🤩
Happy

Yonathan Meguira YonathanMeguira

🤩
Happy
View GitHub Profile
@YonathanMeguira
YonathanMeguira / moneyBot-total-expense.js
Last active June 6, 2018 10:01
money bot --total expense
const Firebase = require("./firebase.init");
const returnTotal = (UID, res) => {
const date = new Date();
const month = date.getMonth();
Firebase.FireDB.ref(UID)
.once("value")
.then(snapshot => {
const user = snapshot.val() || "undefined";
if (user !== "undefined") {
@YonathanMeguira
YonathanMeguira / addExpense.js
Created June 6, 2018 09:57
money bot - new expense
const Firebase = require("./firebase.init");
const addExpense = (request, res) => {
const body = request.body;
const UID = body["messenger user id"];
const ref = Firebase.FireDB.ref(UID);
ref.once("value").then(snapshot => {
const user = snapshot.val() || "undefined";
if (user !== "undefined") {
const date = new Date();
@YonathanMeguira
YonathanMeguira / checkuser.js
Created June 6, 2018 09:54
money bot - check user
const Firebase = require("./firebase.init");
const checkUser = (UID, res) => {
Firebase.FireDB.ref(UID)
.once("value")
.then(snapshot => {
const user = snapshot.val() || "undefined";
if (user !== "undefined") {
res.send({ redirect_to_blocks: ["offre"] });
} else {
@YonathanMeguira
YonathanMeguira / index.js
Created June 6, 2018 09:39
money Bot index.js
const express = require("express");
const bodyParser = require("body-parser");
const request = require("request");
const path = require("path");
const PORT = process.env.PORT || 5000;
const Firebase = require("./lib/firebase.init");
const expense = require("./lib/expense");
const user = require('./lib/checkUser');
const total = require('./lib/total');
const day = require('./lib/setDay');
@YonathanMeguira
YonathanMeguira / merge
Created May 29, 2018 12:50
Merge master to branch
git checkout master
git pull origin master
git checkout <branch>
git merge master
export interface Worker {
firstName: string;
interest: string;
additionalInterests: string[];
city: string;
age: number;
lastName: string;
phone: string;
experiences: Experience[];
entryDate: string;
@YonathanMeguira
YonathanMeguira / pipeSize.pipe.ts
Created March 18, 2018 12:28
fileSize pipe angular 5
import { Pipe, PipeTransform } from '@angular/core';
/*
* Convert bytes into largest possible unit.
* Takes an precision argument that defaults to 2.
* Usage:
* bytes | fileSize:precision
* Example:
* {{ 1024 | fileSize}}
* formats to: 1 KB
@YonathanMeguira
YonathanMeguira / tmpl.html
Created March 14, 2018 13:04
watching decorator @input changes template
<my-component [myBooleanValue]="someValue"></my-component>
@YonathanMeguira
YonathanMeguira / Input-decoractor-changes.ts
Last active March 14, 2018 13:03
watch changes in input decorators
// set up some class with an input decorator (the one we want to watch and act upon change
export class MyComponent {
myBooleanValue: boolean;
@Input()
set myBooleanValue(newValue: boolean) {
// will display this message as soon as the value of 'myBooleanValue' changes
console.log(`old value was ${this.booleanValue}, new value is ${newValue}`;
this.myBooleanValue = newValue;
@YonathanMeguira
YonathanMeguira / service.ts
Created March 14, 2018 10:12
Http service angular 5
goToServer = () => {
this.http.get('url');
}
getInformtionFromService = () => {
service.goToServer().subscribe(result => console.log(result), error => console.log(error.message))
}