Misc
A section dedicated to other applications and tools worth getting to know.
keka
Keka is an amazing application, that was suggested to me by one of my IT professors at USC.
-
Getting Started
brew cask install keka kekadefaultapp
Then, open keka
, configure your preferences, and set keka to be your default app. Now you can compress and decompress any file on your computer by pressing ⌃ ⇧ K
keka
will automatically know which action to perform based on the file it received as input. It will use the configurations you specified in the app. I recommend GNU's .gzip
files because they use an algorithm that is superior in compression to the one used in Microsoft's .zip
filetype. Also, because tar
uses gzip
so it's a good idea to get started.
figlet
figlet
I/O
You can use figlet
to convert any string into a lovely piece of ASCII art.
figlet 'Hello World'
_ _ _ _ _
| |__ ___| | | ___ __ _____ _ __| | __| |
| '_ \ / _ \ | |/ _ \ \ \ /\ / / _ \| '__| |/ _` |
| | | | __/ | | (_) | \ V V / (_) | | | | (_| |
|_| |_|\___|_|_|\___/ \_/\_/ \___/|_| |_|\__,_|
Window Management Applications
This is a great app that my friend Russel Wakugawa showed me. If you work on a laptop, managing your screen space is important. Unfortunately there aren't many built-in keybindings to resize and maximize applications. Although the gesture-based resizing is graceful and pretty, they aren't very useful because the animations are so slow.
An important update: Spectacle is no longer maintained. I encourage you to use Moom as an alternative instead. I've found it to be even better than Spectacle
lsyncd
The lsyncd
program allows bi-directional syncing of files between a local and remote host. If you have a folder that you make changes to often, it would be useful to just change once, update everywhere.
-
Installing
lsyncd
# macOS brew install lsyncd # Debian distro apt install lsyncd
Mutt
-
Installing
mutt
# Using Mutt brew install mutt # Using NeoMutt brew install neomutt
-
Example configuration file
set realname = "Tommy Trojan" set smtp_url = "smtp://tommytrojan@smtp.mail.me.com:587/" set smtp_pass = "1234-abcd-1234-abcd" set smtp_authenticators = 'gssapi:login' set imap_user = "tommytrojan" set imap_pass = "1234-abcd-1234-abcd" set from = "tommytrojan@icloud.com" set folder = "imaps://tommytrojan@imap.mail.me.com:993" set spoolfile = "+INBOX" set postponed = "+Drafts" set record = "+Sent Messages" set trash = "+Trash" unset beep_new # Don't beep for new messages set imap_pipeline_depth = 0 set header_cache = "$XDG_CACHE_HOME/mutt/headers" set message_cachedir = "$XDG_CACHE_HOME/mutt/bodies" set certificate_file = "$XDG_CACHE_HOME/mutt/certificates" set sort=reverse-date-sent set assumed_charset="utf-8" set attach_charset="utf-8" set charset="utf-8" # Don't try to add a copy to sent folder (throws error in batch mode) set copy = no # Don't include original message in reply unset include # Don't show the help menu at the top of the screen unset help # Configure keybindings bind index = noop bind index g first-entry bind pager g top bind index * noop bind index G last-entry bind pager G bottom bind pager <Down> next-line bind pager j next-line bind pager <Up> previous-line bind pager k previous-line bind index o display-message bind index n noop bind index m mail bind index,pager \Cwq quit # Configure inbox style color indicator brightblue default
ImageMagick
-
Compress a PDF to a smaller size file
convert 'input.pdf' -format 'PDF' -quality 10 'output.pdf'
-
Combine multiple images into a single PDF
magick *.jpg combined.pdf
Hugo
-
Generate bash autocompletions for Hugo
sudo hugo gen autocomplete --type bash --completionfile /usr/local/etc/bash_completion.d/hugo.sh
JetBrains
Useful subcommands exist for the following IDE command-line interfaces:
If you specify a directory with an existing project, the IDE opens this project.
If you open a directory that is not a part of a project, the IDE adds the .idea
directory to it, making it a project.
-
Open a project (this one) in Webstorm without showing the splash loading screen
webstorm ~/.wiki --nosplash --wait
Path Variables
-
Pre-defined path variables include
$USER_HOME$
,$PROJECT_DIR$
, and$MODULE_DIR$
TinyPNG
REST APIs
An Application Programming Interface or API is a set of rules that lets programs talk to each other, exposing data and functionality across the internet in a consistent format.
APIs accessed through HTTP typically use Representational State Transfer or REST. This is an architectural pattern that describes how distributed systems can expose a consistent interface. When people use the term ‘REST API,’ they are generally referring to an API accessed via HTTP protocol at a predefined set of URLs.
These URLs represent various resources - any information or content accessed at that location, which can be returned as JSON, HTML, audio files, or images. Often, resources have one or more methods that can be performed on them over HTTP, like GET, POST, PUT and DELETE.
-
-
Add the HTTP header
Authorization: Basic ${token}
-
Generate HTTP header for basic authentication by base64 encoding the username and password
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==username='Alladin' password='open sesame' token=$(base64 -w 0 < =(<<<${username}:${password})) auth="Authorization: Basic ${token}"
-
Copy it to clipboard immediately
pbcopy < =(<<<"Basic $(base64 -w 0 < =(<<<${username}:${password}))")
-
Twilio
-
How to look up a phone number using the Twilio CLI
twilio api:lookups:v1:phone-numbers:fetch --phone-number '+15551234567' --type=carrier --type=caller-name
GitHub
When creating a linking a file hosted on GitHub, you can add a highlight to the relevant lines of code using a
Google Search
You can view Google's own documentation on search operators, but they leave a lot of them out. I've included some of my favorites below:
-
intext:
- require results to include a keyword within the text body
-
intitle:
- require results to include a keyword within the title
-
inurl:
- require results to include a keyword within the URL
-
related:
- find the landing page for websites of alternatives to
slack.com
withrelated:slack.com
- find the landing page for websites of alternatives to
-
cache:
- View the copy of the website from Google's cache
Also, I've written down two search operators that I'm convinced very few self-proclaimed search masters are aware of. These are two search operators that were added in 2018, that most people haven't caughten drift of just yet.
-
after:
-
Search for results before a date with
before:
- For example, searching for events before 2010 would be
before:2010
- For example, searching for events before 2010 would be
-
Search for results after a date with
after:
- For example, searching for events after 2018 would be
after:2018
- For example, searching for events after 2018 would be
-
Clever combined usage of search operators, and be amazed by how precise the returned results are
"whenever * says * I *"
- You can use either the
filetype:pdf
orext:pdf
operators, both return the same results, but theext:
is a little more strict about returning only files of the specified kind
They're also rolling out a new feature called Google Collections which allows you to save images without downloading, pretty neat.
You can reverse search for images at images.google.com
, details provided in their support documentation
-
Breakdown of the query string. For each of these query string parameters, assume the provided value is
foo+bar
, such asparam=foo+bar
. Each word is concatenated with the+
character.-
as_epq
: Results must include each word, and all must be in the provided order -
as_oq
: Results must include one or more of the words provided -
as_eq
: Results most not include any of the words provided -
num
: Controls the number of results that appear -
as_filetype
: Equivalent to thefiletype:
search operator -
as_sitesearch
: Equivalent to thesite:
search operator -
as_qdr
: Limit results to those first indexed by...-
d
: The past day -
w
: The past week -
m
: The past month -
y
: The past year
-
-
as_rights=cc_publicdomain
- Limit results to content free to use from the public domain.
-
as_lq
- Find sites that link to the URL you put in
-
pws
- Whether or not the search should be personalized,
1
to enable,0
to disable
- Whether or not the search should be personalized,
-
hl
- Determines the language of the search interface
-
lr
- Limits results to a particular language. For example, a value of
lang_en
would limit results to those that are written in English
- Limits results to a particular language. For example, a value of
-
cr=countryXX
: Only show results from the countryXX
whereXX
is replaced with that country's ISO 3166-1 country code
-
Selenium
-
Enable the safari webdriver
safaridriver --enable
-
Create a webdriver
#Simple assignment
from selenium.webdriver import Safari
driver = Safari()
driver.get('https://google.com')
print(driver.current_url)
- Quit the webdriver
driver.quit()
WebP
A new image format for the web
Getting Started
The version installed from Homebrew opts out of some fun features like converting GIF files to WebP format. For this reason, I've decided to learn how to build this library from source, and have included the instructions below for others to follow along with.
-
Install latest version of
libwebp
:mkdir -p ~/.local/opt/libwebp url='https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.1.0-mac-10.15.tar.gz ' curl ${url} > ~/Downloads/libwebp.tgz tar xf ~/Downloads/libwebp.tgz -C ~/.local/opt mv ~/.local/opt/libwebp{*(/),} < =(<<<'path=(~/.local/opt/libwebp/bin ${path})') >> ~/.zshrc
-
Enable optional packages in the
libwebp
installation:./configure --prefix=${HOME}/.local --enable-everything
cwebp
Encoder
-
Compress PNG file
image.png
to WebP fileimage.webp
(with quality range of 80)cwebp -q 80 image.png -o image.webp
-
Compress PNG file
image.png
to WebP fileimage.webp
# quality: 100 # width: 1920 # height: auto-fit cwebp -q 100 -resize 1920 0 image.png -o image.webp
-
Compress JPG file
image.jpg
to WebP fileimage.webp
cwebp \ -noalpha \ -hint 'photo' \ -jpeg_like \ -m 6 \ -q 90 \ -alpha_filter 'best' \ -metadata 'all' \ -mt \ 'image.jpg' \ -o 'image.webp'
-
Crop a
500x1000
photo so that10px
are cut off from all four sidescwebp \ -crop 10 10 480 980 \ image.jpg \ -o image.webp
dwebp
Decoder
-
Decode WebP file
image.webp
to PNG fileimage.png
dwebp image.webp -o image.png
Utility Commands
-
Convert a file to WebP, with the same filename, but with
.webp
extensioncwebp ~/Downloads/file.jpg -o !{#^:r}.cwebp
-
Convert the most recently created file
cwebp ~/Downloads/*(om[1]) -o image.cwebp
Looping
-
Compress a series of images into the animated WebP format
img2webp -lossy -d 1000 -m 6 -loop 0 'one.jpg' 'two.jpg' -o ~/Downloads/mowgli.webp
Slack
Slack supports URL Schemes, which they document on their developer API site
-
Link to a conversation with a specific user, in a particular workspace
user_id=W01543F37L3 workspace_id=T019B257FQT open "slack://user?team=${workspace_id}&id=${user_id}"
Fonts
-
Decompress WOFF2 font face into its original file format (TTF or OTF)
brew install woff2 woff2_decompress 'font.woff2'
Firefox
Hidden Keyboard Shortcuts
To copy the location behind a hyperlink, do the following:
- Hover the cursor over the link
- Right click (or ⌃ Left-Click)
- Type a
Google Chrome uses c
, which is what you would normally expect to select a command titled Copy Link Address. If you're curious, you can check out why a was chosen. Personally, I feel it's a discussion worth reading.
Search Operators
Mozilla Firefox
When using the address bar to search, you can filter the results suggested using a set of special characters separated by spaces
Operator | Searches for results in... |
---|---|
^ |
browsing history |
* |
bookmarks |
+ |
bookmarks with matching tags |
% |
currently open tabs |
$ |
in the URL |
? |
in search suggestions |
# |
with every term matching title/tag |
-
Search bookmarks for
mozilla
* mozilla
-
Search browsing history for
react
^ react
-
Search for results containing
giphy
in the URL$ giphy
Google Chrome
The shortcuts above require a little more configuration in order to be usable on Google Chrome. To be able to search bookmarks, you'll want to visit chrome://settings/searchEngines, add a search engine, and provide it with the URL chrome://bookmarks/?#q=%s. The %s
should be provided as-is, but it will expand to contain the contents of your query when you are performing a search using this search engine.
You can search history as well. The process is very similar: simply repeat the steps outlined above, and provide the following URL: chrome://history/?#q=%s.
Quick Find
Some websites use /
as the keyboard shortcut to focus the cursor on the main search bar of the page. The problem, however, is that Firefox uses /
as the keyboard shortcut for Quick Find, and intercepts a user when they press /
.
To disable the usage of /
by Firefox
- Go to
about:config
- Search for
accessibility.typeaheadfind.manual
- Set its value to
false
youtube-dl
-
Custom config file location
youtube-dl --config-location FILE
Audio can be extracted using the -x
or --extract-audio
option
QR Code Generator
Stumbled upon the amzqr project and I found it absolutely delightful.
-
Installing
amzqr
pip install amzqr
-
Creating a QR code with an image embedded inside of it:
amzqr -p IMAGE 'https://URL'