Skip to content

Instantly share code, notes, and snippets.

@ClementWalter
ClementWalter / utils.test.js
Last active May 4, 2018 09:10
Tests of the utils for the UserStamp mixin
'use strict';
const sinon = require('sinon');
const chai = require('chai');
const sinonChai = require('sinon-chai');
const expect = chai.expect;
chai.use(sinonChai);
const utils = require('../../../server/mixins/utils');
describe('mixins utils', () => {
@ClementWalter
ClementWalter / utils.js
Created May 4, 2018 09:14
Utils for the UserStamp mixin
'use strict';
module.exports = {
addUserInfoToOptions: function(context, unused, next) {
if (!context.req.currentUser || !context.req.currentUser.id) {
const noCurrentUserError = new Error(
'The request does not contain currentUser information'
);
noCurrentUserError.status = 401;
throw noCurrentUserError;
@ClementWalter
ClementWalter / userStamp.js
Created May 4, 2018 09:15
The UserStamp mixin
'use strict';
const utils = require('./utils');
module.exports = function(Model, bootOptions) {
const options = Object.assign(
{
creatorId: 'creatorId',
required: true,
},
bootOptions
@ClementWalter
ClementWalter / pycharm_commands.md
Created November 21, 2018 08:33
Usefull commands and tools for PyCharm

Editor commands

Commande Nom JetBrain
Dupliquer une ligne Duplicate line
Déplacer une ligne Move line down/up
Déplacer un bloc de code automatiquement sélectionné Move statement down/up
Ouvrir un fichier File...
Rechercher dans un fichier / le projet Find in path
@ClementWalter
ClementWalter / eventmaker_bot.py
Created January 6, 2019 20:59
Bot to hach voucher code in eventmaker.io website
import itertools
from unittest.mock import sentinel
import requests
if __name__ == '__main__':
alphabet = ['BD', 'GT', 'IDEAL', 'IDEALWINE', '18', '2018', 'BETTANE', 'DESSAUVE', 'GRAND', 'TASTING', 'ID']
product_len = 1
iterator = itertools.product(*(product_len * [alphabet]))
code = ''.join(next(iterator))
@ClementWalter
ClementWalter / pweave-cheatsheet.md
Last active January 27, 2019 16:40
Getting started with pweave with pycharm

Pweave cheat sheet

Pweave is a dynamic report generation tool for Python. Its lets write texts (Markdown, reST, Latex...) and code in the same file with the code being evaluated and highlighted on purpose.

Key features:

  • Execute python code in the chunks and capture input and output to a report.
  • Rich output and support for IPython magics
  • Use hidden code chunks, i.e. code is executed, but not printed in the output file.
@ClementWalter
ClementWalter / scratch.md
Created February 14, 2019 19:30
Perfect notebook with PyCharm and Pweave

The perfect notebook is not a jupyter one

Jupyter notebook has been heavily reported as the perfect prototyping tool for data scientist. Its main features are:

  • inline code execution
  • easy idea structuring
  • nice displays of pictures and dataframe

This overall flexibility has made it a preferred tool compared to the more rustic iPython command line. However it should not be forgotten that this is no more than an REPL where you can navigate efficiently throughout the history.

@ClementWalter
ClementWalter / main.png
Last active February 23, 2019 11:14
test
main.png

5 things you need to know before starting your machine learning project

and why Jupyter Notebook is not a good tool to do it.

At Sicara, we build machine learning based products for our customers:

  • we build products: we need to develop in a production-ready mindset. Algorithms are served in the cloud, served and updated with APIs, etc.
  • machine learning products: the customer comes with a business need and we have to deliver a satisfying solution as fast as possible.
@ClementWalter
ClementWalter / preprocessing.py
Created September 23, 2020 15:15
Simple image preprocessing
@tf.function(input_signature=(tf.TensorSpec(shape=[None, None, 3], dtype=tf.uint8),))
def preprocessing(input_tensor):
output_tensor = tf.cast(input_tensor, dtype=tf.float32)
output_tensor = tf.image.resize_with_pad(output_tensor, target_height=224, target_width=224)
output_tensor = keras_applications.mobilenet.preprocess_input(output_tensor, data_format="channels_last")
return output_tensor