Skip to content

Instantly share code, notes, and snippets.

@drboyer
drboyer / GrADS int Function
Created August 27, 2014 03:50
Truncates a floating point number to an integer in GrADS scripting language.
* Take a floating-point (decimal) number as a parameter and returns a truncated integer (with no decimal point)
function int(num)
outnum = ''
i = 1
while(i < strlen(num))
char = subwrd(num,i)
if(char = '.')
break
else
outnum = outnum%subwrd(num,i)
@drboyer
drboyer / Alternate datetime creation
Created March 12, 2015 18:47
I always forget how to create a datetime object from a formatted string in Python 2.4 (or earlier), where the datetime.strptime method doesn't exist. You can easily make it using the time module though...
# Do imports of these modules somewhere up top
import time, datetime
# timestring is a string containing the time and/or date you want to parse
# format is the time format to parse.
# Reference: https://docs.python.org/2.6/library/datetime.html#strftime-and-strptime-behavior
mydatetime = datetime.datetime(*(time.strptime(timestring, format)[0:6]))
yum install nfs-utils
chkconfig nfs on
service rpcbind start
service nfs start
vi /etc/sysconfig/iptables # (see iptables edit for changes to make)
service iptables restart
# Add entires to /etc/exports
exportfs -a(v)
@drboyer
drboyer / whatsmyips.sh
Last active August 29, 2015 14:25
A script to query the AWS EC2 Metadata Service to display an instance's public and private IP Addresses
#!/bin/bash
privatestr="Private (local) IP:\t"
privatestr+=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)
echo -e $privatestr
publicstr="Public IP:\t\t"
publicstr+=$(curl -s http://169.254.169.254/latest/meta-data/public-ipv4)
echo -e $publicstr
@drboyer
drboyer / Perl-checksyntax.sublime-build
Created September 10, 2015 19:35
Sublime Text Build System: Runs `perl -c` on a Perl script to check its syntax. You can also run the script (though it will not accept any additional arguments) using the Build: Run feature.
{
"selector": "source.perl",
"cmd": ["perl", "-c", "$file"],
"variants": [
{ "name": "Run",
"cmd": ["perl", "$file"]
}
]
install
text
cdrom
lang en_US.UTF-8
keyboard us
network --onboot yes --bootproto dhcp --noipv6
function getDroughtMonStream(outStream) {
var pass = new stream.PassThrough()
req('http://droughtmonitor.unl.edu/data/shapefiles_m/USDM_' + dates.getDroughtMonDate() + '_M.zip')
.pipe(pass)
toJSON(pass).pipe(outStream)
}
@drboyer
drboyer / myfile.csv
Last active July 3, 2018 15:26
Simple PySpark CSV query example
quad val
nw 0
ne 1
se 2
sw 3

Keybase proof

I hereby claim:

  • I am drboyer on github.
  • I am drboyer (https://keybase.io/drboyer) on keybase.
  • I have a public key ASCWxCpccDA_rxa1I9Q8f3E2uwruYyXTBtrGzWMe5kMkTAo

To claim this, I am signing this object: