Skip to content

Instantly share code, notes, and snippets.

View cldotdev's full-sized avatar

Chienlung Huang cldotdev

View GitHub Profile
function showLineNumbers() {
/************************************
* Written by Andreas Papadopoulos *
* http://akomaenablog.blogspot.com *
* akoma1blog@yahoo.com *
************************************/
var isIE = navigator.appName.indexOf('Microsoft') != -1;
var preElems = document.getElementsByTagName('pre');
if (preElems.length == 0) return;
###########################################################################################
## Compute N50 values for Assembly Results and Plot their Cumulative Length Distribution ##
###########################################################################################
## Author: Thomas Girke
## Last update: January 28, 2010
## Utilities: Compute N50 and plot cumulative length distribution.
## More details can be found here: http://manuals.bioinformatics.ucr.edu/home/ht-seq#TOC-Analyzing-Assembly-Results
## Overview:
## The N50 is a weighted median statistic such that 50% of the entire assembly
@cldotdev
cldotdev / mtmpfs
Last active December 14, 2015 04:39
Mounting the temperary directories to DRAM. This can reduce writes to SSD.
# Copy these snippets to /etc/fstab
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/spool tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/log tmpfs defaults,noatime,mode=0755 0 0
tmpfs /home/XXX/.cache tmpfs defaults,noatime,mode=0775,uid=YYY,gid=ZZZ 0 0
# XXX = user name
# Get YYY and ZZZ (eg. uid=1000, gid=1000) by typing the command:
# $ id [user name]
# in your bash shell
@cldotdev
cldotdev / DSSPData.py
Created March 17, 2013 14:50
A python script created to allow easy parsing of DSSP files.
# http://openwetware.org/wiki/Wilke:ParseDSSP
import re
class DSSPData:
def __init__(self):
self.num = []
self.resnum = []
self.moltyp = []
@cldotdev
cldotdev / fixname.py
Created April 17, 2013 06:21
fixname - Fix hit name in the blastlist (standalone)
#!/usr/bin/env python3
#
# fixname - Fix hit name in the blastlist
#
# Copyright (C) 2013, Jian-Long Huang
# Licensed under The MIT License
# http://opensource.org/licenses/MIT
#
# Author: Jian-Long Huang (jianlong@ntu.edu.tw)
# Version: 0.1
@cldotdev
cldotdev / sandbox.py
Last active December 17, 2015 12:58
Preventing Python code from importing certain modules
#!/usr/bin/env python
# http://marlonyao.iteye.com/blog/905313
# Usage: $ python sandbox.py <untrusted.py>
_builtins = dict(__builtins__.__dict__)
def _hook_import(name, *args, **kwargs):
restricted_modules = [
'os',
@cldotdev
cldotdev / convert_camelcase.py
Created May 24, 2013 03:27
Convert CamelCase to camel_case
# http://stackoverflow.com/questions/1175208/elegant-python-function-to-convert-camelcase-to-camel-case
def convert(name):
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
@cldotdev
cldotdev / config
Last active February 27, 2019 05:44
bpython configuration
# This is a standard python config file
# Valid values can be True, False, integer numbers, strings
# By default bpython will look for ~/.config/bpython/config or you
# can specify a file with the --config option on the command line
# General section tag
[general]
# Display the autocomplete list as you type (default: True).
# When this is off, you can hit tab to see the suggestions.
@cldotdev
cldotdev / python-function.lang
Last active June 7, 2017 22:04
source-highlight configuration
vardef FUNCTION = '[[:blank:]]([[:alpha:]]|_)[[:word:]]*(?=[[:blank:]]*\()'
function = $FUNCTION
keyword = "and|assert|break|class|continue|def|del|elif|else|except|exec",
"finally|for|global|if|in|is|lambda|not|or|pass",
"print|raise|return|try|while|self"
@cldotdev
cldotdev / set_vs_list
Created June 12, 2013 01:27
Performance of Sets and Lists
# http://stackoverflow.com/questions/2831212/python-sets-vs-lists
>>> import timeit
>>> a = set(range(1000000))
>>> b = range(1000000)
>>> def test_a():
... '9999' in a
...
>>> def test_b():
... '9999' in b