Skip to content

Instantly share code, notes, and snippets.

# swapcaps.sh
#!/bin/sh
if [[ $(xmodmap -pk | grep Caps | awk '{print $1}') = 22 ]]; then
# already configured, do nothing.
exit 0
fi
# remove special key lock and swap caps with backspace
xmodmap -e "remove Lock = Caps_Lock"
@micheller
micheller / traverser.clj
Created April 4, 2017 22:22
A get-in like tree traverser which supports multiple paths (on vectors)
(defn unpack [alist]
(loop [accum []
alist alist]
(if (empty? alist)
accum
(let [ff (first alist)
func (if (sequential? ff)
concat
conj)]
(recur (func accum ff)
@micheller
micheller / repl-it.el
Created April 4, 2017 22:17
emacs lisp code to post snippets on repl.it
(defun get-buffer-data ()
(let (bounds)
(setq bounds
(if (and transient-mark-mode mark-active)
(cons (region-beginning) (region-end))
(cons (point) (point-max))))
(buffer-substring-no-properties (car bounds)
(cdr bounds))))
(defun buffer-mode (&optional buffer-or-name)
# Если у вас есть две или более модели SearchIndex, у которых есть поле с одинаковым названием, то в конфиге эластика последний
# тип оверрайдит первый.
class PointIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.NgramField(document=True, use_template=True)
address = indexes.EdgeNgramField(model_attr='address')
def get_model(self):
return Point
@micheller
micheller / PCipfinder.py
Last active October 26, 2015 13:59
накостыленный под существующие настройки скрипт
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import logging
import atexit
import argparse
from pyVim import connect
from pyVmomi import vmodl, vim
@micheller
micheller / bit-converter
Created July 17, 2015 08:57
My colleague asked me to write function written to convert selected binary constants (ex. 0b11101) to decimal view and back.
;; The fist version. Tricky and workarounded.
;; you can test it on this:
;; var BITS = ( 29, 0, 63, 85, 34 )
(defun bit-compact (start end)
(interactive "r")
(defun int-to-binary-string (i)
"convert an integer into it's binary representation in string format"