The goal of this notebook is to generate a file containing links to all notebooks in my posts directory for easy access from the web.
The link that helped me encode the urls with percent encoding is the following : http://stackoverflow.com/questions/1695183/how-to-percent-encode-url-parameters-in-python.
import os
files = os.listdir(os.getcwd())
files = filter(lambda s: s.endswith('.ipynb'), files)
files
['12 tables.ipynb', '20131030 Jason Martinez A Response to \x93Falling with Helium\x94.ipynb', '20131104 Japan life tables.ipynb', '20131211_KevinHomework.ipynb', '20131227_GenerateRepositoryReadme.ipynb', '20131227_KevinTestNumpy.ipynb', '20140120_SandAvalanches.ipynb', '20140124_AmeliOrthodontiste.ipynb', '20140130_CylinderFlow.ipynb', '20140206_GoogleFlights.ipynb', '20140220_SinesAndRectangles.ipynb', '20140222_DepartmentTrajectories.ipynb', '20140303_KarplusStrongAlgorithm.ipynb', '20140325_2048Game.ipynb', '20140516_CircularGuitarChordDiagrams.ipynb', 'A synthetic guitar sound.ipynb', 'accords de guitare.ipynb', 'Ameli - post et get.ipynb', 'Books 2013.ipynb', 'Comparaison gammes.ipynb', 'Death probabilities.ipynb', 'Demokratie.ipynb', 'Extracting information from a MusicXML file.ipynb', 'Extracting the notes from the melody of MusicXML file.ipynb', 'Fitzhugh-Nagumo .ipynb', 'Guitar sound frequency analysis.ipynb', 'Kanjidic2 & JMDict.ipynb', 'Musical frequencies.ipynb', 'Parsing ameli direct.ipynb', 'Spelling corrector.ipynb', 'Sudoku solver.ipynb', 'V\xe9lib pricing.ipynb', 'WiiBoard data analysis.ipynb', 'xkcd - Dating Pools.ipynb']
import urllib
urllib.quote(files[1])
'20131030%20%20Jason%20Martinez%20A%20Response%20to%20%93Falling%20with%20Helium%94.ipynb'
with open('notebooks_links.md', 'w') as f:
f.write("""# Links to all the notebooks in this folder to be statically viewed on nbviewer\n\n""")
for filename in files:
f.write("[%s](http://nbviewer.ipython.org/urls/raw.github.com/flothesof/posts/master/%s)\n" % (filename, urllib.quote(filename)))