Git: Get the Latest Commits in a Repository

Sometimes you have a large repository (many commits, many branches) and it either might be an old clone or you might be operating out of a secondary branch and not aware of which branch has the majority of activity. You can do a git-log that displays all commits without respect to the current branch and order them by parents before children, in descending commit-timestamp (as opposed to author-timestamp) order.

This prints the top five:

$ git log -5 --all --date-order
Advertisements

Browse Your Image Library With a Webpage

Easily install via PyPI and start a documentation server with RemoteImageBrowser. It also supports more robust/scalable installs (via uWSGI).

You can also reuse and augment the local Gnome thumbnail cache. This means that if you have a want to serve a large image library, you can precache all of your thumbnails from a scheduled process and benefit from them both when browsing/manipulating them directly as well as when you browse them from the website. A basic PIL-based thumbnailer is used by default.

Installing:

$ git clone https://github.com/dsoprea/RemoteImageBrowser.git
$ cd RemoteImageBrowser
$ sudo pip install -r requirements.txt
$ rib/resources/scripts/development \
    --env IMAGE_ROOT_PATH=~/Downloads \
    --env THUMBNAIL_ROOT_PATH=/tmp/thumbnails

Screenshots:

Browsing

Lightbox

Cog: Evaluate Arbitrary Python Fragments in a Template Document

You provide any text document with embedded fragments of Python, and Cog renders it:

using namespace std;

#include <iostream>

int main() {
    cout << "Hello Earth." << endl;


/*[[[cog

print("""\
cout << "Hello Mars." << endl;
printf("Goodbye Pluto.\\n");
""")

]]]*/

//[[[end]]]


  return 0;
}

Notice that newlines have to be escaped.

Translate:

$ cog.py hello_world.cpp.cog > hello_world.cpp

Output:

using namespace std;

#include <iostream>

int main() {
    cout << "Hello Earth." << endl;


/*[[[cog

print("""\
cout << "Hello Mars." << endl;
printf("Goodbye Pluto.\\n");
""")

]]]*/
cout << "Hello Mars." << endl;
printf("Goodbye Pluto.\n");

//[[[end]]]


  return 0;
}

General build and run:

$ g++ -o hello_world hello_world.cpp
$ ./hello_world
Hello Earth.
Hello Mars.
Goodbye Pluto.

Chrome at the Command-Line to Dump Website Structure

You can use Chrome to dump the DOM, PDF, or screenshot of a webpage, or do a number of other cool things:

https://developers.google.com/web/updates/2017/04/headless-chrome

Open a website in a Chrome process headless-mode, which you can then query from a client process or another browser:

$ chrome --headless --disable-gpu --remote-debugging-port=9222 https://www.chromestatus.com

Print the site HTML:

$ chrome --headless --disable-gpu --dump-dom https://www.chromestatus.com

Capture a PDF:

$ chrome --headless --disable-gpu --print-to-pdf https://www.chromestatus.com

Capture a PNG screenshot:

$ chrome --headless --disable-gpu --screenshot https://www.chromestatus.com

Open a REPL console in which to run JavaScript expressions against the DOM:

$ chrome --headless --disable-gpu --repl https://www.chromestatus.com

Use GPG to Quickly Encrypt at the Command-Line


$ echo "cleartext" | gpg --passphrase "some-passphrase" -c --no-use-agent > text.encrypted
$ cat text.encrypted | gpg --passphrase "passphrase" --no-use-agent 2>/dev/null
$ cat text.encrypted | gpg --passphrase "some-passphrase" --no-use-agent 2>/dev/null
cleartext

Without “–no-use-agent”, you might very well be prompted by some system keyring/agent every time.