Skip to content

Instantly share code, notes, and snippets.

@Dulani
Dulani / tryCatch() in R
Last active August 29, 2015 14:08
R: A working example with tryCatch() that takes action on bad data and then throws a warning.
parsedXml <- tryCatch( ParseAlert(xmlParse(alert.xml)),
error = function(e){ warning(paste("Problem encountered parsing alert XML for:",curMsgID,continuing));
warning(geterrmessage());
data.frame(NA)
return(NA)
}
)
@Dulani
Dulani / Reclaim space on a Mac sparse bundle
Last active January 5, 2021 20:52
Reclaim free space in a Mac OS X sparse disk image (sparseimage).
#Original source: http://forums.macrumors.com/showthread.php?t=789978
hdiutil compact /path/to/xxxxx.sparseimage
@Dulani
Dulani / AWS-RHEL
Created September 18, 2014 05:30
Setup R and RStudio on RHEL on AWS
#Setup and launch an RHEL EC2 instance
#Ensure that the security group (firewall) allows access to port 8787
#Login via SSH
#Guide: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html
ssh -i keyfile.pem [email protected]
#Keyfile.pem is the name of your the keyfile you generated with AWS.
#RHEL users are either root or ec2-user
#ec2-11-22-33-44.compute-1.amazonaws.com is the "actuall" public name assigned by AWS
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
.node {
cursor: pointer;
}
.node circle {
fill: #fff;
stroke: #f98415;
stroke-width: 1.5px;
}