NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.
If you are not into long explanations, see [Paolo Bergantino’s answer][2].
def format_time(secs): | |
return "%d:%02d" % (secs / 60, secs % 60) | |
def invert(arr): | |
""" | |
Make a dictionary that with the array elements as keys and | |
their positions positions as values. | |
>>> invert([3, 1, 3, 6]) |
1) Create a branch with the tag | |
git branch {tagname}-branch {tagname} | |
git checkout {tagname}-branch | |
2) Include the fix manually if it's just a change .... | |
git add . | |
git ci -m "Fix included" | |
or cherry-pick the commit, whatever is easier | |
git cherry-pick {num_commit} | |
class Hangman(): | |
def __init__(self): | |
print "Welcome to 'Hangman', are you ready to die?" | |
print "(1)Yes, for I am already dead.\n(2)No, get me outta here!" | |
user_choice_1 = raw_input("->") | |
if user_choice_1 == '1': | |
print "Loading nooses, murderers, rapists, thiefs, lunatics..." | |
self.start_game() | |
elif user_choice_1 == '2': |
def lis(a): | |
L = [] | |
for (k,v) in enumerate(a): | |
L.append(max([L[i] for (i,n) in enumerate(a[:k]) if n<v] or [[]], key=len) + [v]) | |
return max(L, key=len) | |
inp = [int(a) for a in input("List of integers: ").split(' ')] | |
print(lis(inp)); |
#!/bin/bash | |
# Create ftp user, create folders and set permissions | |
# Shamelessly coppied from http://dev.n0ise.net/2012/09/vsftpd-add-user-automation-bash-script/ | |
# Usage: ./create_ftp_user.sh [username] "[password]" | |
# | |
NAME=$1 | |
PASS=$2 |
NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.
If you are not into long explanations, see [Paolo Bergantino’s answer][2].
See the official documentation here: https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-Documentation | |
---- | |
qBittorrent Web API | |
API version: 2 | |
GET METHODS | |
=========== | |
- Get version info |
import os | |
import sys | |
from xml.sax import parse | |
from xml.sax.saxutils import XMLGenerator | |
class CycleFile(object): | |
def __init__(self, filename): | |
self.basename, self.ext = os.path.splitext(filename) | |
self.index = 0 |
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
# Description: Create a Plex collection from a text file list of rating keys. | |
# Author: /u/SwiftPanda16 | |
# Requires: plexapi | |
from plexapi.server import PlexServer | |