Skip to content

Instantly share code, notes, and snippets.

@html
html / cyr-to-lat-russian-transliteration.lisp
Created November 3, 2012 12:08
Transliteration from Cyrillic to Latin in Common Lisp of Russian symbols/Транслитерация с кирилицы в латиницу на Common Lisp русских символов
(defun transliterate-cyr-to-lat-russian (text)
; Taken from http://cl-cookbook.sourceforge.net/strings.html
(defun replace-all (string part replacement &key (test #'char=))
"Returns a new string in which all the occurences of the part
is replaced with replacement."
(with-output-to-string (out)
(loop with part-length = (length part)
for old-pos = 0 then (+ pos part-length)
for pos = (search part string
:start2 old-pos
@html
html / php-functions-for-cl.lisp
Last active December 19, 2018 19:46
Php utility functions for common lisp
(ql:quickload :ironclad)
(ql:quickload :cl-ppcre)
(ql:quickload :arnesi)
(ql:quickload :cl-prevalence)
(ql:quickload :closure-html)
(ql:quickload :cxml)
(ql:quickload :split-sequence)
(defun nl2br (text)
(cl-ppcre:regex-replace-all #\newline text "<br/>"))
@html
html / enable-disable-selection.js
Created July 7, 2012 11:36
Enable/disable selection in jQuery
// Stolen from jquery-ui and customized
(function($){
$.fn.disableSelection = function(){
return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
".disableSelection", function( event ) {
event.preventDefault();
});
};
$.fn.enableSelection = function(){
@html
html / oz-parsing-util.lisp
Last active November 8, 2017 04:47
Utilities I use for parsing, it depends on "php funcs for cl" https://gist.github.com/html/4707958
(defvar *cache-dir* '(:relative "cache"))
(defvar *cache-enabled-p* nil)
(defvar *drakma-request-max-tries* nil) ;
(defvar *character-for-wrong-utf-8-chars* #\@)
; V5
(defun drakma-request (&rest args)
"Gets url contents using drakma:http-request.
Tries several times to do it on error.
@html
html / countries-translation-code.lisp
Created May 13, 2016 00:25
All countries in English and Russian parsing
(defvar *countries* (list "Bangladesh" "Belgium" "Burkina Faso" "Bulgaria" "Bosnia and Herzegovina" "Brunei" "Bolivia" "Japan" "Burundi" "Benin" "Bhutan" "Jamaica" "Botswana" "Brazil" "The Bahamas" "Belarus" "Belize" "Russia" "Rwanda" "Republic of Serbia" "Lithuania" "Luxembourg" "Liberia" "Romania" "Guinea Bissau" "Guatemala" "Greece" "Equatorial Guinea" "Guyana" "Georgia" "United Kingdom" "Gabon" "Guinea" "Gambia" "Greenland" "Kuwait" "Ghana" "Oman" "Somaliland" "Western Sahara" "Kosovo" "Northern Cyprus" "Jordan" "Croatia" "Haiti" "Hungary" "Honduras" "Puerto Rico" "West Bank" "Portugal" "Paraguay" "Panama" "Papua New Guinea" "Peru" "Pakistan" "Philippines" "Poland" "Zambia" "Estonia" "Egypt" "South Africa" "Ecuador" "Albania" "Angola" "Kazakhstan" "Ethiopia" "Zimbabwe" "Spain" "Eritrea" "Montenegro" "Moldova" "Madagascar" "Morocco" "Uzbekistan" "Myanmar" "Mali" "Mongolia" "Macedonia" "Malawi" "Mauritania" "Uganda" "Malaysia" "Mexico" "Vanuatu" "France" "Finland" "Fiji" "Falkland Islands" "Nicaragua" "Neth
@html
html / codemirror-mustache.js
Created December 18, 2013 00:57
Codemirror mustache mode, borrowed from CodeMirror source (mustache example)
/*
Copyright (C) 2013 by Marijn Haverbeke <marijnh@gmail.com> and others
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@html
html / yaclml-syntax-improvement.lisp
Last active December 27, 2015 03:19
Enable shorter syntax for yaclml. Also this allows to create yaclml tags dynamically.
#|
Version: 0.0.3
Example of using yaclml after this code evaluating
CL-USER> (<a :href "asdf" "jkl")
<a href="asdf"
>jkl</a
>; No value
CL-USER> (<some-undefined-tag :some-parameter "asdf" "jkl")
@html
html / weblocks-bootstrap-look-navigation.lisp
Created May 28, 2013 13:22
Snippet for bootstrap like navigation for weblocks
(defwidget bootstrap-navigation (navigation)
())
(defun render-bootstrap-navbar-menu-wt (&rest args &key menu-id menu-header menu-content menu-empty-p menu-empty-message menu-ordered-list-p)
(with-html-to-string
(:div :class "navbar"
:id menu-id
(:div :class "navbar-inner"
(when menu-header
(htm (:h1 (str menu-header))))
@html
html / install-app.sh
Created May 11, 2013 09:56
Small piece of code used to deploy apps
function install-app(){
DIR_NAME="`echo "$1" | grep -o "\([^/]\+\?\)\.git" | sed -e s/.git//`"
echo "Cloning repository"
git clone "$1" && cd $DIR_NAME;
git submodule update --init
}
install-app $*
@html
html / create-weblocks-app-repository.sh
Created April 28, 2013 18:51
Function used to create repository for weblocks project
function create-weblocks-app-repository(){
NAME="$1"
mkdir "$NAME";
cd "$NAME";
git init
git submodule add git://github.com/html/quicklisp-app-skeleton.git .quicklisp-install
cp .quicklisp-install/.quicklisp-version .
echo "(progn (ql:quickload :weblocks) (funcall (intern \"MAKE-APP\" \"WOP\") '$NAME \".\"))" | sbcl --load ".quicklisp-install/require-quicklisp"
mv $NAME/* .
rm -rf "$NAME"