Skip to content

Instantly share code, notes, and snippets.

View svetlyak40wt's full-sized avatar
💭
Making Ultralisp.org

Alexander Artemenko svetlyak40wt

💭
Making Ultralisp.org
View GitHub Profile
@svetlyak40wt
svetlyak40wt / test.lisp
Created January 22, 2017 19:32
Lisp's consistent white spacing, using magic format function
#!/bin/sh
#|-*- mode:lisp -*-|#
#| <Put a one-line description here>
exec ros -Q -- $0 "$@"
|#
(progn ;;init forms
)
(defpackage :ros.script.test-me.3694101834
(:use :cl))
@svetlyak40wt
svetlyak40wt / demo.lisp
Created February 8, 2017 18:42
Common Lisp. Dynamic variable binding using defun's lambda expression.
(defvar *foo* nil)
(defun minor ()
(format t "~&*foo* in minor: ~a~%" *foo*))
(defun bar (&key ((:baz *foo*) 42))
(format t "~&*foo* in bar: ~a~%" *foo*)
(minor))
(progn
@svetlyak40wt
svetlyak40wt / show-all-certs.py
Created March 14, 2017 17:56
This utility prints information about all SSL certificates in one pem file. Useful to see what is inside of certificate chain.
#!/usr/bin/env python
# coding: utf-8
from __future__ import division, absolute_import
from __future__ import print_function
import sys
import subprocess
@svetlyak40wt
svetlyak40wt / histogram.lisp
Created June 5, 2017 08:50
A module to print ASCII histogram.
(defpackage #:histogram
(:use #:cl)
(:export
#:print-histogram))
(in-package histogram)
(defun min-value (values)
"Ищет минимальное по любому количеству элементов."
(loop for value in values
class Store(object):
def store(self, data):
raise NotImplemented()
def prepare(self, data):
# тут может быть какой-то общий код, который переиспользуется разными реализациями.
class CloudStore(object):
def __init__(self, login, password):
self.login = login
@svetlyak40wt
svetlyak40wt / parenscript-dependency.lisp
Created November 9, 2017 16:02
Пример JS кода на Parenscript.
(weblocks.parenscript:make-dependency
(defun scroll-percentage (el offset)
"Возвращает число от 0 до 100 показывающее, сколько процентов сказки уже просмотрено."
(let* ((el (j-query el))
(w (j-query window))
(document-view-top ((@ w scroll-top)))
(document-view-bottom (+ document-view-top
((@ w height))))
(element-height ((@ el height)))
(element-top (@ ((@ el offset))
@svetlyak40wt
svetlyak40wt / weblocks-lass-example.lisp
Created November 9, 2017 16:04
Пример генерации CSS кода из Common Lisp (с использованием LASS)
(weblocks.lass:make-dependency
'(.story-feed
(.progress :position fixed
:z-index 100
:top 0
:left 0
:width 100%)
(.spinner :display none
:border-top 1px solid gray)))
@svetlyak40wt
svetlyak40wt / do-rss-feed-for-org-mode.py
Created November 11, 2017 13:09
Пример использования python-processor для преобразования Email в RSS фид.
#!env/bin/python3
import re
import logging
import os
from html2text import html2text
from processor import run_pipeline, sources, outputs
from twiggy_goodies.setup import setup_logging
# Что тут есть?
@svetlyak40wt
svetlyak40wt / lisp-emacs-config.el
Created November 12, 2017 08:17
A minimal config for working with Lisp in Emacs
(package-initialize)
(require 'package)
(add-to-list 'package-archives
'("MELPA" . "http://melpa.milkbox.net/packages/") t)
(defun install-package (package)
(unless (package-installed-p package)
(package-refresh-contents)
@svetlyak40wt
svetlyak40wt / ningle-http-http-api.lisp
Created November 12, 2017 08:24
A short example of a HTTP api written in Common Lisp's framework Ningle.
;; Micro-framework for building API
(ql:quickload :ningle)
;; Now ningle is installed and we need to install a clack which is analog of WSGI
;; stack from Python
;; I've pressed C-c C-c to eval this form
(ql:quickload :clack)
;; To parse json:
(ql:quickload :jonathan)