Skip to content

Instantly share code, notes, and snippets.

@EtienneR
EtienneR / index.js
Created July 29, 2019 21:43
Very basic JWT Express login / register API (no database, no Bcrypt)
const express = require('express')
const morgan = require('morgan')
const jwt = require('jsonwebtoken')
const cors = require('cors')
const PORT = 1234
const SECRET = 'mykey'
const app = express()
app.use(cors())
@EtienneR
EtienneR / index.js
Created November 2, 2018 15:24
Very simple JWT server
// npm install express morgan jsonwebtoken cors
const express = require('express')
const morgan = require('morgan')
const jwt = require('jsonwebtoken')
const cors = require('cors')
const PORT = 1234
const SECRET = 'mykey'
const app = express()
@EtienneR
EtienneR / pagination.go
Created June 29, 2017 21:42
Paginate an array and order by descending "id"
package main
import (
"fmt"
"math"
"sort"
)
type idSorter []article
@EtienneR
EtienneR / filters.html
Created April 12, 2017 13:05
Petit TP sur les filtres en JavaScript
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Movies - Filter</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body class="container" style="margin-top: 1rem;">
package main
import (
"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
_ "github.com/mattn/go-sqlite3"
)
type Users struct {
Id int `gorm:"AUTO_INCREMENT" form:"id" json:"id"`
'title': 'This is my go blog'
'email': '[email protected]'
'tags': [go, golang, yaml, json]
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Countries CRUD</title>
<style>
input[type='submit'], button, [aria-label]{
cursor: pointer;
}
#spoiler{
@EtienneR
EtienneR / Gulpfile.js
Created March 17, 2016 14:56
Auto reload your Go webserver with Gulp
const gulp = require('gulp'),
util = require('gulp-util'),
notifier = require('node-notifier'),
sync = require('gulp-sync')(gulp).sync,
reload = require('gulp-livereload'),
child = require('child_process'),
os = require('os');
var server = null;
@EtienneR
EtienneR / current_folder.js
Created March 16, 2016 13:55
Get the current folder with NodeJS
const os = require('os');
if (os.platform() == 'win32') {
// Windows
var path_folder = __dirname.split("\\");
} else {
// Linux / MacOS
var path_folder = __dirname.split("/");
}
@EtienneR
EtienneR / recipe.go
Created March 14, 2016 23:38
Simple API JSON (go run recipe.go --> http://127.0.0.1:3000)
package main
import (
"encoding/json"
"fmt"
"net/http"
)
type Recipe struct {
Title string `json:"title"`