Skip to content

Instantly share code, notes, and snippets.

View terrymun's full-sized avatar
🌞
Happy 2024!

Terry Mun terrymun

🌞
Happy 2024!
View GitHub Profile
@terrymun
terrymun / bubblestop.jquery.js
Created August 21, 2017 07:23
Stop touch events from bubbling up in iOS Safari
/*
* Stops touchevent from bubbling up using jQuery
*/
$(document).on('touchstart touchmove touchend', function(e) {
// Example of a parentSelector
// var parentSelector = '#parentElement';
if ($(e.target).closest(parentSelector).length)
e.preventDefault();
});
@terrymun
terrymun / batch_fasta.py
Last active August 20, 2022 08:26
Convert multi-sequence FASTA file into individual files containing n number of FASTA entries
# Load libraries
import os, sys, time, re
from Bio import SeqIO
from itertools import zip_longest
# File path
currentDir = os.path.dirname(os.path.realpath(__file__))
# Configuration
minSeqLength = 80 # Do not include sequences shorter than this
@terrymun
terrymun / interproscan_job.sh
Created November 27, 2016 22:05
Create job scripts iteratively for each FASTA file for InterProScan
#!/bin/bash
shopt -s nullglob
for fasta in $(find `pwd` -type f -name "*.fa" | sort)
do
# Create your jobscript here.
# And the command you should run in your jobscript:
# /path/to/interproscan.sh -i $fasta -dp -iprlookup --goterms --pathways
done
@terrymun
terrymun / interpro_batch_submit.sh
Last active August 18, 2022 09:32
Making batch request to EMBL-EBI InterPro REST service
#!/bin/bash
i=1
waitevery=30
mkdir -p out
for j in $(find `pwd` -type f -name "*.fa")
do
echo "Iteration: $i; File: $j"
filename=$(basename "$j")
@terrymun
terrymun / explode_fasta.py
Last active August 20, 2022 08:23
Exploding multi-sequence FASTA file into individual sequence files
#!/usr/bin/env python3
#=====================================================#
# Script for exploding FASTA files into individual
# FASTA files
#
# Author: Terry Mun <hello@terrymun.com>
# Date: November 9, 2016
#=====================================================#
@terrymun
terrymun / httpd-actual-example.conf
Last active November 16, 2015 00:09
Actual example (single SequenceServer): Apache httpd.conf file for SequenceServer
<VirtualHost *:80>
# Server config
ServerName domain.com
DocumentRoot /var/www/html
# Allow access to URI space
<Directory /var/www/html>
Allow from all
Options -MultiViews
# For Apache >= 2.4
@terrymun
terrymun / httpd-actual-example.conf
Last active November 16, 2015 00:42
Actual example (multiple SequenceServer): Apache httpd.conf file for SequenceServer
<VirtualHost *:80>
# Server config
ServerName lotus.au.dk
DocumentRoot /var/www/html
# Allow access to URI space
<Directory /var/www/html>
Allow from all
Options -MultiViews
# For Apache >= 2.4
@terrymun
terrymun / httpd-example.conf
Last active November 16, 2015 00:09
Template: Apache httpd.conf file for SequenceServer
<VirtualHost *:80>
# Server config
ServerName domain.com
DocumentRoot /var/www/html
# Allow access to URI space
<Directory /var/www/html>
Allow from all
Options -MultiViews
# For Apache >= 2.4
@terrymun
terrymun / SassMeister-input-HTML.html
Created September 4, 2015 20:48
Generated by SassMeister.com.
<div class="m45">m45: 90px tall</div>
<div class="m50">m50: 100px tall</div>
<div class="m55">m55: 110px tall</div>
@terrymun
terrymun / bettermysql-rowCount.php
Last active August 29, 2015 14:27
Count the number of rows returned
<?php
// Assuming that database connection is already open
// Prepare statement
$stmt = $db->prepare("SELECT user, email, country FROM users WHERE id > 1000");
$stmt->execute();
// Get results
if($stmt->rowCount() > 0) {
// One or more rows returned, start iteration through set
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {