Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Sergey Arkhipov 9seconds

💭
I may be slow to respond.
View GitHub Profile
@9seconds
9seconds / comparators.py
Last active Nov 20, 2020
Example of inlined datetime comparators
View comparators.py
import enum
import datetime
import pydantic
class Comparator(enum.Enum):
LT = "<"
GT = ">"
EQ = "="
@9seconds
9seconds / coins.py
Created Dec 28, 2018
Coins task solution
View coins.py
#!/usr/bin/env python3
import sys
import itertools
COINS = [1, 5, 10, 50, 100, 200, 500, 1000, 2500]
CACHE = {}
def change_number(money):
View coins.txt
В России есть такие монеты:
- 1 копейка
- 5 копеек
- 10 копеек
- 50 копеек
- 1 рубль
- 2 рубля
- 5 рублей
- 10 рублей
- 25 рублей
View curl.py
import io
import pycurl
curl = pycurl.Curl()
curl.setopt(curl.URL, "https://nghttp2.org")
curl.setopt(pycurl.HTTP_VERSION, pycurl.CURL_HTTP_VERSION_2_0)
curl.setopt(pycurl.VERBOSE, 1)
View example-log.py
# -*- coding: utf-8 -*-
# vim: set et sw=4 ts=4:
import logging
import logging.config
import flask
@9seconds
9seconds / ranntsbuilder.py
Created Apr 28, 2017
Script which builds rannts website
View ranntsbuilder.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim: set ft=python:
import argparse
import contextlib
import json
import logging
import os
@9seconds
9seconds / ranntsbuilder.yaml
Last active Apr 28, 2017
Script used to build rannts website on remote machines
View ranntsbuilder.yaml
---
# vim: set ft=ansible:
# Mandatory: copy_back - drectory path without trailing slash
# commit_hash - commit to work with
- hosts: all
become: true
gather_facts: false
@9seconds
9seconds / db_logger.py
Created Jul 4, 2016
Ansible Database logger
View db_logger.py
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
import os
import os.path
import sqlite3
import time
import uuid
View EXAMPLE.md
    $ cd rust-lang-repo/
    $ git ask src/libcore
    * src/libcore
            Brian Anderson <banderson@mozilla.com>
            Patrick Walton <pcwalton@mimiga.net>
            Alex Crichton <alex@alexcrichton.com>
@9seconds
9seconds / backup.sh
Last active Oct 21, 2017
backup wrapper for borg backup
View backup.sh
#!/bin/bash
set -eu -o pipefail
# -----------------------------------------------------------------------------
export LANG=en_US.UTF-8
export BORG_PASSPHRASE=''
MAIN_USER="johndoe"
MAIN_HOMEDIR="$(getent passwd ${MAIN_USER} | cut -f 6 -d ':')"