Skip to content

Instantly share code, notes, and snippets.

View gtindo's full-sized avatar

gtindo gtindo

View GitHub Profile
@gtindo
gtindo / testSocket.js
Last active March 13, 2020 08:28
Integration test with socket.io
const assert = require('chai').assert;
const socket = require('socket.io-client')("http://localhost:3000");
/**
* function used to wait response on a channel
*
* @param {String} channel
* @param {Function} callback
*/
@gtindo
gtindo / stanzas.js
Created March 5, 2020 11:10
XMPP stanzas
const { xml } = require('@xmpp/client');
function simpleMessage(to, from, type, message){
return xml(
"message",
{to, from, type},
xml("body", {},message)
)
}
@gtindo
gtindo / rtmp_stream_downloader.py
Last active January 31, 2020 12:58
Download rtmp stream file
import librtmp
import time
import re
class ParamsError(Exception):
"""Raised while download params are incorrect."""
pass
@gtindo
gtindo / edge_detection.py
Last active January 26, 2020 14:49
Detect rectangular focus on picture
import numpy as np
import imutils
try:
import cv2
except ImportError:
from cv2 import cv2
def order_points(pts):
@gtindo
gtindo / auth.html
Created December 17, 2019 23:02
#1 - Blog
{% extends 'custom_auth/base.html' %}
{% block title %} Authentication page {% endblock %}
{% block content %}
<form method="post" action="{% url 'custom_auth:auth_view' %}">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="valider" />
</form>
{% endblock %}
@gtindo
gtindo / views.py
Created December 17, 2019 22:57
#1 - Blog, views.py
from django.shortcuts import render
from django.views.generic import FormView
from .forms import AuthForm
from django.contrib.auth.decorators import login_required
from django.contrib import messages
from django.urls.base import reverse_lazy
from django.shortcuts import redirect
class AuthView(FormView):
@gtindo
gtindo / register.js
Last active December 7, 2019 16:04
/*********************************
* Server side of implementation
**********************************/
var app = require('express')();
var http = require('http').createServer(app);
var io = require('socket.io')(http);
app.get("/", (req, res) => {
res.render("client.ejs");
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Test socket</title>
</head>
<body>
<form>
import pandas as pd
from keras.preprocessing.image import ImageDataGenerator
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D, Dropout, Flatten, Dense, Activation, BatchNormalization
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
import os
def validation_required(validator_function):
def decorator(function):
async def error(websocket, err):
await websocket.send(err)
async def wrapper(websocket, data):
status, err = validator_function(data)
if status: