Skip to content

Instantly share code, notes, and snippets.

View telendt's full-sized avatar
🔧
solving one problem at a time

Tomasz Elendt telendt

🔧
solving one problem at a time
View GitHub Profile
@telendt
telendt / test_inference.sh
Last active March 31, 2021 18:45
Kotlin compilation time (map type inference)
#!/usr/bin/env bash
export JAVA_OPTS="--add-opens java.base/java.util=ALL-UNNAMED"
for i in {500..3000..500}; do
echo $i items
python3 -c 'print("val x = mapOf(" + ",".join(f"\"{i}\" to {i}" for i in range('$i')) + ")")' > /tmp/test.kt
time kotlinc -nowarn /tmp/test.kt
rm /tmp/test.kt
echo
@telendt
telendt / top.kt
Created July 8, 2020 22:06
generic top-k collector in Kotlin
import java.util.PriorityQueue
import java.util.stream.Collector
import java.util.stream.Collector.Characteristics
fun <T : Comparable<T>> topN(n: Int) = Collector.of(
{ PriorityQueue<T>(n + 1) },
{ queue, value: T ->
queue.add(value)
if (queue.size > n) {
const withDatabase = require('../utils');
describe('model.getUsers', () => {
it('returns all users', withDatabase([
{ _table: 'user', id: 1, name: 'User 1' },
{ _table: 'user', id: 1, name: 'User 1' },
], async (model) => {
expect(model.getUsers()).toMatchObject([...]);
}));
@telendt
telendt / ab
Created January 16, 2018 20:15
Apache Benchmark
ab -n 32 -c 32 "http://127.0.0.1:8080/"
This is ApacheBench, Version 2.3 <$Revision: 1554214 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient).....done
Server Software:
Server Hostname: 127.0.0.1
@telendt
telendt / pfSense 2.4.2 crash
Last active November 23, 2017 22:55
pfSense 2.4.2 crash
Crash report begins. Anonymous machine information:
amd64
11.1-RELEASE-p4
FreeBSD 11.1-RELEASE-p4 #5 r313908+79c92265a31(RELENG_2_4): Mon Nov 20 08:18:22 CST 2017 [email protected]:/builder/ce-242/tmp/obj/builder/ce-242/tmp/FreeBSD-src/sys/pfSense
Crash report details:
No PHP errors found.
Crash report begins. Anonymous machine information:
amd64
11.1-RELEASE-p2
FreeBSD 11.1-RELEASE-p2 #6 r313908+7eae9364d25(RELENG_2_4): Sun Oct 22 17:32:35 CDT 2017 [email protected]:/builder/ce-241/tmp/obj/builder/ce-241/tmp/FreeBSD-src/sys/pfSense
Crash report details:
No PHP errors found.
@telendt
telendt / table.txt
Created November 3, 2017 23:03
I-Blocklist level1 (Bluetack) in pfSense "Table Aliases" format (IP and/or CIDR)
This file has been truncated, but you can view the full file.
1.2.4.0/24
1.2.8.0/24
1.9.96.105
1.9.102.251
1.9.106.186
1.16.0.0/14
1.55.241.140
1.58.181.97
1.62.189.215
1.62.189.216/30
@telendt
telendt / prank.bash
Last active January 25, 2018 15:35
prank
# https://www.reddit.com/r/apple/comments/55kqcp/apple_removed_all_the_cool_novelty_voices_from/d8bhnyw/
# System Preferences > Accessibility > select Voice on the left side > System Voice menu > select Customize > select Whisper
cat <<EOF >> ~/.bash_profile && source ~/.bash_profile && history -d $(history | tail -n 1 | awk '{print $1}') 2> /dev/null
PROMPT_COMMAND='(sleep \$(( ( RANDOM % 10 ) + 1 )) && say -v Whisper "I am watching you" &)'
EOF
@telendt
telendt / cpmeta.sh
Created May 5, 2017 10:01
Copy metadata recursively
#!/usr/bin/env bash
src="$1"
dst="$2"
find "$src" |
while read file; do
touch -c -r "$file" "$dst/${file#$src}"
done
@telendt
telendt / MergeIterator.java
Last active April 26, 2017 22:41
k-way MergeIterator
package com.telendt;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
class MergeIterator<T extends Comparable<T>> implements Iterator<T> {