mirror of
https://github.com/jbranchaud/til
synced 2026-01-16 13:38:02 +00:00
Compare commits
5 Commits
40a7ade7f2
...
16155bd063
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16155bd063 | ||
|
|
c2f30615c3 | ||
|
|
f54eab20e7 | ||
|
|
b2ddce62fd | ||
|
|
460473a87f |
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||
|
||||
_1404 TILs and counting..._
|
||||
_1407 TILs and counting..._
|
||||
|
||||
---
|
||||
|
||||
@@ -1089,6 +1089,7 @@ _1404 TILs and counting..._
|
||||
- [Add Progress Reporting To Long-Running Script](ruby/add-progress-reporting-to-long-running-script.md)
|
||||
- [Are They All True?](ruby/are-they-all-true.md)
|
||||
- [Assert About An Object's Attributes With RSpec](ruby/assert-about-an-objects-attributes-with-rspec.md)
|
||||
- [Audit Your Ruby Project For Any CVEs](ruby/audit-your-ruby-project-for-any-cves.md)
|
||||
- [Assoc For Hashes](ruby/assoc-for-hashes.md)
|
||||
- [Block Comments](ruby/block-comments.md)
|
||||
- [Build HTTP And HTTPS URLs](ruby/build-http-and-https-urls.md)
|
||||
@@ -1396,6 +1397,7 @@ _1404 TILs and counting..._
|
||||
- [Partial String Matching In Bash Scripts](unix/partial-string-matching-in-bash-scripts.md)
|
||||
- [PID Of The Current Shell](unix/pid-of-the-current-shell.md)
|
||||
- [Print A Range Of Lines For A File With Bat](unix/print-a-range-of-lines-for-a-file-with-bat.md)
|
||||
- [Print DateTime Represented By Unix Timestamp](unix/print-datetime-represented-by-unix-timestamp.md)
|
||||
- [Print Milliseconds In Human-Readable Format](unix/print-milliseconds-in-human-readable-format.md)
|
||||
- [Print Out Files In Reverse](unix/print-out-files-in-reverse.md)
|
||||
- [Print The Current Date In Human-Readable Format](unix/print-the-current-date-in-human-readable-format.md)
|
||||
@@ -1426,6 +1428,7 @@ _1404 TILs and counting..._
|
||||
- [Tell direnv To Load The Env File](unix/tell-direnv-to-load-the-env-file.md)
|
||||
- [Touch Access And Modify Times Individually](unix/touch-access-and-modify-times-individually.md)
|
||||
- [Undo Some Command Line Editing](unix/undo-some-command-line-editing.md)
|
||||
- [Unrestrict Where ripgrep Searches](unix/unrestrict-where-ripgrep-searches.md)
|
||||
- [Update Package Versions Known By asdf Plugin](unix/update-package-versions-known-by-asdf-plugin.md)
|
||||
- [Use fzf To Change Directories](unix/use-fzf-to-change-directories.md)
|
||||
- [Use Regex Pattern Matching With Grep](unix/use-regex-pattern-matching-with-grep.md)
|
||||
|
||||
@@ -15,10 +15,8 @@ const remove = (items,index) => {
|
||||
};
|
||||
|
||||
const list = [1,2,3,4,5];
|
||||
remove(list, 2);
|
||||
// [1,2,3,4]
|
||||
list
|
||||
// [1,2,3,4,5]
|
||||
remove(list, 2); // [1,2,4,5]
|
||||
// list still [1,2,3,4,5]
|
||||
```
|
||||
|
||||
It only took a couple lines of code and immutability is baked in.
|
||||
|
||||
45
ruby/audit-your-ruby-project-for-any-cves.md
Normal file
45
ruby/audit-your-ruby-project-for-any-cves.md
Normal file
@@ -0,0 +1,45 @@
|
||||
# Audit Your Ruby Project For Any CVEs
|
||||
|
||||
The [`bundler-audit` gem](https://github.com/rubysec/bundler-audit) is a handy
|
||||
tool that you can run manually or integrate into your CI workflow to warn you
|
||||
about any CVEs in your dependencies.
|
||||
|
||||
Running this tool without any arguments will perform a check of your
|
||||
`Gemfile.lock` file. It will check against the
|
||||
[`ruby-advisory-db`](https://github.com/rubysec/ruby-advisory-db) for any CVEs
|
||||
linked to your dependencies, down to the patch-level.
|
||||
|
||||
```bash
|
||||
$ bundle exec bundler-audit
|
||||
|
||||
Name: puma
|
||||
Version: 4.3.12
|
||||
CVE: CVE-2024-21647
|
||||
GHSA: GHSA-c2f4-cvqm-65w2
|
||||
Criticality: Medium
|
||||
URL: https://github.com/puma/puma/security/advisories/GHSA-c2f4-cvqm-65w2
|
||||
Title: Puma HTTP Request/Response Smuggling vulnerability
|
||||
Solution: upgrade to '~> 5.6.8', '>= 6.4.2'
|
||||
|
||||
Vulnerabilities found!
|
||||
```
|
||||
|
||||
In this example run, a vulnerability was found in the currently installed
|
||||
version of the `puma` gem.
|
||||
|
||||
I believe a standard `bundler-audit` command will make sure the advisory DB is
|
||||
up-to-date, but to be sure, you can run the `update` command.
|
||||
|
||||
```bash
|
||||
$ bundle exec bundler-audit update
|
||||
|
||||
Updating ruby-advisory-db ...
|
||||
From https://github.com/rubysec/ruby-advisory-db
|
||||
* branch master -> FETCH_HEAD
|
||||
Already up to date.
|
||||
Updated ruby-advisory-db
|
||||
ruby-advisory-db:
|
||||
advisories: 884 advisories
|
||||
last updated: 2024-03-26 16:27:16 -0700
|
||||
commit: 840f21aeeb8a06a93a3c3bf1e2a92d7167029992
|
||||
```
|
||||
16
unix/print-datetime-represented-by-unix-timestamp.md
Normal file
16
unix/print-datetime-represented-by-unix-timestamp.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Print DateTime Represented By Unix Timestamp
|
||||
|
||||
A lot of tools and systems use a Unix timestamp to represent a point in time.
|
||||
It is the number of seconds since the Unix epoch (Jan 1, 1970). However, just
|
||||
looking at a timestamp like `1623867544` doesn't tell a human much. I can't
|
||||
mentally translate that to the date and time that it is representing.
|
||||
|
||||
The `date` utility can help. Give it the `-r` flag with the timestamp value (in
|
||||
seconds) and it will display the date and time in a human-readable format.
|
||||
|
||||
```bash
|
||||
❯ date -r '1623867544'
|
||||
Wed Jun 16 13:19:04 CDT 2021
|
||||
```
|
||||
|
||||
See `man date` for more details.
|
||||
33
unix/unrestrict-where-ripgrep-searches.md
Normal file
33
unix/unrestrict-where-ripgrep-searches.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# Unrestrict Where ripgrep Searches
|
||||
|
||||
One of the conveniences of [`rg`
|
||||
(ripgrep)](https://github.com/BurntSushi/ripgrep) is that by default it doesn't
|
||||
search in places you probably don't want it to search. That means it ignores
|
||||
anything specified by your `.gitignore` file, it excludes hidden files and
|
||||
directories (dotfiles, e.g. `.git/` or `.env`), and it excludes binary files.
|
||||
|
||||
These restrictions can be incrementally undone as needed using the `-u` flag.
|
||||
|
||||
The `-u` flag on its own will remove the ignored files restriction. This is
|
||||
equivalent to the `--no-ignore` flag.
|
||||
|
||||
```bash
|
||||
$ rg -u pattern
|
||||
```
|
||||
|
||||
Adding an additional `u` (`-uu`) to that flag will remove both the ignored files and
|
||||
hidden files restrictions. This is a shorthand equivalent to both `--no-ignore`
|
||||
and `--hidden`.
|
||||
|
||||
```bash
|
||||
$ rg -uu pattern
|
||||
```
|
||||
|
||||
Adding one more `u` (`-uuu`) will additionally remove the binary file
|
||||
restriction. Equivalent to those other two flags plus `--text`.
|
||||
|
||||
```bash
|
||||
$ rg -uuu pattern
|
||||
```
|
||||
|
||||
[source](https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md#automatic-filtering)
|
||||
Reference in New Issue
Block a user