Preview Github-flavored Markdown from the bash with ianks/octodown
Preview what your markdown would look like on Github. Helpful e.g. when writing or extending a Readme for your gem or projects.
Installation
sudo apt-get install cmake libicu-dev # required for building native extensions
gem install octodown
Know that this will install at least 12 other gems. However, the beautiful output should be worth it.
Usage
octodown README.md
Related cards:
Migrate gem tests from Travis CI to Github Actions with gemika
We currently test most of our gems on Travis CI, but want to migrate those tests to Github Actions. This is a step-by-step guide on how to do this.
Note that this guide requires the gem to use gemika.
- Go...
How to remove entries from the bash history
Sometimes you accidentally generate entries in the bash history that you do not want to have there (e.g. commands with credentials).
Here's how to remove single entries.
You can look at the bash history with the history
command.
To see e.g. th...
Bash: Build and execute command lines on the fly with "xargs"
xargs
is a powerful bash tool that can take input from $STDIN and pass it to a given command. I.e. you can do the following:
$> cat tmp/parallel_cucumber_failures.log
features/authentication.feature:33
features/backend/pages.feature:5
featu...
Find the newest file from shell
This can be helpful when you need the latest file inside a directory for processing in a shell script:
ls -1tr * | tail -1
Used switches
The -1
switch makes ls
return 1 file per line, -t
orders by modification time and...
Exclude your staging site from Google with robots.txt and not shoot yourself in the foot
If you want to exclude your staging site from Google using robots.txt
without running the risk to forget deleting the file once you go live, name the file robots.exclude.txt
instead.
In your Apache Vhost config, rewrite requests for the stagi...
Bash: How to count and sort requests by IP from the access logs
Example
87.140.79.42 - - [23/Jan/2024:09:00:46 +0100] "GET /monitoring/pings/ HTTP/1.1" 200 814 "-" "Ruby"
87.140.79.42 - - [23/Jan/2024:09:00:46 +0100] "GET /monitoring/pings/ HTTP/1.1" 200 814 "-" "Ruby"
87.140.79.41 - - [23/Jan/2024:09...
Working on the Linux command line: How to bash `cd` with autocorrect
There is an option you can set so that when using the cd
command, small typos are automatically corrected. Add the following to your ~/.bashrc
:
# cd: autocorrect small typos and use best guess
shopt -s cdspell
Example:
cd P...
Rails: Example on how to extract domain independent code from the `app/models` folder to the `lib/` folder
This cards describes an example with a Github Client on how to keep your Rails application more maintainable by extracting domain independent code from the app/models
folder to the lib/
folder. The approach is applicable to arbitrary scenarios...
Instant Markdown previews from Vim
Live markdown previewer (with Github flavored syntax) for VIM.
Will open a preview in your browser and update automatically on each key press.
Security issues with hash conditions in Rails 2 and Rails 3
Find conditions for scopes can be given either as an array (:conditions => ['state = ?', 'draft']
) or a hash (:conditions => { 'state' => 'draft' }
). The later is nicer to read, but has horrible security implications in some versions of Ru...