Skip to content

Instantly share code, notes, and snippets.

Marc-Philippe Huget mphuget

View GitHub Profile
View gist:9e892ba828acc02835c98a1216772e63
<!DOCTYPE html>
<html>
<head>
<title> All Todos </title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
View Code CRUD MongoDB
function getAllTodos(req, res) {
const Todo = require('../../todo/models');
Todo.find({}, function(err, todos) {
if (err) throw err;
res.json(todos);
});
@mphuget
mphuget / gist:209dd8f2e7255e37c50a07c04ed39171
Created Mar 6, 2019
Add.page.html (le ion-content seulement)
View gist:209dd8f2e7255e37c50a07c04ed39171
<ion-content padding>
<form [formGroup]="todo">
<ion-item>
<ion-label>Todo</ion-label>
</ion-item>
<ion-item>
<ion-input type="text" formControlName="title"></ion-input>
</ion-item>
<ion-item>
<ion-label>Description</ion-label>
View gist:b2f9a261c59a695e77376798d9430578
import { Component, OnInit } from '@angular/core';
import { NavController, LoadingController } from '@ionic/angular';
import { Validators, FormBuilder, FormGroup } from '@angular/forms';
import { RestService } from '../rest.service';
import { ActivatedRoute, Router } from '@angular/router';
@Component({
selector: 'app-add',
templateUrl: './add.page.html',
styleUrls: ['./add.page.scss'],
View gist:58fb01c7186571ff68016eca80b1c281
import { Component, OnInit } from '@angular/core';
import { LoadingController } from '@ionic/angular';
import { RestService } from '../rest.service';
import { ActivatedRoute, ParamMap } from '@angular/router';
@Component({
selector: 'app-view',
templateUrl: './view.page.html',
styleUrls: ['./view.page.scss'],
})
View gist:41d77dddec55ff8722d95defbc5494bf
import { Component } from '@angular/core';
import { LoadingController, NavController } from '@ionic/angular';
import { RestService } from '../rest.service';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
View gist:e65a98dabf21b45c64f2554aaf922e09
import { Injectable } from '@angular/core';
import { Observable, of, throwError } from 'rxjs';
import { HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
import { catchError, tap, map } from 'rxjs/operators';
const httpOptions = {
headers: new HttpHeaders({'Content-Type': 'application/json'})
};
View gist:68d687a1e8851e63aef97ea59eddc380
<ion-content padding>
<ion-list>
<ion-item-sliding #item>
<ion-item>
A new todo
</ion-item>
<ion-item-options side="start">
<button ion-button color="light" routerLink="/">Done</button>
</ion-item-options>
<ion-item-options side="end">
@mphuget
mphuget / gist:b3e8e667c9b815e1f089635e1ee8ce34
Created Feb 8, 2019
Accessing Twitter streaming 1% sample in Python
View gist:b3e8e667c9b815e1f089635e1ee8ce34
#Import the necessary methods from tweepy library
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
#Variables that contains the user credentials to access Twitter API
access_token = ""
access_token_secret = ""
consumer_key = ""
consumer_secret = ""
@mphuget
mphuget / gist:73c1da91afe9a6de80e5b5162ed38962
Created Dec 14, 2018
JavaScript + validation formulaire
View gist:73c1da91afe9a6de80e5b5162ed38962
<!DOCTYPE html>
<html>
<head>
<title> Mon formulaire </title>
<script>
function validateEntries() {
nom = document.getElementById("nom").value;
prenom = document.getElementById("prenom").value;
email = document.getElementById("email").value;
You can’t perform that action at this time.