Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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', () => {