Skip to content

Instantly share code, notes, and snippets.

@puriney2
puriney2 / insertion_sort.pl
Created June 20, 2013 04:17
PERL: Insertion Sort
# subroutine to implement insertion_sorting
#!/usr/bin/perl -w
sub insertion_sort {
my (@list) = @_;
foreach my $i (1 .. $#list){
my $j = $i;
my $tmp = $list[$i];
while ($j >0 && $tmp < $list[$j-1]){
$list[$j] = $list[$j-1];
$j --;
# OS X termial theme
# tell ls to be colourful
export CLICOLOR=1
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
# tell grep to highlight matches
export GREP_OPTIONS='--color=auto'
# alias
alias ls='ls -FGal'
# set custom bash prompt
#export PS1="\[\033[1;34m\]\!\[\033[0m\] \[\033[1;35m\]\u\[\033[0m\]:\[\033[1;35m\]\W\[\033[0m\]$ "
@puriney2
puriney2 / insertcode.sublime-snippet
Created June 29, 2013 05:21
MARKDOWN: Insert_Codes
<snippet>
<content><![CDATA[
{% highlight ${1:LanguageType} %}
${2:CodesHere}
{% endhighlight %}
$0]]></content>
<tabTrigger>mdcd</tabTrigger>
<scope>text.html.markdown.multimarkdown, text.html.markdown</scope>
</snippet>
@puriney2
puriney2 / DEG finding.R
Created July 5, 2013 00:30
R: MAplot Volcano Plot
#
# Pre-processing Data
#
#exprData <- read.delim("pnas_expression.txt")
# remove final "len"
exprData <- exprData[,-9]
row.names(exprData)<-exprData$ensembl_ID
exprData<-exprData[,-1]
# store gene with valid expression data under ≥ 1 conditions
atLeastOne<-apply(exprData,1,function(row) any (row!=0))
@puriney2
puriney2 / MergeSort.PL
Created July 15, 2013 02:26
PERL: Merge Sort
# http://rosettacode.org/wiki/Sorting_algorithms/Merge_sort#Perl
sub merge_sort {
my @x = @_;
return @x if @x < 2;
my $m = int @x / 2;
my @a = merge_sort(@x[0 .. $m - 1]);
my @b = merge_sort(@x[$m .. $#x]);
for (@x) {
$_ =
!@a ? shift @b :
@puriney2
puriney2 / MergeSortInversionTimes.pl
Created July 15, 2013 02:30
PERL: Inversion counts
our $invTimes =0;
sub mergeSortInversions{
my @x =@_;
return @x if (@x < 2);
my $mid = int (@x/2);
my @a = mergeSortInversions(@x[0 .. $mid - 1]);
my @b = mergeSortInversions(@x[$mid .. $#x]);
for (my $i = 0; $i < @x; $i++) {
if (!@a){