This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 1 | |
;; the nth element of the series | |
(defn pi-series [n] | |
(/ (* 4 (Math/pow -1 n)) (inc (* 2 n)))) | |
;; lazy sequence giving the individual terms | |
(def pi1 (map #(pi-series %) (iterate inc 0))) | |
;; basically the same, but will use fractions (slower, but nice to look at) | |
(def pi2 (map #(/ (* 4 (expt -1 %)) (+ (* 2 %) 1)) (iterate inc 0))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; all code in this function lifted from the clojure-mode function | |
;;; from clojure-mode.el | |
(defun clojure-font-lock-setup () | |
(interactive) | |
(set (make-local-variable 'lisp-indent-function) | |
'clojure-indent-function) | |
(set (make-local-variable 'lisp-doc-string-elt-property) | |
'clojure-doc-string-elt) | |
(set (make-local-variable 'font-lock-multiline) t) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns daft | |
(meta {:description "The song 'Around the World' by Daft Punk has a deeply repetitive nature, unfortunately the lyrics is oftent stated wrong. | |
The song has 4 verses consisting of 8, 16, 28 and 20 double repetitions of the phrase 'Around the world'. | |
All in all, the song has 72 double repetitions or 144 repetitions of the iconic phrase."})) | |
(def lyrics (repeat "Around the world, around the world")) | |
(defn sing [lyrics] | |
(reduce str | |
(interleave |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
semaphore() { | |
if [ -e $0.pid ]; then | |
PID=$(cat $0.pid) | |
fi | |
if [ $PID ]; then | |
echo $PID on file | |
PIDr=$( ps -ef | awk '{print $2}' | grep ^$PID$ ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
semaphore() { | |
if [ -e $0.pid ]; then | |
PID=$(cat $0.pid) | |
fi | |
if [ $PID ]; then | |
echo $PID on file | |
PIDr=$( ps -ef | awk '{print $2}' | grep ^$PID$ ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use Getopt::Long; | |
use strict; | |
my $src = $ENV{'PWD'}; | |
my $dst = "/cygdrive/c/pictures/export/digital"; | |
my $quality = 75; | |
sub usage { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; first, remove all the crap that looks different from emacs 20.7.1 | |
; luddite mode | |
(cond ((> emacs-major-version 20) | |
(tool-bar-mode -1) ; introduced in emacs 21 | |
(menu-bar-mode -1) | |
(scroll-bar-mode -1) | |
(menu-bar-showhide-fringe-menu-customize-disable) | |
(blink-cursor-mode -1) | |
(windmove-default-keybindings 'meta))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun lisp-enable-paredit-hook () (paredit-mode 1)) | |
(add-hook 'clojure-mode-hook 'lisp-enable-paredit-hook) | |
(defmacro defclojureface (name color desc &optional others) | |
`(defface ,name '((((class color)) (:foreground ,color ,@others))) ,desc :group 'faces)) | |
(defclojureface clojure-parens "DimGrey" "Clojure parens") | |
(defclojureface clojure-braces "#49b2c7" "Clojure braces") | |
(defclojureface clojure-brackets "SteelBlue" "Clojure brackets") | |
(defclojureface clojure-keyword "khaki" "Clojure keywords") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; runs the current buffer in the environment where the file resides. | |
(defvar extention-to-executer-bindings ()) | |
(add-to-list 'extention-to-executer-bindings '("pl" . "perl")) | |
(add-to-list 'extention-to-executer-bindings '("php" . "php -f")) | |
(add-to-list 'extention-to-executer-bindings '("sh" . "bash")) | |
(defun lookup-executer (ext) | |
"find appropriate executer for script" | |
(interactive) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub pirnt {print @_} | |
pirnt "hello world\n" |
OlderNewer