Skip to content

Instantly share code, notes, and snippets.

View gkossakowski's full-sized avatar
🎯
Focusing

Grzegorz Kossakowski gkossakowski

🎯
Focusing
View GitHub Profile

Warsaw AI Breakfast Reel: llm & helicone.ai

llm by Simon Willison

Intro to llm

llm "Hello"
❯ llm --cid 01h8f03gxe1bept7sz4yww2t8t -t qa-steps-to-json ""
Traceback (most recent call last):
File "/opt/homebrew/bin/llm", line 8, in <module>
sys.exit(cli())
^^^^^
File "/opt/homebrew/Cellar/llm/0.8/libexec/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/llm/0.8/libexec/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
@gkossakowski
gkossakowski / A.java
Created November 26, 2018 08:07
Scala vs Java compilation speed experiment
class A1 {
String f1(String x) { return x; }
String f2(String x) { return x; }
.
.
String f100(String x) { return x; }
}
@gkossakowski
gkossakowski / asSeenFrom.md
Last active June 19, 2018 18:27
Understand Scala's core typechecking rules

Scala's "type T in class C as seen from a prefix type S" with examples

Introduction

Recently, I found myself in need to precisely understand Scala's core typechecking rules. I was particulary interested in understanding rules responsible for typechecking signatures of members defined in classes (and all types derived from them). Scala Language Specification (SLS) contains definition of the rules but lacks any examples. The definition of the rules uses mutual recursion and nested switch-like constructs that make it hard to follow. I've written down examples together with explanation how specific set of rules (grouped thematically) is applied. These notes helped me gain confidence that I fully understand Scala's core typechecking algorithm.

As Seen From

Let's quote the Scala spec for As Seen From (ASF) rules numbered for an easier reference:

@gkossakowski
gkossakowski / Interruptible_completer.scala
Last active January 24, 2018 20:56
Definition of an Interruptible completer
sealed trait Result[T]
case class CompletedResult[T](value: T) extends Result[T]
case class IncompleteDependency(dep: Symbol) extends Result[T]
// completer is:
() => Result[T]
@gkossakowski
gkossakowski / completers_awkward_code_pattern.scala
Created December 22, 2016 01:05
An example of an awkward code pattern caused by interruptible completers
val resolvedParents = new util.ArrayList[Type]()
var remainingParents = tmpl.parents
while (remainingParents.nonEmpty) {
val parent = remainingParents.head
val resolved = resolveTypeTree(parent, lookupScope)
// this is awkard and highly repetitive pattern
resolved match {
case CompletedType(tpe) => resolvedParents.add(tpe)
case _: IncompleteDependency | NotFound => return resolved
}
@gkossakowski
gkossakowski / leaky_completer.scala
Created December 22, 2016 00:45
An example of a leaky type completer in Dotty
// Ensure constructor is completed so that any parameter accessors
// which have type trees deriving from its parameters can be
// completed in turn. Note that parent types access such parameter
// accessors, that's why the constructor needs to be completed before
// the parent types are elaborated.
index(constr)
annotate(constr :: params)
symbolOfTree(constr).ensureCompleted()
| Tydzień | Dystans km | Przyrost % | Przyrost 7% = km |
|---------|------------|------------|------------------|
| 1 | 30 | 7% | 2,1 |
| 2 | 32,1 | 7% | 2,24 |
| 5 | 36,75 | 7% | 2,57 |
| 10 | 59 | 7% | 4,13 |
| 15 | 82,77 | 7% | 5,79 |
| 20 | 116 | 7% | 8,12 |
|------------------------------------------------------|
| 25 | 162,82 | 7% | 11,39 |
@gkossakowski
gkossakowski / hs_err_pid21513.log
Last active January 3, 2016 23:49
Instructions how to reproduce JVM8 (8.0-b123) crash.
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x000000010ff99024, pid=21513, tid=20739
#
# JRE version: Java(TM) SE Runtime Environment (8.0-b123) (build 1.8.0-ea-b123)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.0-b65 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# V [libjvm.dylib+0x399024]
#
@gkossakowski
gkossakowski / gist:8521819
Last active January 3, 2016 21:29
Result of running `ant test.suite` on Java 8 (build 1.8.0-ea-b123)
Grzegorzs-MacBook-Pro:scala-master grek (java8-support)$ ant test.suite
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=192M; support was removed in 8.0
CompilerOracle: exclude scala/tools/nsc/transform/patmat/PatternMatching.AnalysisBudget
Buildfile: /Users/grek/scala/scala-master/build.xml
desired.jars.uptodate:
boot:
init.git: