Skip to content

Instantly share code, notes, and snippets.

View Puriney's full-sized avatar

Yun YAN Puriney

View GitHub Profile
@Puriney
Puriney / MergeSortInversionTimes.pl
Created July 25, 2013 19:23 — forked from puriney2/MergeSortInversionTimes.pl
PERL: Merge Sort Inverstion Times
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){
@Puriney
Puriney / MergeSort.PL
Created July 25, 2013 19:23 — forked from puriney2/MergeSort.PL
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 :
@Puriney
Puriney / insertcode.sublime-snippet
Created July 25, 2013 19:23 — forked from puriney2/insertcode.sublime-snippet
ST: Snippet 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>
@Puriney
Puriney / OS X termial theme
Created July 25, 2013 19:24 — forked from puriney2/OS X termial theme
BASH: Terminal Theme
# 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\]$ "
@Puriney
Puriney / SimpleSVM.R
Last active December 20, 2015 18:09 — forked from zjf/lazy_man_svm.R
R: SVM
set.seed(1026)
# dummy 2-D data: yi~xi(x1,x2)
x = rbind(cbind(rnorm(50, 1, 0.3), rnorm(50, 2, 0.3)), cbind(rnorm(50, 2, 0.3), rnorm(50, 1, 0.3)))
# [,1] [,2]
# [1,] 1.6565944 1.696906
# [2,] 0.9467358 1.458583
# [3,] 0.9444174 1.513886
# [4,] 0.2480391 2.273355
# [5,] 0.8328066 2.078371
# [6,] 0.9569322 2.174178
@Puriney
Puriney / Coverage.R
Created October 19, 2013 01:35 — forked from CnrLwlss/Coverage.R
R: Bioconductor: converage per base
library(ShortRead)
# Root of .bam filename
sname <- "HG00100.unmapped.ILLUMINA.bwa.GBR.low_coverage.20130415"
# Construct path to file
fname <- file.path("alignments",paste(sname,".bam",sep=""))
# Read alignments
bm <- readGappedAlignments(fname)
%!TEX TS-program = xelatex
\documentclass[12pt]{scrartcl}
% The declaration of the document class:
% The second line here, i.e.
% \documentclass[12pt]{scrartcl}
% is a standard LaTeX document class declaration:
% we say what kind of document we are making in curly brackets,
% and specify any options in square brackets.
@Puriney
Puriney / README.md
Last active August 29, 2015 14:07 — forked from psychemedia/README.md

Minimal R shiny app demonstrating:

  1. how to upload a CSV file into an R/shiny app
  2. how to automatically populate list selectors based on column headers
  3. how to use optional list selectors
  4. how to populate a list selector with column names of numerical columns only
  5. how to use an action button to trigger an event when you're ready to do so

@Puriney
Puriney / README.md
Last active August 29, 2015 14:10 — forked from yihui/README.md

See https://yihui.shinyapps.io/voice for the live demo. Make sure you have turned on your microphone and allow the web browser to have access to it. Credits go to annyang and also to @wch for showing me a minimal Shiny example. You can do four things on the scatterplot using your voice input:

  • say "title something" to change the plot title, e.g. title good morning
  • say "color a color name" to change the color, e.g. color blue
  • say "bigger" or "smaller" to change the size of points
  • say "regression" to add a linear regression line

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application: