Skip to content

Instantly share code, notes, and snippets.

View anler's full-sized avatar

Anler anler

View GitHub Profile
@anler
anler / settings.json
Created January 25, 2023 10:00
My VSCode Settings
{
"editor.linkedEditing": true,
"dotnetAcquisitionExtension.enableTelemetry": false,
"files.saveConflictResolution": "overwriteFileOnDisk",
"editor.accessibilitySupport": "off",
"typescript.updateImportsOnFileMove.enabled": "always",
"workbench.preferredDarkColorTheme": "Ayu Dark",
"window.autoDetectColorScheme": true,
"security.workspace.trust.untrustedFiles": "open",
"[json]": {
@anler
anler / types.ts
Created December 12, 2020 22:11 — forked from ClickerMonkey/types.ts
Typescript Helper Types
// when T is any|unknown, Y is returned, otherwise N
type IsAnyUnknown<T, Y, N> = unknown extends T ? Y : N;
// when T is never, Y is returned, otherwise N
type IsNever<T, Y = true, N = false> = [T] extends [never] ? Y : N;
// empty object
type EmptyObject = { [key: string]: never };
@anler
anler / types.ts
Created December 12, 2020 22:11 — forked from ClickerMonkey/types.ts
Typescript Helper Types
// when T is any|unknown, Y is returned, otherwise N
type IsAnyUnknown<T, Y, N> = unknown extends T ? Y : N;
// when T is never, Y is returned, otherwise N
type IsNever<T, Y = true, N = false> = [T] extends [never] ? Y : N;
// empty object
type EmptyObject = { [key: string]: never };
@anler
anler / steve-yegge-google-platform-rant.md
Created July 9, 2020 13:37 — forked from kislayverma/steve-yegge-google-platform-rant.md
A copy (for posterity) of Steve Yegge's internal memo in Google about what platforms are and how Amazon learnt to build them

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't really have SREs and they make engineers pretty much do everything,

@anler
anler / smart-caps-lock.md
Created March 1, 2020 12:59 — forked from tanyuan/smart-caps-lock.md
Smart Caps Lock: Remap Caps Lock to Control AND Escape

Smart Caps Lock: Remap to Control AND Escape (Linux, Mac, Windows)

Caps Lock 變成智慧的 Control 以及 Escape

  • 單獨輕按一下就是 Escape
  • 若按下時同時按著其他鍵,就會是 Control

這應該是 Vim 和 Emacs 的最佳解了!(Emacs? Bash 的快捷鍵就是 Emacs 系列的)

  • Send Escape if you tap Caps Lock alone.
@anler
anler / with-local-redefs.clj
Created March 12, 2018 17:53 — forked from gfredericks/with-local-redefs.clj
thread-local version of with-redefs
(defn with-local-redefs-fn
[a-var its-new-value func]
(cast clojure.lang.IFn @a-var)
(alter-meta! a-var
(fn [m]
(if (::scope-count m)
(update-in m [::scope-count] inc)
(assoc m
::scope-count 1
::thread-local-var (doto (clojure.lang.Var/create @a-var)

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@scala.annotation.implicitNotFound("${EncryptKeyType} encrypted messages cannot be decrypted with ${DecryptKeyType}")
trait CanDecrypt[DecryptKeyType, EncryptKeyType]
object CanDecrypt {
implicit val pkOnSk = new CanDecrypt[PK, SK] {}
implicit val skOnPk = new CanDecrypt[SK, PK] {}
}
sealed trait PK // public key type
sealed trait SK // private key type
final case class Key [KeyType](jkey: java.security.Key)
import cats._, cats.data._, cats.syntax._, cats.implicits._
implicit def readerTMonadError[F[_], I, E](implicit AE: ApplicativeError[ReaderT[F, I, ?], E], M: FlatMap[ReaderT[F, I, ?]]) =
new MonadError[ReaderT[F, I, ?], E] {
def pure[A](x: A) = AE.pure(x)
def handleErrorWith[A](fa: ReaderT[F, I, A])(f: E => ReaderT[F, I, A]) =
AE.handleErrorWith(fa)(f)
def raiseError[A](e: E) =
import Control.Monad.IO.Class
import Data.Functor.Identity
getline :: MonadIO m => m String
getline = (liftIO getLine) >> return "some fake input\n"
main :: IO ()
main = do