Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View cgt's full-sized avatar

Christoffer Gamrath cgt

  • Denmark
View GitHub Profile
@cgt
cgt / proof.md
Created January 28, 2024 07:58
Keyoxide proof

aspe:keyoxide.org:FMTYUMDHOY4EISJ5A7G6PFK7CU

@cgt
cgt / errorparams.md
Created May 13, 2023 08:11
Error parameter in extracted functions
func foo(r io.Reader) error {
    data, err := io.ReadAll(r)
    if err != nil {
        return err
    }
    _, err = fmt.Print(data)
}
@cgt
cgt / hnairemover.user.js
Last active May 6, 2023 03:51
Remove AI news from HN
// ==UserScript==
// @name HN AI remover
// @version 1
// @grant none
// @match https://news.ycombinator.com/
// @match https://news.ycombinator.com/news
// @match https://news.ycombinator.com/?p=*
// @match https://news.ycombinator.com/news?p=*
// ==/UserScript==
@cgt
cgt / pom.xml
Created August 14, 2020 20:07
Snippet of my Maven config for pitest + Kotlin
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.4.5</version>
<configuration>
<avoidCallsTo>
<avoidCallsTo>kotlin.jvm.internal.Intrinsics</avoidCallsTo>
</avoidCallsTo>
<excludedMethods>
<excludedMethod>apply</excludedMethod>
@cgt
cgt / weechat
Created August 1, 2018 10:27
rc.d/weechat
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: weechat
# REQUIRE: NETWORK
# KEYWORD: shutdown
. /etc/rc.subr
package main
import (
"fmt"
"net/http"
"net/url"
)
func request(url_ string) {
req, err := http.NewRequest("HEAD", url_, nil)
@cgt
cgt / blog.cloudflare.com.css
Created February 1, 2017 12:55
user styles
@namespace url(http://www.w3.org/1999/xhtml);
/* Remove <aside> sidebar and expand content */
@-moz-document domain("blog.cloudflare.com") {
aside.sidebar {
display: none;
}
section.primary-content {
float: initial;
@cgt
cgt / churchchecker.py
Created March 19, 2015 20:31
Church infobox URL length report generator
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
An incomplete sample script.
This is not a complete bot; rather, it is a template from which simple
bots can be made. You can rename it to mybot.py, then edit it in
whatever way you want.
The following parameters are supported:
@cgt
cgt / lp.py
Created March 16, 2015 10:10
longest palindrome
#!/usr/bin/env python3
def lp(x, i=None, j=None, cache={}):
if i is None or j is None:
i = 0
j = len(x)-1
if (i, j) in cache.keys():
return cache[(i, j)]
@cgt
cgt / lcslen.py
Last active April 1, 2021 21:44
Iterative and recursive implementations of LCS-Length() in Python
#!/usr/bin/env python3
def LCS_length(X, Y):
m = len(X)
n = len(Y)
c = [[0 for j in range(n+1)] for i in range(m+1)]
for i in range(0, m):
for j in range(0, n):