Skip to content

Instantly share code, notes, and snippets.

View ebelter's full-sized avatar

Eddie Belter ebelter

  • McDonnell Genome Institute at Washington University
  • St. Louis, MO
View GitHub Profile
@ebelter
ebelter / lsf-list-processors.sh
Last active August 29, 2015 14:04
Get the number of cores and processors for machines in an lsf cluster. #tgi #lsf
#!/bin/bash
format="%-12s %-5s %-11s %-10s %-11s %s\n"
printf "$format" host cpus phys_cores virt_cores total_cores lsf_cores
for host in $(lshosts -w | grep wustl | grep -v vm | awk -F. '{print $1}'); do
cpus=$(ssh $host "grep 'physical id' /proc/cpuinfo | sort -u | wc -l")
core_ids=$(ssh $host "grep 'core id' /proc/cpuinfo | sort -u | wc -l")
physical_cores=$(expr $cpus \* $core_ids)
total_cores=$(ssh $host "grep 'proc' /proc/cpuinfo | wc -l")
virtual_cores=$(expr $total_cores \- $physical_cores)
#!/usr/bin/env perl
use strict;
use warnings 'FATAL';
use IO::String;
use Text::CSV;
my $tcga_sample_type_csv = <<TCGA_SAMPLE_TYPE_CSV;
"Code","Definition","Short Letter Code"
#!/usr/bin/env perl
use strict;
use warnings 'FATAL';
use IO::String;
use List::MoreUtils;
use Text::CSV;
my $io = IO::String->new;
@ebelter
ebelter / rename-files-with-month-to-number.pl
Created June 24, 2015 04:12
Rename files that have the month as a string, replacing it with the month as a number.
#!/usr/bin/env perl
use strict;
use warnings;
use List::MoreUtils 'firstidx';
my @months = map { qr/$_/ } (qw/ jan feb mar apr may jun jul aug sep oct nov dec /);
use Data::Dumper;
my %metrics = ( seen => 0, renamed => 0, );
@ebelter
ebelter / perl-class-and-lsf-resource-to-config.rb
Created August 21, 2015 21:21
Given strings containing a perl class name and lsf resource from STDIN, clean up nd write the lsf reource to an appropriately named config file.
#!/usr/bin/env ruby
def filename_for_pkg(filename)
filename.gsub!(/\//, '')
filename.gsub!(/([^A-Z])([A-Z])/,'\1_\2')
File.join('', %w{ gscuser ebelter dev genome genome etc genome spec }, 'lsf_resource_dv2_' + filename.downcase + '.yaml')
end
def cleanup_resource(resource)
resource.chomp!
@ebelter
ebelter / .travis.perl-testing-with-coveralls.yml
Created August 30, 2016 23:18
Travis CI YAML Config for Perl Testing and Coverage with Coveralls
language: perl
perl:
- "5.12"
sudo: false
before_install:
- git clone git://github.com/travis-perl/helpers ~/travis-perl-helpers
- source ~/travis-perl-helpers/init
- build-perl
- perl -V
install:
@ebelter
ebelter / 0_reuse_code.js
Created October 30, 2016 23:17
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ebelter
ebelter / ldap.pl
Created November 3, 2016 01:56
HOWTO Perl Net::LDAP
#!/usr/bin/env perl
use strict;
use warnings 'FATAL';
use Net::LDAP;
use YAML;
my $ldap = Net::LDAP->new('ipa1.gsc.wustl.edu', version => 3);
my $mesg = $ldap->start_tls(verify => 'none');
@ebelter
ebelter / pick-a-thing.rb
Last active November 22, 2016 17:35
This simple ruby script reads in a file and randomly picks a line from it.
#!/usr/bin/env ruby
file = ARGV[0]
if ! file or ! File.exists?(file)
raise "No file!"
end
things = Array.new
fh = File.open(file, 'r')
fh.each_line do |line|
@ebelter
ebelter / GCE Instance Spin Up and Disk Mounting
Last active June 14, 2018 23:45
Google Cloud Mount Disk
### INSTANCE SETUP
# create instance CLI - change the instance nmae and boot disk name as needed
$ NUM=1; export NUM # update for intance number
$ gcloud compute instances create supernova-${NUM} --zone=us-central1-c \
--machine-type=custom-56-372736 --subnet=default --maintenance-policy=MIGRATE \
--service-account=816609412860-compute@developer.gserviceaccount.com --scopes=https://www.googleapis.com/auth/cloud-platform \
--min-cpu-platform=Intel\ Skylake --tags=mgi-accessible,supernova-ui --image=centos-7-v20180507 --image-project=centos-cloud \
--boot-disk-size=200GB --boot-disk-type=pd-standard --boot-disk-device-name=supernova-${NUM}