Skip to content

Instantly share code, notes, and snippets.

View AlejandroCatalina's full-sized avatar

Alejandro Catalina AlejandroCatalina

View GitHub Profile
@AlejandroCatalina
AlejandroCatalina / emacs
Created March 19, 2018 18:08
Script to put under /etc/init.d/emacs to start emacs in daemon mode at startup time.
#! /bin/sh
### BEGIN INIT INFO
# Provides: emacs
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Description: This file should be placed in /etc/init.d.
### END INIT INFO
#change this
#USERNAME=YourUserName
;;; github-theme.el --- Github color theme for GNU Emacs 24
;; Copyright (C) 2011 Dudley Flanders <dudley@steambone.org>
;; Author: Dudley Flanders
;; Adapted-By: Yesudeep Mangalapilly
;; Adapted-By: Joshua Timberman
;; Adapted-By: Alejandro Catalina
;; Keywords: github color theme
;; URL original: http://github.com/dudleyf/color-theme-github
(ns ml-clj.lasso
(:require [clojure.algo.generic.math-functions :as math]
[clojure.core.matrix :as m]
[clojure.core.matrix.operators :as M]))
(defn max-lambda
[Y X]
(second
(apply max-key second
(map-indexed vector
;;
;; linking and capturing
;;
(defun elfeed-link-title (entry)
"Copy the entry title and URL as org link to the clipboard."
(interactive)
(let* ((link (elfeed-entry-link entry))
(title (elfeed-entry-title entry))
(titlelink (concat "[[" link "][" title "]]")))
#(take % ((fn rfib [a b]
(lazy-seq (cons a (rfib b (+ a b)))))
1 1))
(spaceline-define-segment evil-state-custom (upcase (format "%S" evil-state)))
;; Install it along the other segments, place it wherever you want
(spaceline-install
'(((persp-name workspace-number window-number evil-state-custom)
:fallback evil-state
:separator "|"
:face highlight-face)
anzu
auto-compile
@AlejandroCatalina
AlejandroCatalina / dijkstra.clj
Created November 23, 2015 11:29 — forked from valpackett/dijkstra.clj
Dijkstra's algorithm in Clojure
; http://www.algolist.com/Dijkstra's_algorithm
(defn dijkstra [g src]
(loop [dsts (assoc (zipmap (keys g) (repeat nil)) src 0)
curr src
unvi (apply hash-set (keys g))]
(if (empty? unvi)
dsts
(let [unvi (disj unvi curr)
nextn (first (sort-by #(% dsts) unvi))
@AlejandroCatalina
AlejandroCatalina / quicksortlisp
Created November 13, 2015 10:31
Elegant quicksort lisp version
(defun quicksort-compr (l)
(when l
(pattern (p . xs) l
(append (quicksort-compr (@ x x xs (< x p))) (list p)
(quicksort-compr (@ x x xs (>= x p)))))))
;; Using https://gist.github.com/AlejandroCatalina/7faaaee84cbda9884600
@AlejandroCatalina
AlejandroCatalina / listcomprehension
Created November 13, 2015 10:28
Lists comprehensions macro for lisp, and a pattern-matching macro
(defmacro @ (value bind list test)
(let ((newlist (gensym)))
`(let ((,newlist nil))
(dolist (,bind ,list)
(when ,test
(push ,value ,newlist)))
(nreverse ,newlist))))
(defmacro pattern (bind l &rest body)
`(destructuring-bind ,bind ,l