Skip to content

Instantly share code, notes, and snippets.

@aorzh
aorzh / clean-up-arch-linux.md
Created November 16, 2024 13:09 — forked from rumansaleem/clean-up-arch-linux.md
Instructions to clean up Arch Linux (Manjaro)

Contents

  • Clean pkg cache
  • Remove unused packages (orphans)
  • Clean cache in /home
  • remove old config files
  • Find and Remove
    • duplicates
    • empty files
    • empty directories
  • broken symlinks
@aorzh
aorzh / install_geo_libraries.sh
Last active August 31, 2021 07:30
Ubuntu OSGEO compile (installing PROJ, GEOS, GDAL) on Ubuntu >= 18.04
echo "START INSTALLING PROJ, GEOS, GDAL"
# Install pre-requirements
echo "##################################"
echo "#### Install pre-requirements ####"
echo "##################################"
sleep 3
sudo apt remove -y proj-bin
sudo apt remove -y gdal-bin
sudo apt autoclean
@aorzh
aorzh / osgeo_compile.sh
Created August 4, 2021 10:19 — forked from robinkraft/osgeo_compile.sh
compile and install GEOS, PROJ4 and GDAL from source on Ubuntu 12.0.4
# Compile/install GEOS. Taken from:
# http://grasswiki.osgeo.org/wiki/Compile_and_Install_Ubuntu#GEOS_2
cd /tmp
wget http://download.osgeo.org/geos/geos-3.4.2.tar.bz2
bunzip2 geos-3.4.2.tar.bz2
tar xvf geos-3.4.2.tar
cd geos-3.4.2
@aorzh
aorzh / README.txt
Created February 25, 2020 16:59
bulk replace
task description:
please, write a function that receives
1)path to file
2) string to replace
3) the new string to replace with
4) in which line in the file to replace (if empty, then replace all)
I assume new string should not be same with pattern
Line number it's a real number (starts from 1). For example client see in text editor this number and pass it to func. I
@aorzh
aorzh / tokens.md
Created June 10, 2019 07:56 — forked from zmts/tokens.md
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Основы:

Аутентификация(authentication, от греч. αὐθεντικός [authentikos] – реальный, подлинный; от αὐθέντης [authentes] – автор) - это процесс проверки учётных данных пользователя (логин/пароль). Проверка подлинности пользователя путём сравнения введённого им логина/пароля с данными сохранёнными в базе данных.

Авторизация(authorization — разрешение, уполномочивание) - это проверка прав пользователя на доступ к определенным ресурсам.

Например после аутентификации юзер sasha получает право обращатся и получать от ресурса "super.com/vip" некие данные. Во время обращения юзера sasha к ресурсу vip система авторизации проверит имеет ли право юзер обращатся к этому ресурсу (проще говоря переходить по неким разрешенным ссылкам)

@aorzh
aorzh / split.py
Created May 30, 2018 13:23
Split value from Django queryset same like default split in Python
class SplitValue(Func):
"""
Usage
value of exist col: '1231$asdasd$asdasd'
data = YourModel.objects.all().annotate(new_col=SplitValue('exist_col', separator='$', slice_index=1))
new_col will '1231'
"""
function = 'SUBSTRING_INDEX'
template_pre = '%(function)s(%(expressions)s, %(separator)s, %(slice_index)s)'
template = '%(function)s({}, %(separator)s, %(slice_second)s)'.format(template_pre)
@aorzh
aorzh / input.csv
Last active April 2, 2017 13:15
Filter streets by conditions for ZP city hostital
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 5.
Арктична,"1,1а,2,3,3а,3б,4,5,5а,6,7,8,9,10,10а,11,12,12а,13,13а,14,15,15а,15б,16,16а,17,18,19,20,21,22,23,23а,24,25,26,26а,27,28,29,29а,30,31,32,32а,33,34,34а,35,36,37,38,39,39а,40,41,42,43,44,44а,45,45а,46,46а,47,48,48а,49,50,51,51а,52,52а,53,54,55,55а,56,57,57а"
Арсенальна,"1,2,3,4,5,6,7,8,9,10,11,11а,12,13,14,15,16,16а,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,36а,37,37а,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,56а,57,58,59,60,60а,61,61а,62,62б,63,64,65,66,67,68,69,70,71,72,73,74,75,75-2,76,76а,77,78,79,80,81,81а,82,83,83а,84,85,86,87,88,89,89а,90,91,92,93,94,95,96,97,98"
Астраханська,"1,2,3,4,5,6,7,8,9,10,11,12,13,13а,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,29-2,29-3,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46"
Агрономічна,"1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34"
Архітектурна,"1,2,3,4,5,6,6а,7,8,9,10,11,12,13,13б,14,15,15а,16,17,17а,18,19,20,21,22,23,24,25,26,26-2,27,28,28а,29,30,31,32,33,33а,34,35,36,37
@aorzh
aorzh / multiple.js
Created February 24, 2017 10:05
Here is small example for exporting multiple charts created by hightcharts to one pdf on multiple pages.
/**
* Create a global getSVG method that takes an array of charts as an
* argument
*/
/*global Highcharts, HighchartsAdapter, document, window, Math, setTimeout */
jQuery(document).ready(function ($) {
$(function () {
var ajaxDiv = '<div class="custom-ajax ajax-progress ajax-progress-throbber"><div class="throbber">&nbsp;</div></div>';
@aorzh
aorzh / captcha.py
Created November 16, 2016 17:44 — forked from tribela/captcha.py
google recaptcha v2
import time
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('https://www.google.com/recaptcha/api2/demo')
captcha_frame = driver.find_element_by_css_selector('iframe[src*="api2/anchor"]')
driver.switch_to_frame(captcha_frame)
driver.find_element_by_css_selector('.recaptcha-checkbox-checkmark').click()
from PyQt4 import QtCore, QtGui
class Dialog(QtGui.QDialog):
def __init__(self, parent=None):
super(Dialog, self).__init__(parent)
self.resize(300,200)
def showEvent(self, event):