Skip to content

Instantly share code, notes, and snippets.

View Hellowlol's full-sized avatar

Steffen Fredriksen Hellowlol

  • Kristiansand, Norway
View GitHub Profile
@lalinsky
lalinsky / fp-find.py
Created July 22, 2011 18:02
Locate audio snippets in a longer stream
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])
@danielestevez
danielestevez / gist:2044589
Last active June 30, 2024 09:04
GIT Commit to an existing Tag
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}
@DevDarren
DevDarren / hangman_1.py
Created December 4, 2012 00:41
A simple hangman game made with Python 2.7.3
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':
@lovasoa
lovasoa / longest-increasing-subsequence.py
Last active October 1, 2020 19:58
Solution to the longest increasing subsequence problem, in 5 lines of python
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));
@bbrothers
bbrothers / create_ftp_user.sh
Last active June 17, 2023 11:20
Bash for creating vsftp users
#!/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
@Zearin
Zearin / python_decorator_guide.md
Last active July 18, 2024 00:10
The best explanation of Python decorators I’ve ever seen. (An archived answer from StackOverflow.)

NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.


Q: How can I make a chain of function decorators in Python?


If you are not into long explanations, see [Paolo Bergantino’s answer][2].

@pmzqla
pmzqla / Web API documentation
Last active September 21, 2021 23:33
qBittorrent Web API documentation
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
@nicwolff
nicwolff / XML_breaker.py
Last active June 26, 2024 23:25
Python script to break large XML files
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

Most downloaded projects

SELECT
  file.project,
  COUNT(*) as total_downloads,
FROM
  TABLE_DATE_RANGE(
    [the-psf:pypi.downloads],
    TIMESTAMP("20160114"),
@JonnyWong16
JonnyWong16 / collection_from_rating_keys.py
Last active May 16, 2024 21:20
Create a Plex collection from a text file list of rating keys.
#!/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