Skip to content

Instantly share code, notes, and snippets.

View tsak's full-sized avatar
💾

tsak

💾
View GitHub Profile
@tsak
tsak / keypad.go
Last active June 18, 2019 17:14
How long does it take to enter a number for a given keypad
package main
import "fmt"
type Keypad struct {
matrix [3][3]string
}
func NewKeypad(keypad string) Keypad {
var result Keypad
@tsak
tsak / unique_pairs.go
Created June 18, 2019 15:53
Count unique pairs in an array
package main
import (
"fmt"
)
type Pair struct {
x int32
y int32
}
@tsak
tsak / counts.go
Created June 18, 2019 15:57
For each element in 1st array count elements less than or equal to it in 2nd array
package main
import "fmt"
// Complexity O(m * n), possible complexity O(m log n + n log n)
func counts(nums []int32, maxes []int32) []int32 {
var result []int32
for _, m := range maxes {
var c int32 = 0
@tsak
tsak / min_unique.go
Created June 18, 2019 16:03
Minimum unique array sum
package main
import (
"fmt"
)
func contains(m map[int32]struct{}, e int32) bool {
_, ok := m[e]
return ok
}
@tsak
tsak / drawer.as
Last active May 21, 2020 07:17
Source of https://draw.tsak.net/drawer.swf. This draws a painting app and then lets the user draw a painting and send the movements to the backend.
movie 'drawer.swf' {
// flash 6, total frames: 1, frame rate: 12 fps, 640x480 px, compressed
frame 1 {
function pushSave(action) {
_root.picture.pic.push(action + '#');
}
colDist = 10;
colWidth = 8;
@tsak
tsak / viewer.as
Last active May 21, 2020 07:16
Source of https://draw.tsak.net/viewer.swf. This loads a drawings movements and then replays it.
movie 'viewer.swf' {
// flash 6, total frames: 1, frame rate: 12 fps, 640x480 px, compressed
frame 1 {
function isLoaded(ref) {
if (ref.getBytesLoaded() > 20 && ref.getBytesLoaded() == ref.getBytesTotal()) {
return true;
} else {
return false;
}
package ui
import (
"github.com/gdamore/tcell"
"github.com/rivo/tview"
)
// FormHeader represents a header in a form to logically separate groups of elements
type FormHeader struct {
*tview.Box
@tsak
tsak / til-kde-fraction-slash.md
Last active October 23, 2020 14:55
TIL that KDE silently replaces slashes in filenames with a fraction slash

TIL that KDE has a killer feature which will silently replace a / with a (fraction slash) when you go Right Click -> Create New -> Text file...

// See https://api.kde.org/frameworks/kio/html/global_8cpp_source.html#l00141
KIOCORE_EXPORT QString KIO::encodeFileName(const QString &_str)
{
    QString str(_str);
    str.replace(QLatin1Char('/'), QChar(0x2044)); // "Fraction slash"
    return str;
}
@tsak
tsak / hid_apple.conf
Created December 26, 2021 14:05
/etc/modprobe.d/hid_apple.conf
options hid_apple fnmode=2
options hid_apple swap_opt_cmd=1
@tsak
tsak / expanse_palo_alto_networks_spam.txt
Created April 20, 2022 09:26
SPAM: Expanse, a Palo Alto Networks company, searches across the global IPv4 space multiple times per day to identify customers' presences on the Internet.
198.235.24.131 - - [15/Apr/2022:01:52:23 +0000] "GET / HTTP/1.1" 301 162 "-" "Expanse, a Palo Alto Networks company, searches across the global IPv4 space multiple times per day to identify customers' presences on the Internet. If you would like to be excluded from our scans, please send IP addresses/domains to: scaninfo@paloaltonetworks.com"
198.235.24.3 - - [15/Apr/2022:03:45:35 +0000] "GET / HTTP/1.1" 301 162 "-" "Expanse, a Palo Alto Networks company, searches across the global IPv4 space multiple times per day to identify customers' presences on the Internet. If you would like to be excluded from our scans, please send IP addresses/domains to: scaninfo@paloaltonetworks.com"
198.235.24.16 - - [15/Apr/2022:16:39:17 +0000] "GET / HTTP/1.1" 301 162 "-" "Expanse, a Palo Alto Networks company, searches across the global IPv4 space multiple times per day to identify customers' presences on the Internet. If you would like to be excluded from our scans, please send IP addresses/domains to: scaninfo@pa