Skip to content

Instantly share code, notes, and snippets.

View mikeivanov's full-sized avatar

Mike Ivanov mikeivanov

View GitHub Profile
@mikeivanov
mikeivanov / paillier.py
Created June 29, 2011 02:32
Pure Python Paillier Homomorphic Cryptosystem
import math
import primes
def invmod(a, p):
'''
http://code.activestate.com/recipes/576737-inverse-modulo-p/
The multiplicitive inverse of a in the integers modulo p.
Return b s.t.
a * b == 1 mod p
'''
(in-package swank)
(setq swank-debugger-hook-orig #'swank-debugger-hook)
(defun swank-debugger-hook (condition hook)
(etypecase condition
(sb-int:simple-stream-error
(progn
(princ "*** Stream error" *error-output*)
(abort)))
@mikeivanov
mikeivanov / contextsearch.el
Created April 2, 2012 14:47
Duckduckgo the term under cursor
(defun search-selection-or-symbol (arg)
(interactive "p")
(unless (and (local-variable-p 'search-prefix-default)
search-prefix-default)
(let* ((mode (symbol-name major-mode))
(name (replace-regexp-in-string "-mode$" "" mode))
(prefix (replace-regexp-in-string "-" " " name)))
(set (make-local-variable 'search-prefix-default) prefix)))
(let* ((prefix (if (= arg 1)
search-prefix-default