Skip to content

Instantly share code, notes, and snippets.

View sokovnich's full-sized avatar
🎯
Focusing

Yan sokovnich

🎯
Focusing
View GitHub Profile
@andriisoldatenko
andriisoldatenko / fopen.py
Last active November 20, 2018 05:42
This function helps you do not see errors during upload solutions, because you forget to switch back to sys.stdin and also you can easily debug your code with ipdb or another python debuggers
def fopen(filename, default=sys.stdin):
"""
This function helps you do not see errors during upload solutions
because you forget to switch back to sys.stdin and also you can easily
debug your code with ipdb or another python debuggers
"""
try:
f = open(filename)
except FileNotFoundError:
f = default
stack@octavia:~$ cat /etc/octavia/octavia.conf |egrep -v "^$|^#"
[DEFAULT]
transport_url = rabbit://stackrabbit:secretrabbit@172.16.68.59:5672/
api_handler = queue_producer
bind_host = 172.16.68.59
logging_exception_prefix = ERROR %(name)s %(instance)s
logging_default_format_string = %(color)s%(levelname)s %(name)s [-%(color)s] %(instance)s%(color)s%(message)s
logging_context_format_string = %(color)s%(levelname)s %(name)s [%(global_request_id)s %(request_id)s %(project_name)s %(user_name)s%(color)s] %(instance)s%(color)s%(message)s
logging_debug_format_suffix = {{(pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d}}
[api_settings]
@probonopd
probonopd / orangepizero.md
Last active August 7, 2024 09:43
Orange Pi Zero

Orange Pi Zero

Ideas

  • Port HomeServer to it
  • Read-only thanks to overlayroot
  • Native serial for Viessmann w/o USB-to-Serial
  • Native 433 MHz sending w/o Arduino
  • Native Audio output w/o USB dongle; can attach small amp board
  • Webcam via USB with motion
@mahmoud
mahmoud / scheme_port_map.json
Last active December 12, 2022 17:42
A big mapping url schemes to their protocols' default ports. See comments below for notes. Painstakingly assembled by crossreferencing https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml and https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml
{
"acap": 674,
"afp": 548,
"dict": 2628,
"dns": 53,
"file": null,
"ftp": 21,
"git": 9418,
"gopher": 70,
"http": 80,
@whophil
whophil / config.xml
Last active November 19, 2020 20:32
KVM XML configuration file for Windows 8 HTPC with VGA, USB controller passthrough on ASRock FM2A78M-ITX.
<domain type='kvm' id='1'>
<name>Win8-HTPC-OVMF</name>
<uuid>a2c7ea78-f49a-ef5b-6b16-521d098d40c9</uuid>
<metadata>
<vmtemplate xmlns="unraid" name="Windows 10" icon="windows.png" os="windows10"/>
</metadata>
<memory unit='KiB'>8388608</memory>
<currentMemory unit='KiB'>8388608</currentMemory>
<memoryBacking>
<nosharepages/>
@amatellanes
amatellanes / celery.sh
Last active August 29, 2024 10:08
Celery handy commands
/* Useful celery config.
app = Celery('tasks',
broker='redis://localhost:6379',
backend='redis://localhost:6379')
app.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
CELERY_QUEUES=(
Queue('default', routing_key='tasks.#'),
@michaelBenin
michaelBenin / sort_requirements.py
Created July 20, 2014 21:48
Sort requirements pip files or requirements.txt for python dependencies
requirements_file = 'base.pip'
requirements = open(requirements_file, 'r')
content = requirements.read().splitlines()
content = list(set(content))
content.sort(key=lambda y: y.lower())
content = '\n'.join(content)
file = open('sorted_'+requirements_file, 'w')
file.write(content)
@ikoblik
ikoblik / exif_date.py
Last active June 19, 2024 06:31
Python script to update image creation and modification dates to the EXIF date.
#!/usr/bin/env python
# MIT License
# Copyright (c) 2023 Ivan Koblik
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@atupal
atupal / msvcrt_input.py
Created June 26, 2013 06:31
python set time limit on input
import msvcrt
import time
def raw_input_with_timeout(prompt, timeout=30.0):
finishat = time.time() + timeout
result = []
while True:
if msvcrt.kbhit():
result.append(msvcrt.getche())
if result[-1] == '\r': # or \n, whatever Win returns;-)
@asimjalis
asimjalis / perl-shell.md
Created December 8, 2012 15:34
How to run Perl in an interactive shell

How to run Perl in an interactive shell

by Asim Jalis, MetaProse.com

An interactive shell is useful for quickly trying out different commands. While Ruby, Python, and Clojure come with interactive shells, Perl does not. However, it is easy to create one using this one-liner on Unix systems:

perl -e 'do{print("perl> ");$_x=<>;chomp $_x;print(eval($_x)."\n")}while($_x ne "q")'