command-line-interface
Is there a single line way to run a command in a Python venv?
You can generally run something in a virtual environment simply by using a fully qualified path to the script. For example, if I have: virtualenv .venv Then I can install something into that virtual environment without activating it by running: .venv/bin/pip install foo This should be true for anything installed using standard Python mechanisms.
diff branch changes in git relative to common ancestor
After extensively looking at git help rev-parse and experimenting around, I found this piece of information: <rev1>..<rev2> Include commits that are reachable from <rev2> but exclude those that are reachable from <rev1>. When either <rev1> or <rev2> is omitted, it defaults to HEAD. <rev1>…<rev2> Include commits that are reachable from either <rev1> or <rev2> but … Read more
How to run commands via NodeJS child process?
Sending a newline \n will exectue the command. .end() will exit the shell. I modified the example to work with bash as I’m on osx. var terminal = require(‘child_process’).spawn(‘bash’); terminal.stdout.on(‘data’, function (data) { console.log(‘stdout: ‘ + data); }); terminal.on(‘exit’, function (code) { console.log(‘child process exited with code ‘ + code); }); setTimeout(function() { console.log(‘Sending stdin … Read more
XMLStarlet does not select anything
UPDATE: since version 1.5 the default namespace prefix ‘_’ is available so the solution is reduced to this: xml sel -t -m _:project -v _:groupId -o : -v _:artifactId -o : -v _:version pom.xml Thanks @JamieNelson for the heads-up. Unfortunately, XMLStarlet is very picky about the default namespace. If the document has it declared (xmlns=), … Read more
git request-pull: how to create a (github) pull request on the command line?
Even though they are called exactly the same thing, a GitHub pull request and a ‘git request-pull’ are completely different. The git request-pull is for generating a summary of pending changes to be sent to a mailing list. It has no integration by default with GitHub. The GitHub Pull Requests is a fully featured function … Read more
What is the maximum length of a C#/CLI identifier?
In addition to the other answers, the maximum identifier length that is accepted by the Microsoft Visual C# compiler is 511 characters. This can be tested with the following code: class Program { private static void Main(string[] args) { int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 5; } } The length of the variable name there is 511 characters. … Read more
How do I know the data type of the value of a given key?
You could use the type command: http://redis.io/commands/type
How to escape strings for terminal in Ruby?
Shellwords should work for you 🙂 exec “/usr/bin/mplayer %s” % Shellwords.escape(song.file) In ruby 1.9.x, it looks like you have to require it first require “shellwords” But in ruby 2.0.x, I didn’t have to explicitly require it.
Search for files & file names using silver searcher
According to the man page of ag -G –file-search-regex PATTERN Only search files whose names match PATTERN. You can use the -G option to perform searches on files matching a pattern. So, to answer your question: root@apache107:~/rpm-4.12.0.1# ag -G cpio.c size rpm2cpio.c 21: off_t payload_size; 73: /* Retrieve payload size and compression type. */ 76: … Read more