Skip to content

Instantly share code, notes, and snippets.

@dydemin
dydemin / Dockerfile
Created January 3, 2024 04:41
Docker: Ubuntu 22.04 + Apache2 + PHP8.2 + kalkancrypt.so
FROM ubuntu:22.04
# Install all required soft
RUN apt-get update \
&& apt-get -y upgrade \
&& apt-get -y install tzdata \
&& ln -fs /usr/share/zoneinfo/Asia/Almaty /etc/localtime \
&& dpkg-reconfigure -f noninteractive tzdata \
&& apt-get -y install \
apache2 \
@dydemin
dydemin / sign.py
Last active March 28, 2025 19:27
libkalkancrypt: SignWSSE на Python
import ctypes
KEY_ALIAS = ""
KC_RESULT_OK = 0x0
KC_STORE_FILE_SYSTEM = 0x1
kalkan = ctypes.CDLL("/usr/lib/libkalkancryptwr-64.so", mode=1)
kalkan.KC_GetLastError = kalkan.KC_GetLastError
kalkan.KC_GetLastError.restype = ctypes.c_ulong
@dydemin
dydemin / new empty git branch.md
Created February 13, 2020 04:57 — forked from ozh/new empty git branch.md
Create a new empty branch in Git
$ git checkout --orphan NEWBRANCH
$ git rm -rf .

--orphan creates a new branch, but it starts without any commit. After running the above command you are on a new branch "NEWBRANCH", and the first commit you create from this state will start a new history without any ancestry.

You can then start adding files and commit them and they will live in their own branch. If you take a look at the log, you will see that it is isolated from the original log.

@dydemin
dydemin / hidden.css
Created October 1, 2017 07:07
Hide an element only visually
.visually-hidden {
/* Remove the item from normal flow */
position: absolute;
/* Workaround for falsely pronounced, smushed text */
white-space: nowrap;
/* Set it to the smallest possible size (some screen readers ignore elements with zero height and width) */
width: 1px;
height: 1px;
/* Hide overflowing content after resizing */
overflow: hidden;
@dydemin
dydemin / truncate_html.php
Last active September 12, 2017 04:01 — forked from andykirk/truncate_html.php
PHP Truncate HTML Function
/**
* truncate_html()
*
* Truncates a HTML string to a given length of _visisble_ (content) characters.
* E.g.
* "This is some <b>bold</b> text" has a visible/content length of 22 characters,
* though the total string length is 29 characters.
* This function allows you to limit the visible/content length whilst preserving any HTML formatting.
*
* @param string $html
@dydemin
dydemin / sr-only.css
Created May 2, 2017 03:41
Screen Readers Only
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
-webkit-clip-path: inset(50%);
clip-path: inset(50%);
@dydemin
dydemin / new-branch.sh
Created March 28, 2017 04:30
Создание пустой ветки репозитория git
git checkout --orphan <branchname>
git rm --cached -r .
@dydemin
dydemin / select.css
Created February 24, 2017 03:26
Стилизация элемента select
select {
/* Базовые стили */
width: 100px;
height: 26px;
border-radius: 10px;
line-height: 1em;
/* Отменяем стандартное форматирование */
-webkit-appearance: none; /* WebKit */
.input {
// Цвет
&::-webkit-input-placeholder {color:#c0392b;}
&::-moz-placeholder {color:#c0392b;}/* Firefox 19+ */
&:-moz-placeholder {color:#c0392b;}/* Firefox 18- */
&:-ms-input-placeholder {color:#c0392b;}
// Если большая строка
&[placeholder] {text-overflow:ellipsis;}
&::-moz-placeholder {text-overflow:ellipsis;}
@dydemin
dydemin / logo.html
Last active February 23, 2017 06:33
Микроразметка логотипа для Google
<div itemscope itemtype="http://schema.org/Organization">
<a itemprop="url" href="http://www.example.com/">Главная</a>
<img itemprop="logo" src="http://www.example.com/logo.png" />
</div>