Skip to content

Instantly share code, notes, and snippets.

View sesav's full-sized avatar

Sergey SΛV sesav

  • Novi Sad, Serbia
  • 14:06 (UTC +02:00)
View GitHub Profile
@sesav
sesav / enchanted_thread.py
Created October 4, 2023 18:14
Python thread with tracking of its execution
import sys
import threading
class enchanted_thread(threading.Thread):
def __init__(self, *args, **keywords):
threading.Thread.__init__(self, *args, **keywords)
self.has_stopped = False
def start(self):
@sesav
sesav / wget_exit_codes.txt
Last active September 5, 2023 08:41
This is the list of exit codes for wget
This is the list of exit codes for wget:
0 No problems occurred
1 Generic error code
2 Parse error — for instance, when parsing command-line options, the .wgetrc or .netrc…
3 File I/O error
4 Network failure
5 SSL verification failure
6 Username/password authentication failure
7 Protocol errors
package main
import "fmt"
func searchMatrix(matrix [][]int, target int) bool {
if len(matrix) == 0 {
return false
}
m, n := len(matrix), len(matrix[0])
left, right := 0, m*n-1
#!/usr/bin/python
def combinations(digits):
keys = {
"2": "abc",
"3": "def",
"4": "ghi",
"5": "jkl",
"6": "mno",
#!/usr/bin/python
from collections import deque
def combinations(digits):
keys = {
"2": "abc",
"3": "def",
"4": "ghi",
@sesav
sesav / rotate.sh
Created June 17, 2022 08:33
Fedora Linux 36, Cinnamon 5.2.7 (auto-rotate touch screen based on device orientation)
#!/bin/bash
#
# Auto-rotate touch screen based on device orientation.
#
# Fedora 36
# 5.17.14-300.fc36.x86_64
#
# Cinnamon 5.2.7
#
# You just need to add this script to the startup of applications for the user.
@sesav
sesav / .vimrc
Last active July 7, 2017 11:47
vim/macvim (solarized dark)
" https://github.com/VundleVim/Vundle.vim
" https://valloric.github.io/YouCompleteMe/
"
let $PATH = '/usr/local/bin:'.$PATH
set nocompatible " be iMproved, required
filetype off " required
if has("multi_byte")
if &termencoding == ""
let &termencoding = &encoding
@sesav
sesav / views.py
Created November 24, 2016 20:40
CBV with Multiple forms. Based on UpdateView.
class MultipleFormsView(ItemUpdate):
model = MyModel
template_name = ''
success_url = reverse_lazy('')
form_class = Form1
second_form_class = Form2
third_form_class = Form3
@sesav
sesav / memReport.py
Created December 20, 2014 10:03
ctl memory report for yosemite
#!/usr/bin/python
import subprocess
import re
ps = subprocess.Popen(['ps', '-caxm', '-orss,comm'], stdout=subprocess.PIPE).communicate()[0]
vm = subprocess.Popen(['vm_stat'], stdout=subprocess.PIPE).communicate()[0]
processLines = ps.split('\n')
sep = re.compile('[\s]+')
rssTotal = 0 # kB
@sesav
sesav / decrypt_md5.py
Created December 20, 2014 10:01
Simple example of decrypt md5 (slowly)
#!/usr/bin/python
import hashlib
import sys
def decryptMD5(testHash):
s = []
while True:
m = hashlib.md5()
for c in s: