- この文章と、それに含まれる考察や各サービスへの脆弱性報告などはmala個人の活動であり、所属している企業とは関係ありません。
- 一方で私は、企業が閲覧履歴を収集して何をしたいのか、所属してる企業や他社事例について、ある程度詳しい当事者でもあります。
- 一般論として書けることは書けるが、(業務上知り得た知識で開示されてないものなど)個別具体的なことは書けないこともあり、また観測範囲に偏りがある可能性もあります。
import argparse | |
import os | |
from math import ceil | |
from typing import List | |
try: | |
import requests | |
from requests import HTTPError | |
except ImportError: | |
print("This script uses the `requests` package") |
package sbt | |
package internal | |
package fix | |
import scalafix.v1._ | |
import scala.meta._ | |
class Sbt0_13BuildSyntax extends SyntacticRule("Sbt0_13BuildSyntax") { | |
private def maybeOldSyntax(tree: Tree): Boolean = { | |
tree match { |
What follows is my opinion on how we should tame all of this complexity. Specifically, how can we make it as easy as possible to keep everyone's builds and releases in-sync with the latest Dotty as we approach Scala 3. This is a very complex undertaking with a lot of moving parts. I'm attempting to draw on our experience doing this for prior Scala 2 versions, as well as personal scars from previous upgrade efforts across various Scala versions. In other words, this is a bit of a "lessons learned" phrased as "please everyone do this".
Any projects I have any control over will be following these steps to the best of our ability.
Breaking upgrades are always much easier when you can break them apart into the smallest possible steps. Publishing for the previous Scala 3 release in addition to the latest one is a very easy thing to do (since your library was already building on that version!) and it eases the
import java.util.Set; | |
import java.util.concurrent.ConcurrentHashMap; | |
public class HelloCovariance { | |
public static void main(String[] args) { | |
ConcurrentHashMap<String, String> properties = new ConcurrentHashMap<>(); | |
Set<String> keySet = properties.keySet(); | |
} | |
} |
NOTE: This is an article by Chris Taylor, originally posted on his blog, but the blog was removed at some point. I resurected it from the WayBack Machine without the authors permission, but post it here for posterity's sake, so others may be able to find it.
by Chris Taylor
FEB 10TH, 2013
This note outlines a principled way to meta-programming in Scala. It tries to combine the best ideas from LMS and Scala macros in a minimalistic design.
-
LMS: Types matter. Inputs, outputs and transformations should all be statically typed.
-
Macros: Quotations are ultimately more easy to deal with than implicit-based type-lifting
-
LMS: Some of the most interesting and powerful applications of meta-programming
import scalafix.v1.{Patch, SyntacticDocument, SyntacticRule} | |
import scala.meta.{Name, Term, Transformer, Tree, Type, XtensionQuasiquoteType} | |
class ExpandPolymorphicLambdas extends SyntacticRule("ExpandPolymorphicLambdas") { | |
override def description: String = "Expand kind-projector's syntax for polymorphic lambda values" | |
override def isLinter: Boolean = false | |
private def replacePlaceholder(tree: Term, param: Term.Name): Option[Term] = tree match { | |
case Term.Select(Term.Placeholder(), method) => Some(Term.Select(param, method)) | |
case Term.Select(select @ Term.Select(_, _), method) => |
// unfortunately | |
// opaque type Fix[F[_]] = F[Fix[F]] | |
// won't work (no recursion in opaque type), but this implementation is safe, but scary due to asInstanceOf | |
object FixImpl { | |
type Fix[F[_]] | |
inline def fix[F[_]](f: F[Fix[F]]): Fix[F] = f.asInstanceOf[Fix[F]] | |
inline def unfix[F[_]](f: Fix[F]): F[Fix[F]] = f.asInstanceOf[F[Fix[F]]] | |
} |
object RuntimeUtils { | |
def requestThreadDump: String = { | |
// Get the PID of the current JVM process | |
val selfName = java.lang.management.ManagementFactory.getRuntimeMXBean().getName() | |
val selfPid = selfName.substring(0, selfName.indexOf('@')) | |
// Attach to the VM | |
import com.sun.tools.attach.VirtualMachine | |
import sun.tools.attach.HotSpotVirtualMachine; | |
val vm = VirtualMachine.attach(selfPid); |