Skip to content

Instantly share code, notes, and snippets.

View akovalenko's full-sized avatar

Anton Kovalenko akovalenko

View GitHub Profile

Keybase proof

I hereby claim:

  • I am akovalenko on github.
  • I am akovalenko (https://keybase.io/akovalenko) on keybase.
  • I have a public key ASA795wj16fJpsxUF1rKW2UKDFmvYqc9JE29OIgsDf9n_Qo

To claim this, I am signing this object:

@akovalenko
akovalenko / cl-pg-as-minimal-test.lisp
Last active August 29, 2015 14:11
Minimal parse / execute / row-reader demo for cl-postgres-async
(in-package :cl-postgres-async)
;;(defparameter *test-connection* '("test" "test" "" "localhost"))
(defvar *test-connection* '("test" "test" "" "localhost"))
(defun prompt-connection (&optional (list *test-connection*))
(flet ((ask (name pos)
(format *query-io* "~a (enter to keep '~a'): " name (nth pos list))
(finish-output *query-io*)
(let ((answer (read-line *query-io*)))
(defvar *ru-vowels* "аоуыэяёюие")
(defun vowelp (character) (position character *ru-vowels*))
(defun move-vowels (n &optional (input *standard-input*) (output *standard-output*))
(let ((vowels 0))
(loop
(let ((character (read-char input nil :eof)))
(when (eq :eof character)
(return))
@akovalenko
akovalenko / watch-xi2.c
Created January 23, 2013 13:13
Watch-xi2 looks for X Window System events that occur when input device hierarchy changes in any way (e.g. when a keyboard or a mouse is connected or disconnected). It may take a single parameter: a shell command to run on the hierarchy change events.
/* (c) Copyright 2010 Anton Kovalenko <anton@sw4me.com>.
LICENSE:Do what you want with this software, but don't blame me.
Compile it with gcc -lX11 -lXi.
*/
#define WATCH_XI2_TIMESTAMP "Time-stamp: <2010-08-14 19:39:55 anton>"
#include <X11/Xlib.h>
#include <X11/extensions/XInput2.h>
#include <X11/Xutil.h>
#include <stdio.h>
(in-package "SB-THREAD")
(define-alien-routine ("SetConsoleCtrlHandler" set-console-ctrl-handler) int
(callback (function (:stdcall int) int))
(enable int))
(defun windows-console-control-handler (event-code)
(case event-code
(0
(flet ((interrupt-it ()