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
| package org.jsun.autodiff | |
| //import $ivy.`org.scalameta::scalameta:4.1.0` | |
| import scala.math.{sin, cos} | |
| import scala.meta._ | |
| object Main extends App { | |
| // Let's say we want to differentiate this function: |
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 tdigest() = { | |
| val totalData = ListBuffer[Long]() | |
| var occ = 0 | |
| for (i <- 0 to 20000){ | |
| val seed = Random.nextInt(1000) | |
| if (seed == 0){ | |
| occ += 1 | |
| totalData.append(100L) | |
| } | |
| else{ |
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
| class A | |
| object ExtendedA { | |
| implicit class Aplus(a:A) extends A{ | |
| val uuid = UUID.randomUUID() | |
| println(s"uuid is: $uuid") | |
| private var b = 0 | |
| def setB(i:Int) = b = i | |
| def getB = b | |
| } |
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
| syntax on | |
| set tabstop=4 | |
| set autoindent | |
| set nu | |
| set expandtab | |
| set shiftwidth=4 | |
| let g:tagbar_ctags_bin='/usr/local/bin/ctags' | |
| let g:tagbar_width=40 | |
| noremap <silent> tb :TagbarOpen fj <CR> |
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
| ''' | |
| Manage "My Clippings.txt" from Kindle, split notes into separate files for each book, with custom file name | |
| usage: | |
| python3 kindle.py <option> <clipping> <name_mapping_file> <dir> | |
| <option>: | |
| "list": step1; list all books in the clipping file, ask for name of the notes file, store the book name <--> notes file name mapping in <name_mapping_file> | |
| "notes": step2; create notes for each book |
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
| (* sorting and selecting, benchmark in the end *) | |
| module Sort : sig | |
| val generate : int -> int -> int array | |
| val merge_sort : 'a array -> 'a array | |
| val quick_sort : 'a array -> unit | |
| val rselect : 'a array -> int -> 'a | |
| val dselect : 'a array -> int -> 'a |
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
| (* benchmarking different implementations for Array.filter *) | |
| (* to build: | |
| include _tags file: true:package(core, core_bench), thread | |
| ocamlbuild -use-ocamlfind filter.byte | |
| *) | |
| (* 1. use Array.append *) | |
| module Filter = | |
| struct |
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
| (* matrix module from Algo course *) | |
| (* Author: Xiayun Sun *) | |
| (* Email: xiayun.sun@gmail.com *) | |
| (* Date: 8-JUL-2013 *) | |
| (* all floating number matrix *) | |
| module Matrix : | |
| sig | |
| val slice : 'a array array -> int * int -> int * int -> 'a array array | |
| val merge_matrix : |