Skip to content

Instantly share code, notes, and snippets.

View matthewrmshin's full-sized avatar
🏠
😃

Matt Shin matthewrmshin

🏠
😃
  • Met Office
  • Exeter, UK
View GitHub Profile
@matthewrmshin
matthewrmshin / UserList.py
Created May 19, 2014 18:40
Trac macro to generate a table of user IDs, their names and their emails
# -*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# UserList.py is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# UserList.py is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@matthewrmshin
matthewrmshin / cylc-suite-100
Created July 18, 2014 14:34
A cylc suite of 100 tasks per cycle
#!jinja2
title=Basic suite
description=A basic suite of 100 tasks per cycle
[cylc]
UTC mode=True # Ignore DST
[scheduling]
initial cycle time=20130101
final cycle time=20130110
#runahead limit=12
[[dependencies]]
@matthewrmshin
matthewrmshin / time the time
Created July 8, 2015 13:13
Proof that time.time is quicker than datetime.datetime.utcnow
#!/usr/bin/python
from datetime import datetime
from time import clock, time
N_TIMES = 100000
def main():
begin = clock()
#!/bin/bash
set -eu
begin() {
for I in $(seq -w 1 30); do
mkdir -p "${HOME}/cylc-run/scan-test-${I}"
cat >"${HOME}/cylc-run/scan-test-${I}/suite.rc" <<'__SUITERC__'
[scheduling]
[[dependencies]]
graph = t1
@matthewrmshin
matthewrmshin / cylc-wrapper
Created June 5, 2013 08:31
This is a wrapper for choosing a version of the `cylc` command based on the variable `CYLC_VERSION`. If the chosen version is not installed, it will use the default version.
#!/bin/bash
if [[ -z ${CYLC_HOME:-} ]]; then
CYLC_HOME_ROOT=${CYLC_HOME_ROOT:-/opt}
CYLC_HOME=$CYLC_HOME_ROOT/cylc
if [[ -n ${CYLC_VERSION:-} && -d $CYLC_HOME_ROOT/cylc-$CYLC_VERSION ]]; then
CYLC_HOME=$CYLC_HOME_ROOT/cylc-$CYLC_VERSION
fi
fi
exec $CYLC_HOME/bin/$(basename $0) "$@"
#!/bin/bash
#-------------------------------------------------------------------------------
# (C) British Crown Copyright 2012-3 Met Office.
#
# This script is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This script is distributed in the hope that it will be useful,
@matthewrmshin
matthewrmshin / my-text-busy-test-t
Last active December 19, 2015 22:39
An attempt to repeat the `/bin/sh: FILE: /bin/bash: bad interpreter: Text file busy` problem. Write 10000 script files and executes them using a pool 10 threads.
#!/usr/bin/python
from glob import glob
from Queue import Queue
import os
import stat
from subprocess import call, PIPE
from threading import Thread
from time import sleep
@matthewrmshin
matthewrmshin / my-text-busy-test-p
Created July 18, 2013 13:51
An attempt to repeat the `/bin/sh: FILE: /bin/bash: bad interpreter: Text file busy` problem. Write 10000 script files and executes them using a pool 10 processes.
#!/usr/bin/python
from glob import glob
from multiprocessing import Pool
import os
import stat
from subprocess import call
from uuid import uuid4
def main():
@matthewrmshin
matthewrmshin / cylc-suite-3000
Last active December 27, 2015 18:29
A Cylc suite of 3000 tasks per cycle
#!jinja2
title=Suite-3000
description=A suite of 3000 tasks per cycle
[cylc]
UTC mode=True # Ignore DST
[scheduling]
initial cycle time=20130101T00Z
final cycle time=20130201T00Z
[[dependencies]]
[[[PT12H]]]
@matthewrmshin
matthewrmshin / test-trim
Created December 4, 2013 21:27
Test correctness of a script trim function.
#!/usr/bin/python
import re
import unittest
def trim(scr_in):
n_ws = 0
scr_out = ""
pre = ""
for line in scr_in.splitlines():