Skip to content

Instantly share code, notes, and snippets.

import sys
import math
from operator import itemgetter
from functools import partial
def range(start, stop, step=1.):
"""Replacement for built-in range function.
:param start: Starting value.
@vpetro
vpetro / pandoc.css
Created August 29, 2020 15:22 — forked from killercup/pandoc.css
Add this to your Pandoc HTML documents using `--css pandoc.css` to make them look more awesome. (Tested with Markdown and LaTeX.)
/*
* I add this to html files generated with pandoc.
*/
html {
font-size: 100%;
overflow-y: scroll;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
### Keybase proof
I hereby claim:
* I am vpetro on github.
* I am vpetro (https://keybase.io/vpetro) on keybase.
* I have a public key ASADFzzLDKl3z7g-H4KHfdDHzN66rBKgfx9GX2iXs_MSugo
To claim this, I am signing this object:
oss/ensime-server 2.0 λ s
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading global plugins from /Users/petrov/.sbt/0.13/plugins
[info] Loading project definition from /Users/petrov/oss/ensime-server/project
[info] Updating {file:/Users/petrov/oss/ensime-server/project/}ensime-server-build...
[info] Done updating.
[info] Compiling 4 Scala sources to /Users/petrov/oss/ensime-server/project/target/scala-2.10/sbt-0.13/classes...
[error] /Users/petrov/oss/ensime-server/project/EnsimeBuild.scala:202: not found: value ensimeUseTarget
[error] ensimeUseTarget in Compile := Some((artifactPath in (Compile, packageBin)).value),
[error] ^

Keybase proof

I hereby claim:

  • I am vpetro on github.
  • I am vpetro (https://keybase.io/vpetro) on keybase.
  • I have a public key ASAqUs7SS6nGXeG18s3IzwMrym0FoAVARzNW2iPd_d4hRQo

To claim this, I am signing this object:

@vpetro
vpetro / neovim_scala_repl.vim
Created February 28, 2016 00:19
Using :terminal to send code to Scala REPL
function! OpenREPL()
if !exists("g:repl_terminal_id")
botright split enew
let g:repl_terminal_id = termopen("scala")
endif
endfunction
function! PasteScala(lines)
if !exists("g:repl_terminal_id")
call OpenREPL()
@vpetro
vpetro / gist:a1e5a749bffaef1e25b1
Created February 5, 2016 15:45
Scalaz imports
scala> import scalaz.syntax.std.option._
import scalaz.syntax.std.option._
scala> val o: Option[Int] = Some(1)
o: Option[Int] = Some(1)
scala> o.cata(_ => 10, 20)
res0: Int = 10
@vpetro
vpetro / isSorted
Created January 10, 2015 17:04
isSorted
case object P {
def isSorted[A](as: Array[A], ordered:(A,A) => Boolean): Boolean = {
as match {
case _ if as.isEmpty => true
case _ => as.tail.foldLeft((true, as.head)) {
case (t, i) => if (ordered(t._2, i)) (true, i) else (false, i)
}._1
}
}
@vpetro
vpetro / gist:3906995
Created October 17, 2012 17:46
slightly more useful eager csv reader
import csv
class csvreader(object):
def __init__(self, filepath):
self._filename = filepath
reader = csv.DictReader(
open(self._filename, 'rU')
)
self.fieldnames = reader.fieldnames
self._rows = [
@vpetro
vpetro / add1.py
Created August 8, 2012 15:23
add1
def add1(lst, val, n):
start, stop, step = 0, len(lst), 1
cond = n == 0
if n < 0:
start, stop = stop-1, start-1
step = -1
n = abs(n)
for idx in range(start, stop, step):