Skip to content

Instantly share code, notes, and snippets.

@svanellewee
svanellewee / rot13.el
Last active August 12, 2016 19:57
Rotate13
(require 'ert)
(defun get-13-char (req-char)
(let* ((alphabet "abcdefghijklmnopqrstuvwxyz")
(get-index (lambda (x) (string-match (format "%s" x) alphabet)))
(get-13-after-index (lambda (x) (if x (% (+ x 13) 26) nil)))
(get-13-after-char (lambda (x) (funcall get-13-after-index
(funcall get-index x))))
(get-13-char-after-char (lambda (x) (if (string-match x alphabet) (format "%c" (elt alphabet (funcall get-13-after-char x)) ) " "))))
(funcall get-13-char-after-char (format "%c" req-char))))
@svanellewee
svanellewee / test_contextmanager.py
Created August 8, 2016 12:21
context manager 2 uses.
class Hello(object):
def __init__(self, bla):
print "CONSTRUCT WITH{}".format(bla)
self.bla = bla
def __enter__(self, *args, **kwargs):
print "{{ENTER[{}]".format(self.bla)
return "SOMETHING"
def __exit__(self, *args, **kwargs):
print "done[{}]}}".format(self.bla)
@svanellewee
svanellewee / elnode.org
Created July 23, 2016 21:37
Elnode org-mode mounting

Stephan’s index page

Hello world!

You may have to reload org-more (C-u M-x org-reload)

  ;;; server.el ---  -*- lexical-binding: t -*-
(require 'elnode)
(defvar my-org-dir "/Users/svanellewee/source/orgz")
@svanellewee
svanellewee / margin-calc.el
Last active July 13, 2016 05:48
Calculating margin
;; sve-margin
(defun sve-calc-margin(cost-price margin-price)
(let* ((cost-price (* 1.0 cost-price))
(margin-price (* 1.0 margin-price))
(numerator (- margin-price cost-price))
(denumerator margin-price))
(/ numerator denumerator)))
(sve-comment
(setq margins '(( 200 2000.00)
@svanellewee
svanellewee / malyon mode.el
Created July 10, 2016 13:45
Working with anchor.z8.
; malyon.el --- mode to execute z code files version 3, 5, 8
;; Maintainer: Peter Ilberg <[email protected]>
;; (I am unable to continue supporting malyon.el. Please send me an
;; email if you are interested in taking over the project. Thanks.)
;; Copyright (C) 1999-2011 Peter Ilberg
;; Permission is hereby granted, free of charge, to any person obtaining a
;; copy of this software and associated documentation files (the "Software"),
@svanellewee
svanellewee / sve-hacks.el
Created July 1, 2016 07:35
My first python test hack in elisp!
;;python-testize!
;; test code
(defun sve-setup-test-pytestize(function-to-test)
(with-current-buffer "test"
(erase-buffer)
(insert "test pim_service/loadsheets/tests/test_db.py")
(funcall function-to-test (point))
(let ((return-value (buffer-string)))
(equal return-value "test pim_service.loadsheets.tests.test_db" ))))
@svanellewee
svanellewee / cons.py
Created June 23, 2016 12:24
Cons in Python
def cons(a, b):
return lambda fn : fn(a, b)
a_list = cons("Shane", cons("Monster", cons("Maniac", None)))
print a_list
@svanellewee
svanellewee / minimal-wpdl-mode.el
Created June 18, 2016 21:05
WPDL mode, does syntax highlight, comments no indents.
;; No indentation code:
;; from here : https://www.emacswiki.org/emacs/ModeTutorial
(defvar wpdl-mode-hook nil
"define list of hooks to run")
(defvar wpdl-mode-map
(let ((map (make-keymap)))
(define-key map "\C-j" 'newline-and-indent)
map)
@svanellewee
svanellewee / testorg.org
Last active June 11, 2016 21:52
orgmode is handled by github!!!

Outliner bla

Somet text!

  • some txt
  • yet more with M-enter
  • M-up moves around

Markup

BOLD , italic , verbatim , striketrhough

  • buttels
  • list
  • items
;; tictactoe.el -- play tic tac toe in emacs
(defun start-tictactoe ()
"Start playing the game"
(interactive)
(switch-to-buffer "ticktacktoe")
(tictactoe-mode)
(tictactoe-init)
(tictactoe-print-board)
(tictactoe-swap-players))