``` {.py file=hello.py}
print("Hello, World!")
```
```py
print("Hello, Amsterdam!")
```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This takes a C2t3 from example 3.1 in CGAL manual on meshes. | |
The `vertices_begin()` method returns non-const iterator, so | |
we pass non-const reference. This should be fixed somehow. | |
*/ | |
void write_to_obj(std::ostream &out, C2t3 &mesh) | |
{ | |
// create a map from Vertex_handle to the vertex index as it is | |
// written into the OBJ file. Remember that OBJ indices start from 1. | |
std::map<C2t3::Vertex_handle, unsigned> vertex_map; | |
unsigned count = 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Copyright 2018 Johan Hidding | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#| Problem statement | |
| ================= | |
| | |
| You, a lab assistant in a remote mountain facility, accidentally release a | |
| horde of zombies. You, the lab technician, professor and student intern need | |
| to flee the laboratory across a rope bridge. The bridge carries a maximum of | |
| two people, it's dark and you only managed to grab one lantern. | |
| | |
| Each of you takes a different time to cross the bridge: | |
| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def something_dangerous(x): | |
print("computing reciprocal of", x) | |
return 1 / x | |
try: | |
for x in [2, 1, 0, -1]: | |
print("1/{} = {}".format(x, something_dangerous(x))) | |
except ArithmeticError as error: | |
print("Something went terribly wrong:", error) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print("\033[47;30m Netherlands\033[48;2;0;174;239;37m▌\033[38;2;255;255;255me\u20d2Science\u20d2\033[37m▐\033[47;30mcenter \033[m") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export WORKON_PATH="${HOME}/.local/share/workon" | |
function workon() { | |
source ${WORKON_PATH}/${1}/bin/activate | |
} | |
function create-python3-env() { | |
py3-virtualenv ${WORKON_PATH}/${1} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sed_program = """# usage: sed -f rot13.sed <filename> | |
y/abcdefghijklmnopqrstuvwxyz/nopqrstuvwxyzabcdefghijklm/ | |
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/NOPQRSTUVWXYZABCDEFGHIJKLM/ | |
""" | |
message = "Vf gurer nalobql BHG gurer?" | |
with DockerContainer('busybox') as c: | |
c.put_archive( | |
Archive('w') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DockerContainer(object): | |
"""Easy interface to Docker API. | |
This class encapsulates a part of the Docker API, with the goal | |
of making it easier to start a container, add some files, run a | |
few scripts, read the output, and then remove the container | |
again. | |
The object is a context manager for the created Docker container, | |
in that it starts the container upon entry and exterminates the |