Skip to content

Instantly share code, notes, and snippets.

View gtindo's full-sized avatar

gtindo gtindo

View GitHub Profile
<!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>
@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");
@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 / 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 / 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 / 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 / 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 / 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 / validate_operation.js
Created April 29, 2020 18:16
validate operation
function isCorrect(expr){
const n = expr.length;
const numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"];
const beforeOperator = [...numbers, ")"]
const afterOperator = [...numbers, "("]
const operators = ["+", "-", "/", "*", "."];
const authorisedsChars = [...numbers, ...operators, "(", ")"];
let leftParenthesis = [];
for(let i = 0; i < n; i++){
@gtindo
gtindo / mp4_to_mp3.py
Created June 28, 2020 22:57
Small script for converting mp4 files inside a directory to mp3 into an output folder.
"""
Small script for converting all mp4 files inside a folder to mp3 into an output folder
Requirement : ffmpeg, python30
Usage : python mp4_to_mp3.py -d <input_directory> -o <ouput_directory>
Author: Gtindo.dev
Licence: ISC
"""
import subprocess