Skip to content

Instantly share code, notes, and snippets.

View laowantong's full-sized avatar

Aristide laowantong

  • Université de Lorraine
  • Metz, France
View GitHub Profile
@GenevieveBuckley
GenevieveBuckley / test_monkeypatch.py
Last active December 12, 2023 18:57
Monkeypatching user input with pytest
from io import StringIO
def double():
x = input("Enter an integer: ")
return int(x) * 2
def adding():
x = float(input('Enter the first number'))
@parente
parente / code_toggle.js
Last active August 6, 2022 21:03
Code toggle for notebooks on nbviewer
// Builds on http://chris-said.io/2016/02/13/how-to-make-polished-jupyter-presentations-with-optional-code-visibility/
// to inject a navbar button in the nbviewer UI and to make the snippet easily reusable across notebooks, i.e.:
// %%html
// <script src="https://cdn.rawgit.com/parente/4c3e6936d0d7a46fd071/raw/2af9515fbe8b776bf8e1c41d8dc662146993bd0d/code_toggle.js"></script>
$(document).ready(function(){
function onShow() {
$('div.input').show(100, function() {
$('div.cell').css({padding: '5px', border: '1px'});
});
}