Skip to content

Instantly share code, notes, and snippets.

View matthew-ball's full-sized avatar

Matthew Ball matthew-ball

  • Canberra, ACT, Australia
View GitHub Profile
;; TODO: can achieve this with the chanserv command ...
(defun erc-cmd-OPME ()
"Request ChanServ to put me into operator status."
(let ((chan (erc-default-target))
(nick (erc-current-nick)))
(erc-message "PRIVMSG" (format "chanserv op %s %s" chan nick) nil)))
(defun erc-cmd-DEOPME ()
"Deop me from current channel."
(erc-cmd-DEOP (format "%s" (erc-current-nick))))
(defmacro erc-server-services (service &rest args)
(let ((func (intern (format "erc-cmd-%s" (upcase service))))
(doc (format "Use the service provided.")))
`(defun ,func (&rest args)
,doc
(let* ((command-args (append (list ,service) args))
(command (mapconcat #'identity command-args " ")))
(erc-send-command command)))))
(defun service-commands (service)
(defmacro erc-server-services (service &rest args)
(let ((func (intern (format "erc-cmd-%s" (upcase service))))
(doc (format "Use the service provided.")))
`(defun ,func (&rest args)
,doc
(let* ((command-args (append (list ,service) args))
(command (mapconcat #'identity command-args " ")))
(erc-send-command command)))))
(erc-server-services "chanserv") ;; => erc-cmd-CHANSERV
(defun to-laugh (tape)
(prog ((newtape tape))
label_1
(case (car newtape)
(h (setq newtape (cdr newtape)) (go label_2))
(otherwise (return nil)))
label_2
(case (car newtape)
(a (setq newtape (cdr newtape)) (go label_3))
(otherwise (return nil)))
;;; IMPORTANT: custom inserts
(defun surrounded-by-p (char)
"Returns t if word is surrounded by given char."
(save-excursion
(and (forward-word -1)
(equal char (char-before))
(forward-word 1)
(equal char (char-after)))))
(defun surround-word (char &optional force)
(defmacro propertize-word (property character)
"Define functions for propertizing words with PROPERTY using CHARACTER."
`(defun ,(intern (format "%s-word" property)) (&optional force)
"Insert a PROPERTY character before (and after) an input string."
(interactive "p")
(surround-word ,character force)))
(propertize-word bold ?*) ;; => (bold-word)
(propertize-word italic ?/) ;; => (italic-word)
(propertize-word underline ?_) ;; => (underline-word)
; ---------------------------------------------------------------------
;
; Name: Matthew Ball
; Student Number: 4537508
; Course: COMP2300
; Assignment Number: 2
; Name of this file: cipher.mli
; Lab Group: Thursday, 8:00am - 10:00am
;
;
;; SOURCE: `http://wenshanren.org/?p=298'
(defun edit-current-file-as-root ()
"Edit the file that is associated with the current buffer as root"
(interactive)
(if (buffer-file-name)
(progn
(setq file (concat "/sudo:root@localhost:" (buffer-file-name)))
(find-file file))
(message "Current buffer does not have an associated file.")))
(define-stumpwm-type :password (input prompt)
(let ((history *input-history*)
(arg (argument-pop input))
(fn (symbol-function 'draw-input-bucket)))
(unless arg
(unwind-protect
(setf (symbol-function 'draw-input-bucket)
;; (lambda (screen prompt input &optional errorp)
(lambda (screen prompt input)
(let ((i (copy-structure input)))
(defvar *environment* nil "The environment of an evaluation.")
(defvar *clause* nil "The input clause of an evaluation.")
(defvar *clauses* nil "A list of clauses for evaluation.")
;; a single clause is a list of 3 elements: (setf *clause* '(a (not b) c)) ;; 3-SAT clause (disjunction)
;; each element is either a single variable name (i.e. an atom) or a list containing the symbol `not' followed by a variable name
;; evaluation is with respect to an environment: (setf *environment* '((a . nil) (b . t) (c . t) (d . nil))