Skip to content

Instantly share code, notes, and snippets.

View damirm's full-sized avatar

Damir Makhmutov damirm

  • Yandex
  • Russia, Moscow
View GitHub Profile
@damirm
damirm / ANSI.md
Created September 5, 2022 21:42 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
#!/usr/bin/env bash
# Usage:
# $ git commit -m "$(t): Commit message"
#
# Where "t" it's provided script below. It should be in $PATH.
ISSUE_RE="[A-Z]+-\d+"
ISSUE=$(git symbolic-ref --short HEAD 2>&1 | grep -Eo ${ISSUE_RE})
'use strict';
function damir(tree, dest) {
if (tree.name === dest) {
return [tree.name];
}
for (let i = 0; i < tree.children.length; ++i) {
const result = [tree.name];
const item = tree.children[i];
-- size
SELECT
table_schema "database_name",
sum( data_length + index_length )/1024/1024 "Data Base Size in MB"
FROM information_schema.TABLES
GROUP BY table_schema;
-- writes mb
set @start := (
select sum(VARIABLE_VALUE/1024/1024)
@damirm
damirm / shrug.js
Last active September 16, 2016 07:56
function shrug(el, speed, i) {
var enabled = true;
var shurgs = [
"¯\\_(ツ)_/¯",
"_/¯(ツ)_/¯",
"_/¯(ツ)¯\\_",
"¯\\_(ツ)¯\\_"
];
'use strict';
const source = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
const expected = [0, 4, 8, 1, 5, 9, 2, 6, 3, 7];
function transpose(arr, columns) {
const rows = Math.ceil(arr.length / columns);
return arr.reduce((result, v, i) => {
const col = Math.ceil((i + 1) / rows);
@damirm
damirm / gist:ea61b694036dc04d6c3f
Created October 7, 2015 21:39 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
function transpose($matrix) {
array_unshift($matrix, null);
return call_user_func_array('array_map', $matrix);
}
function transpose($matrix) {
return array_map(null, ...$matrix);
}
@damirm
damirm / ubuntu_server_setup.sh
Last active August 29, 2015 14:27
Ubuntu server setup
# 1. setting up locales
sudo tee -a /etc/default/locale <<EOF
LANGUAGE="en_US.UTF-8"
LANG="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
EOF
# Или можно юзать update-locale:
sudo update-locale LANGUAGE="en_US.UTF-8" LANG="en_US.UTF-8" LC_ALL="en_US.UTF-8"
sudo locale-gen en_US.UTF-8

Keybase proof

I hereby claim:

  • I am damirm on github.
  • I am damirm (https://keybase.io/damirm) on keybase.
  • I have a public key whose fingerprint is A3DF 90E6 8DE3 2B24 0BEC 3E54 C846 4F13 7B90 5E9B

To claim this, I am signing this object: