Skip to content

Instantly share code, notes, and snippets.

@emmanueltouzery
emmanueltouzery / nvim_plugin_versions.sh
Created September 18, 2022 11:31
nvim_plugin_versions.sh
#! /bin/bash
plugins_and_versions_raw=$(grep -P "use\s+{" "$1" -A2)
AWK=$(cat<<'EOF'
match($0, /['"]([a-zA-Z\-_0-9\.]+\/[a-zA-Z\-_0-9\.]+)['"]/, res) {repo=res[1]}
match($0, /commit[[:space:]]*=[[:space:]]*.([^'"]+)./, res) {commit=res[1]; printf("%s#%s\n", repo, commit)}
EOF
)
plugins_and_versions=$(echo "$plugins_and_versions_raw" | awk "$AWK")
for plugin in $plugins_and_versions; do
vars=(${plugin//#/ })
@emmanueltouzery
emmanueltouzery / filter_log.awk
Created March 18, 2021 15:49
smart log file filter
/^[0-9]{4}-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\.[0-9]{3}/ {
if (contents !~ /(patterns|to|blacklist)/) {
printf("%s", contents)
}
contents = ""
}
{ contents = contents "\n" $0 }
export abstract class A {
static make(input: boolean):A {
return input ? new B() : new C();
}
abstract isB(): this is B;
abstract isC(): this is C;
abstract get(): number;
}
@emmanueltouzery
emmanueltouzery / gist:c2ec59fb18b17ef8c3d48a0fadb7cdfa
Created October 11, 2017 07:10
benchmark run of prelude.ts 0.3.3
> [email protected] benchmarks /home/emmanuel/home/prelude.ts
> tsc && node ./dist/benchmarks/bench.js
Vector.filter x 20,872 ops/sec ±6.94% (69 runs sampled)
Array.filter x 11,289 ops/sec ±5.94% (73 runs sampled)
immList.filter x 28,128 ops/sec ±2.26% (82 runs sampled)
List.filter x 167,296 ops/sec ±0.89% (84 runs sampled)
Fastest is List.filter
Vector.map x 23,437 ops/sec ±1.15% (88 runs sampled)
package com.lecip.core.deployment;
import cz.habarta.typescript.generator.Settings;
import cz.habarta.typescript.generator.TsType;
import cz.habarta.typescript.generator.emitter.EmitterExtension;
import cz.habarta.typescript.generator.emitter.EmitterExtensionFeatures;
import cz.habarta.typescript.generator.emitter.TsBeanModel;
import cz.habarta.typescript.generator.emitter.TsPropertyModel;
public class TypeScriptEqualsHashcodeEmitter extends EmitterExtension {
@emmanueltouzery
emmanueltouzery / focal_lengths.R
Last active August 13, 2017 19:35
little R script to plot the most comonly used focal lengths (the **/* globbing requires zsh)
# exiftool -T -TAG -FocalLength -TAG -Model **/*.jpg > ~/all_focals2.txt
library(readr)
library(ggplot2)
library(dplyr)
focals <-
read_delim('~/all_focals2.txt', delim='\t',
col_names=c("1", "focal", "2", "model"),
col_types=cols_only(focal = col_character(), model = col_character())) %>%
import {Map, List, Seq, Collection} from "immutable";
declare module "immutable" {
module Collection {
interface Collection<K, V> {
concat(valuesOrCollections: Array<V>): Collection<K, V>;
}
}
}
import javaslang.collection.*;
import javaslang.*;
public class SetNarrowTest {
static class PersonBase {
public final String name;
public PersonBase(String name) {
this.name = name;
}