Skip to content

Instantly share code, notes, and snippets.

View yveszoundi's full-sized avatar

Yves Zoundi yveszoundi

View GitHub Profile
@yveszoundi
yveszoundi / anonymous-gist.el
Created July 23, 2014 22:30
magit clone url
(defun magit-clone-url ()
(interactive)
(let ((git-repo-url (read-from-minibuffer "Enter git repo URL: ")))
(magit-git-command (concat " clone " git-repo-url)
default-directory)))
@yveszoundi
yveszoundi / anonymous-gist.el
Created July 23, 2014 22:33
Eclim Emacs setup
(use-package eclim
:load-path ("/Users/yves/.emacs.d/vendor/emacs-eclim")
:init (setq help-at-pt-display-when-idle t
help-at-pt-timer-delay 0.1
eclimd-executable "~/Tools/eclipse/eclimd"
eclim-executable "~/Tools/eclipse/eclim"
eclimd-default-workspace "~/Documents/workspace/"
eclim-eclipse-dirs '("~/Tools/eclipse"))
@yveszoundi
yveszoundi / levenshtein_prev_row.clj
Created October 27, 2014 22:19
Levenshtein distance with only previous row tracking.
(defn levenshtein-distance [w1 w2]
"Computes the levenshtein distance between two words."
(letfn [(cell-value [ch1 ch2 prev-row acc col-idx]
(min (inc (nth prev-row col-idx))
(inc (last acc))
(+ (nth prev-row (dec col-idx)) (if (= ch1 ch2) 0 1))))]
(loop [row-idx 1, max-rows (inc (count w2)), prev (range (inc (count w1)))]
(if (= row-idx max-rows)
(last prev)
@yveszoundi
yveszoundi / levenshtein_full_matrix.clj
Created October 27, 2014 22:20
Levenshtein distance with a full matrix.
(defn levenshtein-distance [w1 w2]
(letfn [(distance [matrix]
(last (last matrix)))
(make-matrix [word1 word2]
(let [matrix (into []
(for [i (range (inc (count word1)))]
(into [] (take (inc (count word2)) (iterate inc 0)))))]
;; new matrix
(reduce (fn [acc idx]
@yveszoundi
yveszoundi / .astylerc
Created March 24, 2015 19:14
astylerc config
style=java
indent-classes
indent=spaces=8
#brackets=linux
break-closing-brackets
indent-labels
pad-oper
unpad-paren
keep-one-line-blocks
convert-tabs
@yveszoundi
yveszoundi / anonymous-gist.
Created January 3, 2016 23:33
Sample Tern Project Config
{
"libs": ["ecma5"],
"loadEagerly": ["web-app/libs/*.js"],
"plugins": {
"angular": true,
"jquery": true,
"node": {}
}
}
@yveszoundi
yveszoundi / jump-to-file-register.el
Last active January 17, 2016 16:32
ELISP-Jump easily to a file register using completing-read (default, IDO or Helm)
(defun jump-to-file-register ()
"Jump to a file register using completing-read"
(interactive)
(let* ((reg-list (cl-loop for ptr-reg in register-alist
when (eq 'file (first (last ptr-reg)))
collect (concat (char-to-string (car ptr-reg)) "|" (cdr (last ptr-reg)))))
(reg-data (completing-read "Pick file register: " reg-list))
(reg-location (string-to-char (car (split-string reg-data "|")))))
(jump-to-register reg-location)))
@yveszoundi
yveszoundi / eclim-format-region-or-buffer.el
Created June 27, 2016 11:29
Eclim format region or buffer
(defun eclim-java-format ()
"Format the source code of the current java source file."
(interactive)
(let ((positions (if (region-active-p)
(list (region-beginning) (region-end))
(list 0 (1- (point-max))))))
(eclim/execute-command "java_format" "-p" "-f" ("-h" (car positions)) ("-t" (cadr positions) ) "-e")))
@yveszoundi
yveszoundi / newtype.el
Created June 30, 2016 12:37
Eclim New Type
(defun ers/eclim-new-type (new_type_name new_type)
(interactive (list (read-string "Type name: ")
(completing-read "Type: " '("class"
"abstract"
"interface"
"enum"
"@interface"))))
(let* ((prj-dir (or (eclim-project-name) (eclim-project-name (dired-current-directory))))
(eclim-newtype-args (list "java_new"
"-p"
@yveszoundi
yveszoundi / paste-c-net.el
Last active December 20, 2021 22:52
Create a paste at paste-c-net.org
(defvar paste-c-net-url "https://paste.c-net.org/")
(defvar paste-c-net-buffer-name "*paste-c-net*")
(defun paste-c-net--buffer-whole-string (buffer)
"Retrieve the text contents from an HTTP response BUFFER."
(with-current-buffer buffer
(save-restriction
(widen)
(re-search-forward "^$")
(buffer-substring-no-properties (point) (point-max)))))