| ; in user.clj | |
| (:import [org.slf4j LoggerFactory] | |
| [ch.qos.logback.classic Logger Level] | |
| (defn set-log-level! [level] | |
| (.. (LoggerFactory/getLogger org.slf4j.Logger/ROOT_LOGGER_NAME) | |
| (setLevel (Level/valueOf (.toUpperCase (name level)))))) |
Lisp, the original high-level language, introduced a long list of features common in languages today, including dynamic typing, interpretation, and garbage collection. The original Lisp language is long gone, but it had many imitators, which we call 'dialects' of Lisp. Clojure, introduced in 2007, is the first Lisp dialect to gain wide usage in three decades.
Though Lisp features have been co-opted by many other languages, what still distinguishes Lisp dialects from all other languages is how Lisp dialects translate source code into running programs. In non-Lisp languages, the code translation process has two primary steps:
- lexing (a.k.a. tokenization) and parsing
- code generation (compilation or interpretation)
Nope. No program can be composed 100% of pure code because every program must do I/O work, which is inherently stateful. Most programs also need to carry around some amount of internal state, to one degree or another. The goal of functional programming, then, is to maximize the proportion of pure code to impure code in your program.
What does it mean for data and code to be pure? The short answer is that pure things are immutable, but this is not quite accurate: all pure things are immutable, but not all immutable things are pure. Pure things are not only unmodifiable but also definitional.
| # An implementation of the Maybe monad for Nim | |
| # This implements the traditional operations, bind(called chain) | |
| # and return(called box) as well as a few useful operators for | |
| # cleaning up usage of the monad. Also implemented the functor | |
| # operation fmap(called map) which allows a procedure to be called | |
| # on a wrapped value | |
| type | |
| Maybe*[T] = object | |
| case valid*: bool |
Mosh (mobile shell) is a gift from the Gods(tm). Anyone with spotty internet or wireless connection has suffered the pain of a lost SSH session. Sure, one can fire up screen (or tmux as the kids are using these days), but that's an extra step and you are still using the SSH protocol.
I'm not here to tout the benefits of Mosh, you came here to open it up in your firewall.
- Create the following file as
/etc/firewalld/services/mosh.xml firewall-cmd --add-service=mosh --permanentfirewall-cmd --reload
If you tend to have a lot of sessions (not recommended), you can increase the ports, but the default should be fine for most applications.
| # check swap usage | |
| sysctl vm.swapusage | |
| # disable encrypted swap - SNOW LEOPARD | |
| sudo defaults write /Library/Preferences/com.apple.virtualMemory UseEncryptedSwap -boolean no | |
| # disable encrypted swap - LION | |
| sudo defaults write /Library/Preferences/com.apple.virtualMemory DisableEncryptedSwap -boolean yes | |
| # disable swap |
| ;(use '[clojure.tools.macro :only [symbol-macrolet]]) | |
| (defmacro letrec | |
| "Like let, but the bindings may be mutually recursive, provided that | |
| the heads of all values can be evaluated independently. | |
| This means that functions, lazy sequences, delays and the like can | |
| refer to other bindings regardless of the order in which they | |
| appear in the letrec form." | |
| [bindings & body] |
| # Makefile for building keil projects | |
| KEIL=wine "/home/bliker/.wine/drive_c/Keil/UV4/UV4.exe" | |
| TMP=/tmp/keil.out | |
| NULL=/dev/null | |
| # Will prevent it from exiting even when somehing failied | |
| build: | |
| -@$(KEIL) -j0 -b -o $(TMP) *.uvproj 2> $(NULL); | |
| @cat $(TMP) |
Partials are basically functions that return functions with some already predefined arguments and need some arguments to be completed. Let's say you have a function with several arguments to be set, but you don't want to set the majority of arguments over and over again because you need it more than once.
# my useless function to write something to the dom
function writeSomethingToDom(element, content){
element.append(content);
}
# use the function repeatedly