Skip to content

Instantly share code, notes, and snippets.

View glwagner's full-sized avatar

Gregory L. Wagner glwagner

View GitHub Profile
@glwagner
glwagner / .vimrc
Last active March 30, 2017 01:20
My Mac vimrc with a few humble keymappings and color changes to vim syntax groups.
" Line numbers.
set number
" Syntax highlighting.
syntax on
" Convert tab key to insert four spaces.
set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab
" Remove extremely annoying red boxes that appears in
@glwagner
glwagner / linecounter.py
Last active June 3, 2017 04:05
Provides a python function with an associated generator object that rapidly counts line in a specified text file. This method only works in python 3.
def linecount_generator(reader):
"""Yield a generator object for the purpose of counting lines in a file
at speed. See
https://stackoverflow.com/questions/
845058/how-to-get-line-count-cheaply-in-python/27518377#27518377
"""
b = reader(1024*1024)
while b:
yield b
b = reader(1024*1024)
@glwagner
glwagner / julia.vim
Last active June 5, 2017 20:51
Julia syntax file for vim.
" Vim syntax file
" Language: julia
" Maintainer: Carlo Baldassi <carlobaldassi@gmail.com>
" Last Change: 2013 feb 11
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
@glwagner
glwagner / .vimrc_digraphs
Created December 5, 2017 21:48
Code for .vimrcs that defines digraphs for unicode alphabetic subscripts
" Define digraphs for alphabetic subscripts in .vimrc
execute "digraphs ks " . 0x2096
execute "digraphs as " . 0x2090
execute "digraphs es " . 0x2091
execute "digraphs hs " . 0x2095
execute "digraphs is " . 0x1D62
execute "digraphs ks " . 0x2096
execute "digraphs ls " . 0x2097
execute "digraphs ms " . 0x2098
execute "digraphs ns " . 0x2099
@glwagner
glwagner / speedtest_simpleops.jl
Last active December 10, 2017 17:57
A small script to test the speed of simple operations in julia
function broadcastmult!(A, x, F; nloops=1000)
for i = 1:nloops
@. A = x*F
end
end
function regularmult!(A, X, F; nloops=1000)
for i = 1:nloops
@. A = X*F
end
@glwagner
glwagner / .vimrc
Last active March 19, 2018 14:52
My Ubuntu vimrc with a few humble settings and keymappings.
set nocompatible
filetype off
" Set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'JuliaEditorSupport/julia-vim'
@glwagner
glwagner / ocean_ekman_column.jl
Last active August 18, 2021 21:30
Ocean "Ekman column" model with mutable surface flux boundary conditions
using Plots
using Printf
using Oceananigans
using Oceananigans.Units
using Oceananigans.TurbulenceClosures: TKEBasedVerticalDiffusivity
#####
##### Parameters
#####
@glwagner
glwagner / paramanigans.jl
Last active August 24, 2021 11:43
Example parameter file interface for Oceananigans
#=
# This example implements the script
using Oceananigans
using Oceananigans.TurbulenceClosures: CATKEVerticalDiffusivity
using SeawaterPolynomials: TEOS10EquationOfState
gravitational_acceleration = 9.807 # m s⁻²
dissipation_parameter = 2.91
@glwagner
glwagner / .vimrc
Last active March 22, 2022 00:20
My .vimrc for a MacbookPro running OSX 10.14 Mojave
" glw's .vimrc for a MacBook pro
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
@glwagner
glwagner / computational_costs_les.jl
Last active April 29, 2024 14:39
The comptuational cost of ocean large eddy simulation on CPU and GPU
using Oceananigans.Units
using GLMakie
# Wall time per time step in a large eddy simulation with 256^3 resolution.
#
# Numbers provided by Qing Li (HKUST Guangzhou, qingli411.github.io)
#
# Details for the "LESMIP" contained in
# https://github.com/qingli411/A2022_LESMIP/blob/main/notebook/Compare_LES-BF5hWD05WV00.ipynb
#