Skip to content

Instantly share code, notes, and snippets.

@Aivean
Aivean / Glob.scala
Created September 10, 2016 20:26
Glob matcher implementation in Scala
case class State(matches: String => Boolean, optional: Boolean)
def matcher(pattern: String): String => Boolean = {
val states = pattern.split("/").toList.map {
case "**" => State(_ => true, true)
case s =>
val r = s.replaceAllLiterally("*", ".*").r
State(r.unapplySeq(_).isDefined, false)
package com.revjet.raycasting2d;
import java.util.Arrays;
/**
* @author <a href="mailto:ivan.zaytsev@webamg.com">Ivan Zaytsev</a>
* 2018-04-17
*/
public class Lighting {
@Aivean
Aivean / index.d.ts
Last active June 19, 2018 03:25 — forked from subvertallchris/react-shortcuts.d.ts
TypeScript defs for avocode/react-shortcuts
// Type definitions for react-shortcuts v1.6.0
// Project: https://github.com/avocode/react-shortcuts
// Definitions by: Chris Grigg <https://github.com/subvertallchris>
/// <reference types="react"/>
declare namespace ReactShortcuts {
type PlatformType = 'osx' | 'windows' | 'linux' | 'other';
interface Keymap {
@Aivean
Aivean / codex_sorting_test.py
Last active October 25, 2021 06:12
Evaluate Codex accuracy on random list sorting task
import random
import openai, os
from dotenv import load_dotenv
load_dotenv()
OPENAI_KEY = os.getenv('OPENAI_KEY')
openai.api_key = OPENAI_KEY
template = """The sort function can be used to sort a list in ascending, descending or user defined