This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Create two bimodal toy distributions. | |
| ```{r} | |
| a = c(rnorm(100, 5, 2), rnorm(100, 15, 3)) | |
| b = c(rnorm(100, 3, 3), rnorm(100, 14, 1)) | |
| ``` | |
| Set up the graphics environment. | |
| We draw a density curve. `polygon` draws a filled curve, but you don’t seem to be able to control the border width. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Tile LoadFromFile(std::string filename) { | |
| std::ifstream ifs{filename}; | |
| std::string line; | |
| if (not getline(ifs, line)) | |
| throw "foo"; | |
| std::string name{line}; | |
| int numBoxes{}; | |
| int numTargets{}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def find_password(): | |
| import subprocess | |
| import re | |
| cmd = ['security', 'find-internet-password', '-gs', 'github.com'] | |
| pwinfo = subprocess.Popen(cmd, stdout = subprocess.PIPE, | |
| stderr = subprocess.PIPE) | |
| pwline = pwinfo.stderr.read().strip() | |
| return re.sub('password: "(.*)"', '\\1', pwline) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| `<-` = function (body, params) { | |
| vars = all.vars(substitute(params)) | |
| formals = as.pairlist(setNames(replicate(length(vars), quote(expr = )), vars)) | |
| eval.parent(call('function', formals, substitute(body))) | |
| } | |
| sapply(1 : 4, x -> 2 * x) | |
| # 2 4 6 8 | |
| mapply(x ~ y -> x + y, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| `:` = function (a, b) { | |
| if (inherits(a, 'xrange')) | |
| do.call(seq, as.list(c(range(a), by = b))) | |
| else if (inherits(a, 'factor')) | |
| interaction(a, b, sep = ':') | |
| else | |
| structure(seq(a, b), class = 'xrange') | |
| } | |
| print.xrange = function (x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| In [4]: x = [ ['a'], ['b'], ['c'] ] | |
| In [5]: for i in x: | |
| ...: print id(i) | |
| ...: i[0] = 'x' | |
| ...: print id(i) | |
| ...: | |
| 4366314384 | |
| 4366314384 | |
| 4370788648 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| auto&& hello = command<int, std::string>{{ | |
| option{"--count", 1, "number of greetings"}, | |
| option{"--name", "", "the person to greet", flags::required}}, | |
| [](int count, std::string name) { | |
| for (auto i : range(0, count)) | |
| std::cout << "Hello " << name << '\n'; | |
| }}; | |
| int main(int argc, char* argv[]) { | |
| return hello(argc, argv); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mv "$input" "$input.tmp" | |
| samtools view -h "$input.tmp" \ | |
| | awk -F '\t' -v OFS='\t' ' | |
| /^@SQ/ { | |
| $2 = "SN:chr" substr($2, 4, match($2, " ") - 4) | |
| } | |
| /^@/ && !/^@SQ/ { print } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static int binarySearch(int[] arr, int key) { | |
| Object[] arrobj = new Object[arr.length]; | |
| for (int i = 0; i < arr.length; i++) | |
| arrobj[i] = arr[i]; | |
| Object keyobj = key; | |
| return binarySearch(arrobj, keyobj); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Reproduce a name clash with packages | |
| # R 3.0.2 | |
| library(DESeq) # 1.14.0 | |
| x = do.call(rbind, rep(list(read.table(text='1 2\n3 4')), 10)) | |
| m = c('V1', 'V2') | |
| cds = estimateSizeFactors(newCountDataSet(x, m)) | |
| cds1 = estimateDispersions(cds, method='blind', fitType='local') | |
| lp = function () 42 | |
| cds2 = estimateDispersions(cds, method='blind', fitType='local') |