Bla bla… here’s what you have to do: Install nbinteract: pip install nbinteract (even if you have anaconda installed, use pip) Create a git repo for your project – this is important otherwise nbinteract will NOT run Make your repo public Under settings, enable pages (so that you can host your code on your github.io) …
Category: Code
Posts related to code
The Amazing Kronecker Product
Kronecker products can be used to efficiently and easily create 2D and 3D finite difference (and other) operators based on simple 1D operators for derivatives. Here’s a Jupyter notebook that shows you how to do this. You can find this notebook on nbviewer here.
Vector Graphics Plots using Matplotlib in Jupyter
Here’s a neat trick I learned today to display all matplotlib plots as vector format rather than raster in Jupyter notebooks:
Jupyter Notebook doesn’t Automatically Open a Browser on OS X
This issue appears to have showed up on Sierra. Here’s a simple fix: Edit your bash profile (emacs ~/.bash_profile) Add export BROWSER=open Close your shell or source it (source ~/.bash_profile) Things should get back to normal now. Ref: https://github.com/conda/conda/issues/5408
Copying Lists in Python
make sure you don’t fall into the trap of copying pointers in Python: import numpy as np a = np.zeros(2) print(“a = “, a) b = np.zeros(2) print(“b = “, b) b = a # this assignment is simply a pointer copy – b points to the same data pointed to by a a[0]=33.33 # …
How to Highlight Code in Keynote
First install a utility called highlight. It is available through macports and homebrew. sudo port install highlight Now that highlight is installed, you can “apply” it to a file and pipe it to the clipboard: highlight -O rtf MyCode.cpp | pbcopy Now go to Kenote and simply paste from clipboard (or command + v). Highlight …
C++ – Calling Overloaded Operator () from Pointer
Here are three ways to call a C++ classes’ operator () using a pointer: Say you have a C++ class name MyClass that overloads the operator “()”, something along the lines: I use method 2.
Convert Movie or Animation to Animated Gif
mkdir frames ffmpeg -i input -vf scale=320:-1:flags=lanczos,fps=10 frames/ffout%03d.png convert -loop 0 frames/ffout*.png -fuzz 20% -layers OptimizePlus output.gif Thanks to: http://superuser.com/questions/556029/how-do-i-convert-a-video-to-gif-using-ffmpeg-with-reasonable-quality
Fluent udf: Polar to Cartesian Coordinate Transformation
This code illustrates how to convert an analytical solution from polar coordinates to cartesian coordinates and subsequently be used to initialize a fluent simulation. This only works for 2d simulations.
Two-Dimensional Heat Equation in C
Standalone C code that solves the two-dimensional heat equation. Contains a bunch of useful functions for creating 2D arrays in C using pointers.