Skip to content

Instantly share code, notes, and snippets.

View claustres's full-sized avatar
🏠
Working from home

Luc Claustres claustres

🏠
Working from home
View GitHub Profile
@claustres
claustres / capture_request_body.json
Created September 2, 2024 13:49
Capture Service Request Body
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@claustres
claustres / elevation_response.json
Last active August 21, 2024 08:26
Elevation Service Response
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@claustres
claustres / elevation_request_body.json
Created August 21, 2024 08:21
Elevation Service Request Body
{
"type": "Feature",
"resolution": 100,
"corridorWidth": 100,
"geometry": {
"type": "LineString",
"coordinates": [
[x0,y0,z0],
...,
[xn,yn,zn]
@claustres
claustres / forward_geokoder_response.json
Last active August 21, 2024 08:03
Forward Geokoder Response
[{
"type": "Feature",
"properties": {
"state": "11, Aude, Occitanie",
"city": "Carcassonne",
"zipcode": "11000",
"citycode": "11069",
"countryCode": "FR",
"country": "France",
"type": "municipality",
@claustres
claustres / service-events.md
Last active January 31, 2024 10:20 — forked from daffl/service-events.md
HTTP methods, service layer and real-time event mapping
HTTP method Service layer method Real-time event
GET /features features.find({}) -
GET /features?properties.type=building features.find({ query: { properties.type: building } }) -
GET /features/id features.get(id) -
POST /features features.create(body) features created
PUT /features/id features.update(id, body) features updated
PUT /features?properties.id=1 features.update(null, body, { query: { properties.id: 1 } }) features updated
PATCH /features/id features.patch(id, body) features patched
PATCH /features?properties.id=1 features.patch(null, body, { query: { properties.id: 1 } }) features patched
@claustres
claustres / oauth_app_client.js
Last active August 30, 2022 17:55
OAuth client authentication for Feathers v4
import feathers from '@feathersjs/client'
import { io } from 'socket.io-client'
export const client = feathers()
// Initialize as usual
const socket = io(origin)
client.configure(feathers.socketio(socket))
export async function restoreSession () {
try {
@claustres
claustres / default.js
Created June 22, 2022 08:04
OAuth configuration file for Feathers v4
module.exports = {
authentication: {
secret: 'your secret',
path: '/authentication',
service: '/users',
entity: 'user',
authStrategies: [
'jwt',
'local'
],
@claustres
claustres / oauth-app.js
Last active June 22, 2022 07:58
OAuth backend configuration for Feathers v4
import _ from 'lodash'
import feathers from '@feathersjs/feathers'
import configuration from '@feathersjs/configuration'
import express from '@feathersjs/express'
import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication'
import { LocalStrategy } from '@feathersjs/authentication-local'
import { AuthenticationProviderStrategy } from './AuthenticationProviderStrategy.js'
import { expressOauth } from '@feathersjs/authentication-oauth'
const app = express(feathers())
@claustres
claustres / AuthenticationProviderStrategy.js
Last active June 21, 2022 09:14
OAuth strategy for Feathers v4
import _ from 'lodash'
import { OAuthStrategy } from '@feathersjs/authentication-oauth'
export class AuthenticationProviderStrategy extends OAuthStrategy {
async getEntityData (profile, entity) {
const createEntity = _.isNil(entity)
// Add provider Id
entity = { [`${this.name}Id`]: profile.id || profile.sub }
// When creating a new user extract required information from profile
if (createEntity) {
@claustres
claustres / machine_learning_nutshell.js
Created November 15, 2020 20:53
Machine Learning in a Nutshell
// Select the model to use and its hyperparameters
model = new Model(hyperparameters)
// Split available data into train and test datasets
x_train, y_train, x_test, y_test = split_data(x, y)
// Perform training
model.fit(x_train, y_train)
// Compute model performance over test dataset
model.compute_accuracy(x_test, y_test)
// Use model to predict new data
y = model.predict(x)