Skip to content

Instantly share code, notes, and snippets.

;; prefered order top-right-bottom-left
;; labyrinth x,y indexed at 0 :
;; x
;; +------>
;; |
;; y |
;; v
;;
;; dimension always NxN
@denlab
denlab / remap-altgr-to-alt-and-capslock-to-ctrl.sh
Created May 3, 2011 14:03
Keyboard remapping for easier Emacs
# ------------------------------------------------------------------------------
# A few key remapping on GNU/Linux, for easier Emacs.
#
# Note: You need a querty keyboard in the first place because it removes the alt-gr key.
#
# Replace :
# - capslock by ctrl
# - altgr by alt
#
# To have an alt on the right and an easier ctrl on the left.
@denlab
denlab / gist:973086
Created May 15, 2011 12:00
clojure-twitter on GAE stacktrace
2011-05-15 04:52:31.655
Error for /
java.lang.NoClassDefFoundError: javax.net.ssl.HttpsURLConnection is a restricted class. Please see the Google App Engine developer's guide for more details.
at com.google.appengine.runtime.Request.process-be4965fdf6d33756(Request.java)
at javax.net.ssl.HttpsURLConnection.<clinit>(HttpsURLConnection.java)
at org.apache.http.conn.ssl.SSLSocketFactory.<init>(SSLSocketFactory.java:255)
at org.apache.http.conn.ssl.SSLSocketFactory.<clinit>(SSLSocketFactory.java:166)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:109)
at com.twinql.clojure.http$loading__4414__auto__.invoke(http.clj:1)
@denlab
denlab / gist:1057019
Created June 30, 2011 19:32
vagrant stacktrace
denis@bigbig:~/tmp/vagrant_guide$ vagrant up
/usr/lib/ruby/gems/1.8/gems/virtualbox-0.8.6/lib/virtualbox/com/implementer/ffi.rb:95:in `call_and_check': Error in API call to get_guest_property_notification_patterns: 2147942405 (VirtualBox::Exceptions::FFIException)
from /usr/lib/ruby/gems/1.8/gems/virtualbox-0.8.6/lib/virtualbox/com/implementer/ffi.rb:69:in `call_vtbl_function'
from /usr/lib/ruby/gems/1.8/gems/virtualbox-0.8.6/lib/virtualbox/com/implementer/ffi.rb:36:in `read_property'
from /usr/lib/ruby/gems/1.8/gems/virtualbox-0.8.6/lib/virtualbox/com/abstract_interface.rb:122:in `read_property'
from /usr/lib/ruby/gems/1.8/gems/virtualbox-0.8.6/lib/virtualbox/com/abstract_interface.rb:64:in `guest_property_notification_patterns'
from /usr/lib/ruby/gems/1.8/gems/virtualbox-0.8.6/lib/virtualbox/abstract_model/interface_attributes.rb:93:in `send'
from /usr/lib/ruby/gems/1.8/gems/virtualbox-0.8.6/lib/virtualbox/abstract_model/interface_attributes.rb:93:in `spec_to_proc'
from /usr/lib/ruby/gems/1.8/gems/vi
@denlab
denlab / .stumpwmrc
Created July 3, 2011 13:43
Fabrice's .stumpwmrc commented
;; Hey, Emacs! This is a -*- lisp -*- file!
;;; .stumpwmrc --- my StumpWM Init File
;; Copyright (C) 2008-2010 Fabrice Niessen
;; Time-stamp: <2010-06-21 Mon 14:30 sva on mundaneum>
;; Author: Fabrice Niessen <(concat "fni" at-symbol "mygooglest.com")>
;; Keywords: stumpwm, dotfile, config
;; $Revision: 1933 $
@denlab
denlab / gist:1231894
Created September 21, 2011 12:18
coding-dojo-20110921
(defn primes [n] nil
(reverse
(loop [candidate 2 current n acc []]
(if (zero? current)
acc
(if (every? #(not= 0 (rem candidate %)) acc)
(recur (inc candidate) (dec current) (cons candidate acc))
(recur (inc candidate) current acc))))))
(fact
@denlab
denlab / prime-numbers.clj
Created September 21, 2011 20:56 — forked from ardumont/prime-numbers.clj
Return the list of the n first prime numbers
(ns dojo-coding-0.core
(:use [clojure.test :only [run-tests]])
(:use [midje.sweet])
(:use [clojure.contrib.repl-utils :only [show]])
(:use [clojure.pprint :only [pprint]])
(:use [clojure.walk :only [macroexpand-all]]))
(defn prime-numbers "Return the list of the n first prime numbers"
[n]
(loop [candidate 2 current n primes []]
@denlab
denlab / battle.clj
Created March 12, 2012 11:08
fizzbuzz @ jduchess battle language of march 2012
(ns battle
(:use [midje.sweet]))
(defn fizzbuzz "Fizzbuzz infinite sequence"
[] (let [mult? #(zero? (rem % %2))]
(map #(cond (mult? % 15) "fizzbuzz"
(mult? % 3) "fizz"
(mult? % 5) "buzz"
:else %)
(iterate inc 1))))
@denlab
denlab / gist:2349290
Created April 10, 2012 08:15
hands on clj
(ns ^{:doc "Find one path in a labyrinth"}
hands-on-march-2012.laby
(:use [midje.sweet]
[clojure
[pprint :only [pprint]]
[repl :only [doc]]]))
(unfinished )
;; ------------- rules of the game ------------------
@denlab
denlab / p150.clj
Created May 1, 2012 13:48
4clj #150 (palindrome)
(def g
(letfn [(ng-next [n]
(let [s (str n)
seg2-right (.length s)
seg1-right (quot seg2-right 2)
seg1 (.substring s 0 seg1-right)]
(if (= "" (.replaceAll s "9" ""))
(+ 2 n)
(if (even? seg2-right)
(let [seg1-ng (str (inc (Long/valueOf seg1)))]