Skip to content

Instantly share code, notes, and snippets.

View Oliver2213's full-sized avatar

Blake Oliver Oliver2213

View GitHub Profile
# Given a string of letters, output all the english word permutations of those letters.
# pip install click pyenchant
from itertools import permutations
import sys
import click
try:
import enchant
except ImportError:
enchant = None
@Oliver2213
Oliver2213 / keybase.md
Created November 17, 2016 23:51
My keybase proof

Keybase proof

I hereby claim:

  • I am oliver2213 on github.
  • I am oliver2213 (https://keybase.io/oliver2213) on keybase.
  • I have a public key ASBQ3zZt4sHKF4fXS8Fxu5d67FLooKaf2MV2NzREefHVxwo

To claim this, I am signing this object:

@Oliver2213
Oliver2213 / github_commandline_pullrequests.md
Created September 21, 2016 04:04
Manage pull requests from an upstream repository on your fork from cli git

Managing Git Hub pull requests from an upstream repository with the git cli

Sometimes, when I fork a repository I do it just to mess around with the code to see if I can come up with any useful features to eventually PR into upstream/master. Other times (when a repository hasn't been committed to in a while), I'll fork it to merge outstanding pull requests from upstream. There is a way to do this from the github website, but it's (in my opinion) overly complicated and I much prefer a nice and easy commandline approach.

I figured this out by reading through this stackoverflow question (scroll down to see the answer in question), and am posting it in this gist so I'll have something to refer to in the future, as well as helping anyone who has a similar need for commandline simplisity.

setup

For this to work, you must have at least 2 remotes, in this example "origin" is your fork of the

@Oliver2213
Oliver2213 / browserlog
Created September 10, 2016 07:07
Small script to output the first argument passed to it as a log file. I use this as my $BROWSER on linux servers that don't have (or need) a terminal browser installed, though I guess you could use it for other things, just change the environment variable you set and the log format. You'll need python (2 or 3 should both work) and the psutil pac…
#!/usr/bin/env python
# quick browser link printer
# outputs to browser.log in home directory by default
import sys
import os
import datetime
import psutil
def list_all_torrents(client):
"""Given a valid transmission RPC client instance, lists all torrents and the progress of each"""
bitmath.format_string = "{value:.2f} {unit}"
for torrent in client.get_torrents():
print("Torrent %d, %s. Status: %s. Progress: %s percent. Download rate: %s, upload rate: %s, Total size: %s, downloaded: %s, uploaded: %s." %(torrent.id, torrent.name, torrent.status, round(torrent.progress, 3), bitmath.Byte(torrent.rateDownload).best_prefix(), bitmath.Byte(torrent.rateUpload).best_prefix(), bitmath.Byte(torrent.totalSize).best_prefix(), bitmath.Byte(torrent.downloadedEver).best_prefix(), bitmath.Byte(torrent.uploadedEver).best_prefix()))