Is there a way to squash a number of commits non-interactively?
Make sure your working tree is clean, then git reset –soft HEAD~3 git commit -m ‘new commit message’
Make sure your working tree is clean, then git reset –soft HEAD~3 git commit -m ‘new commit message’
>>> import getpass >>> pw = getpass.getpass()
Yes, it’s possible. In order to be interactive, the program must be able to wait for and read in user input from stdin. In PHP, you can read from stdin by opening a file descriptor to ‘php://stdin’. Taken from an answer to different question, here’s an example of an interactive user prompt in PHP (when … Read more
There are several ways to approach controlling a matplotlib plot using ipywidgets. Below I’ve created the output I think you’re looking for using each of the options. The methods are listed in what feels like the natural order of discovery, however, I would recommend trying them in this order: 4, 2, 1, 3 Approach 1 … Read more
A minimal and complete working example of how to use this answer (tested in Python 3.6.1) # run.py from paramiko import SSHClient ssh = SSHClient() ssh.load_system_host_keys() ssh.connect(‘…’) print(‘started…’) stdin, stdout, stderr = ssh.exec_command(‘python -m example’, get_pty=True) for line in iter(stdout.readline, “”): print(line, end=””) print(‘finished.’) and # example.py, at the server import time for x in … Read more
__main__.__file__ doesn’t exist in the interactive interpreter: import __main__ as main print hasattr(main, ‘__file__’) This also goes for code run via python -c, but not python -m.
In addition to what @triplepoint mentioned, have a look at the slider widget. There’s an example on the matplotlib examples page. It’s a graphical slider bar rather than keyboard bindings, but it works quite well for what you want to do. Also note that to guarantee the sliders and buttons remain responsive and not garbage-collected, … Read more
import paramiko import re class ShellHandler: def __init__(self, host, user, psw): self.ssh = paramiko.SSHClient() self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self.ssh.connect(host, username=user, password=psw, port=22) channel = self.ssh.invoke_shell() self.stdin = channel.makefile(‘wb’) self.stdout = channel.makefile(‘r’) def __del__(self): self.ssh.close() def execute(self, cmd): “”” :param cmd: the command to be executed on the remote computer :examples: execute(‘ls’) execute(‘finger’) execute(‘cd folder_name’) “”” cmd = cmd.strip(‘\n’) … Read more
This is often works well enough import os, sys if os.isatty(sys.stdout.fileno()): …
Is this like in this git-add post? Manually editing the hunk is immensely powerful, but also a bit complicated if you’ve never done it before. The most important thing to keep in mind: The diff is always indented with one character in addition to whatever other indentation is there. The character can either be: a … Read more