Skip to content

Instantly share code, notes, and snippets.

View azalea's full-sized avatar
😂
Enjoy life

Z azalea

😂
Enjoy life
View GitHub Profile
@azalea
azalea / build_openssl_dylib.sh
Created January 6, 2021 23:06 — forked from tmiz/build_openssl_dylib.sh
Build latest OpenSSL Universal Binary on OSX
#!/bin/bash
OPENSSL_VERSION="1.0.1g"
curl -O http://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
tar -xvzf openssl-$OPENSSL_VERSION.tar.gz
mv openssl-$OPENSSL_VERSION openssl_i386
tar -xvzf openssl-$OPENSSL_VERSION.tar.gz
mv openssl-$OPENSSL_VERSION openssl_x86_64
cd openssl_i386
@azalea
azalea / ProcessEnvPrependPath.nsh
Last active December 8, 2016 14:21
NSIS macro to prepend to system path during install / uninstall process
!macro ProcessEnvPrependPath UN
;; ref: http://stackoverflow.com/a/32384667/1292238
!ifndef ERROR_ENVVAR_NOT_FOUND
!define ERROR_ENVVAR_NOT_FOUND 203
!endif
!if "${NSIS_PTR_SIZE}" <= 4
!include LogicLib.nsh
Function ${UN}ProcessEnvPrependPath ; IN:Path OUT:N/A
System::Store S
Pop $1
!macro ProcessEnvPrependPath UN
;; ref: http://stackoverflow.com/a/32384667/1292238
!ifndef ERROR_ENVVAR_NOT_FOUND
!define ERROR_ENVVAR_NOT_FOUND 203
!endif
!if "${NSIS_PTR_SIZE}" <= 4
!include LogicLib.nsh
Function ${UN}ProcessEnvPrependPath ; IN:Path OUT:N/A
System::Store S
Pop $1
@azalea
azalea / init.el
Created December 3, 2015 20:09
emacs init.el for Windows
;; Requisites: Emacs >= 24
;; INSTALL PACKAGES
;; --------------------------------------
(prefer-coding-system 'utf-8)
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(package-initialize)
@azalea
azalea / getattr.py
Last active August 29, 2015 14:03
Use getattr() to access any attribute of any class instance
# Say I have such classes A, B, C, ..., Y, and Z that do different things,
# and classes AComment, BComment, CComment, ..., YComment and ZComment
# that record comments on instances of class A, B, ..., Y and Z respectively.
# All XComment classes share the same attributes except one property
# that is is dependent on the class the comment is for.
# e.g. AComment has a property 'a' and BComment has a property 'b'.
class A():
def __init__(self):
print 'init an instance of class A'
@azalea
azalea / linux_one_liners.md
Created March 19, 2014 04:23
Linux one-liners

Find the length of each line in the file

while read line; do echo -n "$line" | wc -c; done< f1
@azalea
azalea / spaces2tab.sh
Last active December 8, 2016 14:05
Replace more than one consecutive spaces with tab in files on both Linux and Mac OS X.
#!/bin/sh
# Replace more than one consecutive spaces with tab in files on both Linux and Mac OS X.
# You need to install gnu-sed on Mac OS X for this to work.
# Usage: spaces2tab.sh [file ...]
# See also: http://azaleasays.com/2014/03/07/os-x-sed-does-not-recognize-tab-character/
if [ "$(uname -s)" == "Darwin" ] # If the system is Mac OS X
then
@azalea
azalea / replace_extension.sh
Created March 6, 2014 16:31
Replace file extensions in git repository
#!/bin/sh
oldext=".md"
newext=".markdown"
for file in $(git ls-files | grep ${oldext}\$); do
echo processing $file...
filename="${file%.*}"
git mv $file ${filename}$newext
done
@azalea
azalea / remember_passphrase_cygwin.sh
Last active April 17, 2020 19:00
Remember passphrase in Cygwin
# only ask for my SSH key passphrase once!
# use existing ssh-agent if possible
if [ -f ${HOME}/.ssh-agent ]; then
. ${HOME}/.ssh-agent > /dev/null
fi
if [ -z "$SSH_AGENT_PID" -o -z "`/usr/bin/ps -a|/usr/bin/egrep \"^[ ]+$SSH_AGENT_PID\"`" ]; then
/usr/bin/ssh-agent > ${HOME}/.ssh-agent
. ${HOME}/.ssh-agent > /dev/null
fi
@azalea
azalea / split_then_pairwise_blast.py
Created February 2, 2014 21:14
This code tried to do things the hard way to solve: http://www.biostars.org/p/92205/ by first, the function split_fasta() splits the original fasta file into files containing individual sequence records; second, blast_seq_the_hard_way() iterates over these individual files and feeds their filenames to BLAST. Please note that BLAST can handle mul…
'''This code tried to do things the hard way to solve: http://www.biostars.org/p/92205/ by
first, the function split_fasta() splits the original fasta file into files containing individual sequence records;
second, blast_seq_the_hard_way() iterates over these individual files and feeds their filenames to BLAST.
Please note that BLAST can handle multiple sequences in -query and -subject at the same time, so there is no need
to split the files. This code is just for demonstration purposes.
'''
import os
import re
from Bio.Blast.Applications import NcbiblastpCommandline