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 / 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 / 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 / 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 / keepunique.sh
Created July 2, 2013 23:16
Remove multi-mappers and keep uniquely mapped reads in an alignment file. Now support .sam, .bed, and other tab-delimited files.
#!/bin/bash
column= type= infile= outfile=
while getopts c:i:o: opt; do
case $opt in
c)
column=$OPTARG
;;
i)
infile=$OPTARG
@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 / buggy_defaultdict.py
Created August 7, 2012 23:04
Bug of defaultdict?
import collections
def dfs(G, s, path=[]):
global explored
explored.add(s)
path.append(s)
for v in G[s]:
if v not in path:
path = dfs(G, v, path)
return path
@azalea
azalea / sieveEratosthenes.py
Created January 8, 2012 08:59
Sieve of Eratosthenes
def sieveEratosthenes(limit):
'''Return all primes below the limit'''
numbers = range(3,limit,2)
primes = [2]
while True:
prime = numbers.pop(0)
primes.append(prime)
for n in range(prime**2, limit, 2*prime):
try:
numbers.remove(n)
@azalea
azalea / wineTasting.py
Created December 17, 2011 04:13
Facebook Hacker Cup 2011 Round 1A - Wine Tasting
#!/usr/bin/python
import sys
def fac(n):
'''n!'''
if n==0 or n==1:
return 1
else:
return n*fac(n-1)