Skip to content

Instantly share code, notes, and snippets.

View 9seconds's full-sized avatar
💭
I can't actively participate because of family reasons

Sergey Arkhipov 9seconds

💭
I can't actively participate because of family reasons
View GitHub Profile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Solving best-before problem
http://www.spotify.com/se/jobs/tech/best-before/
'''
# ############################################################################
@9seconds
9seconds / wtf1
Created December 11, 2013 18:35
Python WTFs
>>> a = (1, [2, 3])
>>> a[1] += [4, 5]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
>>> print a
(1, [2, 3, 4, 5])
>>>
@9seconds
9seconds / ah.rb
Last active August 29, 2015 14:08
HomeBrew formula for Ah
require "formula"
class Ah < Formula
homepage "https://github.com/9seconds/ah"
url "https://github.com/9seconds/ah.git", :tag => "0.13.1"
version "0.13.1"
sha1 ""
bottle do
sha1 "7563b28df830baa880731b9448e88b99dcb68420" => :mavericks
>>> import os
>>> os.remove == os.unlink
True
>>> os.remove is os.unlink
False
>>>
@9seconds
9seconds / backup.sh
Last active October 21, 2017 18:31
backup wrapper for borg backup
#!/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 ':')"
    $ 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 / db_logger.py
Created July 4, 2016 12:58
Ansible Database logger
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
import os
import os.path
import sqlite3
import time
import uuid
@9seconds
9seconds / ranntsbuilder.yaml
Last active April 28, 2017 14:30
Script used to build rannts website on remote machines
---
# 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 / ranntsbuilder.py
Created April 28, 2017 14:39
Script which builds rannts website
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim: set ft=python:
import argparse
import contextlib
import json
import logging
import os
@9seconds
9seconds / example-log.py
Created September 12, 2017 09:49
log.py example
# -*- coding: utf-8 -*-
# vim: set et sw=4 ts=4:
import logging
import logging.config
import flask