Skip to content

Instantly share code, notes, and snippets.

View alpacato's full-sized avatar
🏠
Working from home

Igor Kochurin alpacato

🏠
Working from home
View GitHub Profile
const normalizeAngle = (angle) => {
return angle > 0 ? angle % 360 : 360 - -(angle % 360);
}
@alpacato
alpacato / russia_region_codes.php
Created April 23, 2018 13:50
Коды регионов России ГИБДД
<?php
$region_codes = [
'01' => 'Республика Адыгея',
'02' => 'Республика Башкортостан',
'03' => 'Республика Бурятия',
'04' => 'Республика Алтай (Горный Алтай)',
'05' => 'Республика Дагестан',
'06' => 'Республика Ингушетия',
'07' => 'Кабардино-Балкарская Республика',
@alpacato
alpacato / gist:2ddf835bc54a3ba6a45251050105ee26
Last active March 19, 2018 15:30 — forked from realmyst/gist:1262561
Склонение числительных в javascript
const declOfNum = (number, titles) => {
let cases = [2, 0, 1, 1, 1, 2];
return titles[(number % 100 > 4 && number % 100 < 20) ? 2 : cases[(number % 10 < 5) ? number % 10 : 5]];
}
// use:
const number = 100;
declOfNum(number, ['найдена', 'найдено', 'найдены']);
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
-- вход в пользователя постгрес --
sudo -u postgres psql
-- выход --
\q
-- создание пользователя --
😀
😁
😂
🤣
😃
😄
😅
😆
😉
😊
find /root -name "writetofile.php.*" -type f -delete
find ./content/ankety/ -name "*.txt" -type f -exec sed -i 's/Onmoderate\: 1/Onmoderate\: 0/g' {} +
sudo kill $(sudo lsof -t -i:3002)
@alpacato
alpacato / changeEncoding.py
Last active January 21, 2024 09:18
Python script Changes files in folder recursive to another encoding.
# -*- coding: utf-8 -*-
import os
import codecs
# pip3 install cchardet
import cchardet as chardet
def changeEncoding(folder, encode_to):
for root, dirs, files in os.walk(folder):
path = root.split(os.sep)
for file in files: