Skip to content

Instantly share code, notes, and snippets.

View kanterov's full-sized avatar

Gleb Kanterov kanterov

  • Stockholm, Sweden
View GitHub Profile
@kanterov
kanterov / .vimrc_tabline
Created December 24, 2011 18:15
vim tabline
if exists("+showtabline")
function! MyTabLine()
let s = ''
let t = tabpagenr()
let i = 1
while i <= tabpagenr('$')
let buflist = tabpagebuflist(i)
let winnr = tabpagewinnr(i)
let s .= (i != 1 ? '%#TabLine# | ' : '')
let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#')
@kanterov
kanterov / .vimrc
Created January 3, 2012 08:14
.vimrc
:filetype plugin on
let g:C_AuthorName = 'Kanterov Gleb'
let g:C_AuthorRef = ''
let g:C_Email = '[email protected]'
let g:alternateNoDefaultAlternate = 1
set sidescroll=5
set listchars+=precedes:<,extends:>
set ignorecase
@kanterov
kanterov / javaNamedParameters.java
Created August 4, 2012 16:33
Java Named Parameters
// reply to http://worklez.name/blog/2012/07/18/java-named-parameters/
class Request { }
class ManagerProvider { }
class Job {
Job(ManagerProvider provider, Request request, OutputStream out) { }
}
class JobBuilder {
@kanterov
kanterov / gist:4097473
Created November 17, 2012 16:42
derivative in scala
// in scala
// https://twitter.com/my7truth/status/269825587797958656
// 79
def p1(p: Seq[Int]) = p.zipWithIndex.map{case (x,y) => x * (p.size - y - 1)} dropRight 1
// 86
def p2(p: Seq[Int]) = p.zipWithIndex.map(x => x._1 * (p.size - x._2 - 1)) dropRight 1
// 83
object SourceMap extends Controller {
implicit val ec = ExecutionContext.global
def at(prefix: String, path: String) = Action {
val fileOpt = Play.getExistingFile(s"../$prefix/" + path)
fileOpt.map {
case _ if !Play.isDev => Forbidden
case file if file.isDirectory => NotFound
case file if !file.exists() => NotFound
@kanterov
kanterov / HList.purs
Created January 27, 2015 15:22
HList experiment
module Data.HList
( (.:.)
, head
, tail
) where
newtype HList a = HList a
infixr 5 .:.
@kanterov
kanterov / gist:c7eab5c9f5d4604d15ea
Last active August 29, 2015 14:26
scalaz-stream pipeIn
// doesn't print "release" unless you remove `.pipeIn(process1.id[A])`,
// internally `pipeIn` uses `takeWhile` which uses `pipe`, it breaks print too
def printSink[A] = io.stdOutLines.contramap[A](_.toString).pipeIn(process1.id[A])
// simplier case doesn't work too:
// sink.lift[Task, A](x => Task.delay(())).pipe(process1.id[A => Task[Unit]])
def disposableThing: Process[Task, Unit] = {
val acquire = Task.delay {println("acquire")}
val release = Task.delay {println("release")}
@kanterov
kanterov / AmbiguousJoinTests.scala
Last active September 27, 2017 08:52
Different kinds of corner cases with join in frameless
package frameless
import shapeless.Witness
class AmbiguousJoinTests extends TypedDatasetSuite {
def col[T, A](column: Witness.Lt[Symbol])(
implicit
exists: TypedColumn.Exists[T, column.T, A],
encoder: TypedEncoder[A]): TypedColumn[T, A] = {