Skip to content

Instantly share code, notes, and snippets.

package example;
public class A {
public static void main(String[] args) {
var a = new java.util.concurrent.atomic.AtomicLong();
a.compareAndSet(1L, 2L);
}
}
@xuwei-k
xuwei-k / 3
Created February 28, 2024 07:10
$ scala -Xsource:3
Welcome to Scala 2.13.13 -Xsource:3.0.0 (OpenJDK 64-Bit Server VM, Java 1.8.0_392).
Type in expressions for evaluation. Or try :help.
scala> def f = {
| val x: Boolean = ???
|
| x
| && x
| }
@xuwei-k
xuwei-k / gist:2340850
Created April 9, 2012 02:11
chromium Objectice-C++ files ( revision 131318 )
./trunk/src/media/video/capture/mac/video_capture_device_qtkit_mac.mm
./trunk/src/media/video/capture/mac/video_capture_device_mac.mm
./trunk/src/testing/gtest_mac_unittest.mm
./trunk/src/testing/gtest_mac.mm
./trunk/src/testing/platform_test_mac.mm
./trunk/src/gpu/demos/framework/window_mac.mm
./trunk/src/ash/test/test_suite_init.mm
./trunk/src/ash/shell/shell_main_parts_mac.mm
./trunk/src/webkit/tools/test_shell/webwidget_host_mac.mm
./trunk/src/webkit/tools/test_shell/webview_host_mac.mm
package example
import shapeless.nat._
import shapeless.syntax.std.tuple._
object Main{
def main(args: Array[String]): Unit = {
val t = (2, false, "a")
val x = t.updateAtWith(2)(a => a :: Nil)._2
import scala.compiletime.ops.int.*
object MapTupleNExample {
type TupleMapN[T <: NonEmptyTuple, N <: Int, A] =
N < Tuple.Size[T] match {
case true =>
Tuple.Concat[
Tuple.Take[T, N],
A *: Tuple.Drop[T, N + 1]
]
[info] running (fork) org.openjdk.jmh.Main -i 10 -wi 10 -f1
[info] # JMH version: 1.37
[info] # VM version: JDK 23-ea, OpenJDK 64-Bit Server VM, 23-ea+7-481
[info] # VM invoker: /Library/Java/JavaVirtualMachines/jdk-23.jdk/Contents/Home/bin/java
[info] # VM options: <none>
[info] # Blackhole mode: compiler (auto-detected, use -Djmh.blackhole.autoDetect=false to disable)
[info] # Warmup: 10 iterations, 10 s each
[info] # Measurement: 10 iterations, 10 s each
[info] # Timeout: 10 min per iteration
[info] # Threads: 1 thread, will synchronize iterations
@xuwei-k
xuwei-k / Witness.scala
Last active January 27, 2024 10:40
shapeless.Witness match type
import scala.compiletime.ops.string.Length
import scala.compiletime.ops.string.CharAt
import scala.compiletime.ops.string.Substring
import scala.compiletime.ops.int
import scala.compiletime.ops.long
import scala.language.dynamics
object Witness extends Dynamic {
type StringTail[A <: String] = Substring[A, 1, Length[A]]
import play.api.BuiltInComponents
import play.api.Mode
import play.api.mvc._
import play.api.routing._
import play.api.routing.sird._
import play.core.server.PekkoHttpServer
import play.core.server.ServerConfig
object Main {
// 1つのScalaファイルで済むので、
@xuwei-k
xuwei-k / Main.scala
Last active October 5, 2023 22:27
playframework Scala 3 hello world
import play.api.BuiltInComponents
import play.api.Mode
import play.api.mvc._
import play.api.routing._
import play.api.routing.sird._
import play.core.server.NettyServer
import play.core.server.ServerConfig
object Main {
// 1つのScalaファイルで済むので、
@xuwei-k
xuwei-k / Scala-2-12
Last active October 5, 2023 05:29
scala xml pattern match
Welcome to Scala 2.12.18 (OpenJDK 64-Bit Server VM, Java 11.0.20).
Type in expressions for evaluation. Or try :help.
scala> val <a>{ b }</a> = <a></a>
scala.MatchError: <a></a> (of class scala.xml.Elem)
... 55 elided
scala> val <a>{ _ }</a> = <a>c</a>
scala> val <a>{ _* }</a> = <a>c</a>