Skip to content

Instantly share code, notes, and snippets.

@casimir
casimir / lint.kak.patch
Created February 17, 2018 21:34
sed → awk
diff --git a/rc/base/lint.kak b/rc/base/lint.kak
index 41ad1144..ec390738 100644
--- a/rc/base/lint.kak
+++ b/rc/base/lint.kak
@@ -45,11 +45,11 @@ define-command lint -docstring 'Parse the current buffer with a linter' %{
errors = errors ":" $2 "." $3 "," $2 "." $3 "|" substr($4,2)
# fix case where $5 is not the last field because of extra :s in the message
for (i=5; i<=NF; i++) errors = errors "\\:" $i
- errors = substr(errors, 1, length(errors)-1) " (col " $3 ")"
+ errors = substr(errors, 1, length(errors)) " (col " $3 ")"
@casimir
casimir / 1_output.md
Last active July 23, 2024 18:49
AES-256 examples

Informations

cipher key: 0123456789abcdef0123456789abcdef
IV: 0123456789ABCDEF
padding character: fs (ASCII=34 -> FILE SEPARATOR)

Expected output

secret message: this information is confidential, for your eyes only

Keybase proof

I hereby claim:

  • I am casimir on github.
  • I am casimir (https://keybase.io/casimir) on keybase.
  • I have a public key ASAPxdXYULdwFN-lnQgifwfEU8T-fcB18hSzZLoLumShago

To claim this, I am signing this object:

@casimir
casimir / last_month.py
Created January 18, 2017 10:38
A whole new year
import datetime as dt
def last_month():
last_eom = dt.date.today().replace(day=1) - dt.timedelta(days=1)
to_date = last_eom + dt.timedelta(days=1)
from_date = last_eom.replace(day=1)
return from_date, to_date
# >>> print(dt.date.today())
# 2017-01-18
@casimir
casimir / test_re.sh
Created September 9, 2016 14:21
ERE → BRE
#!/bin/sh
# Check with the examples from the spec (http://vimdoc.sourceforge.net/htmldoc/options.html#modeline)
# ./test_re.sh 'vi:noai:sw=3 ts=6' '/\* vim: set ai tw=75: \*/' '# kak: se ft=sh'
old_parse() {
printf %s\\n "$1" | gsed -r \
-e 's/^(.+\s\w+:\s?(set?)?\s)//' \
-e 's/:?\s[^a-zA-Z0-9_=-]+$//' \
-e 's/:/ /g'
@casimir
casimir / display_colours.py
Created November 4, 2015 13:08
Display ANSI colours
#!/usr/bin/env python2
import sys
terse = "-t" in sys.argv[1:] or "--terse" in sys.argv[1:]
for i in range(2 if terse else 10):
for j in range(30, 38):
for k in range(40, 48):
if terse:
@casimir
casimir / args.go
Last active August 29, 2015 14:27
C entrypoint in Go
package main
/*
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
typedef char** args_t;
args_t args_new(int n) {
@casimir
casimir / .ycmd_make_conf.py
Created May 19, 2015 10:45
Global conf for ycmd that uses existing environnement variables and Makefiles
import os
import re
FlagsNames = {
'c': 'CFLAGS',
'c++': 'CXXFLAGS',
'objective-c': 'OBJCFLAGS',
}
def FlagsFromMakefile(var, flags):

Keybase proof

I hereby claim:

  • I am casimir on github.
  • I am casimir (https://keybase.io/casimir) on keybase.
  • I have a public key whose fingerprint is 860E 0BB2 4112 62EC 2E2D 3266 AA2B A55C 3D2C D1E2

To claim this, I am signing this object: