Skip to content

Instantly share code, notes, and snippets.

@andrewcstewart
andrewcstewart / create_f_parse_ua_string.sql
Created October 28, 2021 20:29
dbt macro to create ua string parsing UDF for Snowflake.
{% macro create_f_parse_ua_string() %}
CREATE OR REPLACE FUNCTION utils.parse_ua_string(ua_string varchar)
RETURNS VARIANT
LANGUAGE JAVASCRIPT
AS $$
/*!
* UAParser.js v0.7.20
* Lightweight JavaScript-based User-Agent string parser
* https://github.com/faisalman/ua-parser-js
*
@andrewcstewart
andrewcstewart / Dockerfile
Created May 8, 2015 22:25
begriffs/postgrest/Dockerfile
FROM centos
RUN yum install -y tar wget postgresql-devel
RUN wget http://bin.begriffs.com/dbapi/heroku/postgrest-0.2.8.0.tar.xz
RUN tar --xz -xvf postgrest-0.2.8.0.tar.xz
RUN mv postgrest-0.2.8.0 /usr/local/bin/postgrest
CMD postgrest --db-host localhost --db-port 5432 \
--db-name my_db --db-user postgres \
--db-pass foobar --db-pool 200 \
@andrewcstewart
andrewcstewart / gist:048623ce2977ac3cad5b
Created June 30, 2014 13:48
Galaxy Conference 2014 - Training Day: Visualization
# Paste URLs and other text here for easier copying
http://cloud1.galaxyproject.org/
@andrewcstewart
andrewcstewart / parse_blast_hits.py
Created December 12, 2013 18:27
Quick routine for parsing hits out of a blast file using BioPython.
import sys
from Bio import SearchIO
# usage: parse_blast_hits.py inputfile > outputfile
file = sys.argv[1]
for qresult in SearchIO.parse(file, 'blast-text'):
print("%s" % (qresult.id))
#!/usr/bin/perl -w
while(<>) {
chomp($_);
my @o = split("",$_);
print join(',',@o) . "\n";
}
@andrewcstewart
andrewcstewart / fcrepo api error
Created August 28, 2013 15:05
fcrepo api error
In [26]: pid = client.getNextPID(u'foo')
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-26-9c5d45fed03c> in <module>()
----> 1 pid = client.getNextPID(u'foo')
/Library/Python/2.7/site-packages/fcrepo/client.pyc in getNextPID(self, namespace, numPIDs, format)
19
20 def getNextPID(self, namespace, numPIDs=1, format=u'text/xml'):
---> 21 request = self.api.getNextPID()
@andrewcstewart
andrewcstewart / Vagrantfile
Created July 12, 2013 01:58
Using yaml to store aws creds in Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
@andrewcstewart
andrewcstewart / qsubscript.pl
Created July 1, 2013 19:22
Run the following script like this: > qsubscript.pl *.qsub
#!/usr/bin/perl -w
for ($job in @ARGV) {
system "qsub $job";
}
@andrewcstewart
andrewcstewart / galaxy error
Created June 11, 2013 16:20
Error returned by Galaxy when running tools imported from tool shed.
/bin/sh: raxmlHPC-PTHREADS-SSE3: command not found
Return error code 127 from command:
['raxmlHPC-PTHREADS-SSE3', '-T 4', '-s /home/galaxy/galaxy-dist/database/files/000/dataset_76.dat', '-n galaxy', '-m GTRGAMMA', '-p 1234567890']
@andrewcstewart
andrewcstewart / A.py
Created May 11, 2013 02:16
How is b.D() smart enough to know that C is b.C(), or rather how is it aware of C when C hasn't been imported into the environment?
import B as b
b.D()