Skip to content

Instantly share code, notes, and snippets.

@blippy
blippy / myplot.f90
Created December 18, 2015 17:17
Simple plot using plplot and Fortran
! compile using the command:
! gfortran `pkg-config --cflags --libs plplot-f95` -o myplot myplot.f90
program myplot
use plplot
implicit none
integer, parameter :: dp=kind(0.0d0)
real(kind=plflt), dimension(3):: x, y
x = [1,2,3]
@blippy
blippy / hard_coded_data.f90
Created December 20, 2015 09:22
Using ALLOCATABLE with hard-coded data
program hard
double precision, allocatable :: a(:)
a = [10 , 12, 13] ! no need to count size beforehand
print *, a
end program hard
@blippy
blippy / yahoo.sh
Last active June 16, 2016 11:27
Download prices from Yahoo
#!/usr/bin/env bash
# dollar exchange rate
url="http://download.finance.yahoo.com/d/quotes.csv?s=USDGBP=X&f=nl1d1t1"
curl -s -L $url > usd.csv &
# download regular tickers
PRE="http://download.finance.yahoo.com/d/quotes.csv?s="
POST="&f=sl1c1p2&e=.csv"
@blippy
blippy / has-charts.ipynb
Created January 19, 2016 10:43
Charts in Haskell
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@blippy
blippy / sharelock-to-hdf5.ipynb
Created January 19, 2016 10:50
Convert SharelockHolmes data to HDF5
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@blippy
blippy / cop.bsh
Created January 20, 2016 11:29
coprocesses in bash using dc as an example
#!/usr/bin/env bash
# example of using coprocesses with dc
coproc mydc { dc; } # run process dc, calling it `mydc'
# define convenience functions for writing/reading to mydc
say () { echo "$1" >&"${mydc[1]}" ; } # echo 1st argument to mydc
get () { read res <&"${mydc[0]}" ; } # set var `res' is response
say "0" # initialise stack with 0
@blippy
blippy / datetime-fortran-1.2.0.patch
Created January 23, 2016 10:24
Arch Linux patch to date-fortran-1.2.0-1
diff -aurN datetime-fortran-1.2.0.pristine/Makefile datetime-fortran-1.2.0.new/Makefile
--- datetime-fortran-1.2.0.pristine/Makefile 2016-01-23 10:12:05.230627072 +0000
+++ datetime-fortran-1.2.0.new/Makefile 2016-01-23 10:12:33.990628308 +0000
@@ -1,12 +1,37 @@
+# To compile a file foo.f90 containing `use datetime_module'
+# issue a command like:
+# gfortran -o foo `pkg-config --cflags datetime-fortran` foo.f90 -ldatetime
+
+# If Arch Linux, assume a package manager, and go to /usr
+ifneq ("$(wildcard /etc/arch-release)","")
@blippy
blippy / mkepics.f90
Created February 4, 2016 12:27
Example of calling netcdf from Fortran
#define PRERR(e) print *, 'e', e
program mkepics
use netcdf
!use maff
use datetime_module
use fates
use yahoo
implicit none
@blippy
blippy / h5print.c
Created February 5, 2016 12:40
Reading data from HDF5
/*
Example of reading data in HDF
Compile using:
gcc h5print.c -lhdf5
Dataset is available in UUENCODED format at:
https://gist.github.com/blippy/82c23d1d0cdb932a4c29
Quite possibly not all resources have been cleaned up
*/
@blippy
blippy / images.ipynb
Created February 28, 2016 11:06
Reducing opacity of an image using python an PIL
x