Skip to content

Instantly share code, notes, and snippets.

@mokrates
mokrates / simple-archive.sh
Last active April 28, 2023 00:14
self extracting archive with bash
#!/bin/bash
if [ "${1::1}" == "/" ]; then
echo "refusing to archive absolute filenames" >&2
exit 1
fi
while [ "$1" != "" ]; do
if [ -d "$1" ]; then
"$0" "$1"/*
(defun mo-compare-killring ()
"copy some text to kill-ring, set point to the beginning of similar looking text, run this function.
The cursor will be set to the first difference"
(interactive)
(let ((s (current-kill 0 t))
(pos 0))
(while (and (< pos (length s))
(equal (aref s pos) (char-after (point))))
(forward-char)
(incf pos))
@mokrates
mokrates / my-ement.el
Last active September 20, 2023 22:23
allow markdown in ement, allow C-$ to switch compose modes.
;; stuff taken and modified from ement-room.el -- ement-room-compose-org
(require 'ement)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;; revert to fundamental composing
(defun ement-room-compose-fundamental ()
"Activate `fundamental-mode' in current compose buffer.
Configures the buffer appropriately so that saving it will not use any filter"
(defun region-length-kill (pref beg end)
"counts the length/chars in the region.
Prefix argument counts newlines twice for DOS"
(interactive "P\nr")
(let* ((reg-len (- end beg))
(reg-len-dos? (if pref (+ (count-matches "\n" beg end)
reg-len)
reg-len)))
(message (format "Region length: %s" reg-len-dos?))
@mokrates
mokrates / cygwin_update_reminder.md
Created February 7, 2024 18:30
cygwin update reminder

Update reminder for Cygwin

$ cat check_weekly_update.sh
#!/bin/bash

## check if the last cygwin update is less than a week back by
## checking if the newest file in /etc/setup is younger than a week