mirror of
https://github.com/jbranchaud/til
synced 2026-01-20 23:48:02 +00:00
Compare commits
1 Commits
781f1827c8
...
7c41c38d13
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c41c38d13 |
@@ -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).
|
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||||
|
|
||||||
_1498 TILs and counting..._
|
_1496 TILs and counting..._
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -395,7 +395,6 @@ _1498 TILs and counting..._
|
|||||||
|
|
||||||
- [Access Go Docs Offline](go/access-go-docs-offline.md)
|
- [Access Go Docs Offline](go/access-go-docs-offline.md)
|
||||||
- [Build For A Specific OS And Architecture](go/build-for-a-specific-os-and-architecture.md)
|
- [Build For A Specific OS And Architecture](go/build-for-a-specific-os-and-architecture.md)
|
||||||
- [Do Something N Times](go/do-something-n-times.md)
|
|
||||||
- [Find Executables Installed By Go](go/find-executables-installed-by-go.md)
|
- [Find Executables Installed By Go](go/find-executables-installed-by-go.md)
|
||||||
- [Not So Random](go/not-so-random.md)
|
- [Not So Random](go/not-so-random.md)
|
||||||
- [Replace The Current Process With An External Command](go/replace-the-current-process-with-an-external-command.md)
|
- [Replace The Current Process With An External Command](go/replace-the-current-process-with-an-external-command.md)
|
||||||
@@ -441,7 +440,6 @@ _1498 TILs and counting..._
|
|||||||
### Internet
|
### Internet
|
||||||
|
|
||||||
- [Add Emoji To GitHub Repository Description](internet/add-emoji-to-github-repository-description.md)
|
- [Add Emoji To GitHub Repository Description](internet/add-emoji-to-github-repository-description.md)
|
||||||
- [Add Styled Alerts To GitHub Markdown Documents](internet/add-styled-alerts-to-github-markdown-documents.md)
|
|
||||||
- [Analyze Your Website Performance](internet/analyze-your-website-performance.md)
|
- [Analyze Your Website Performance](internet/analyze-your-website-performance.md)
|
||||||
- [Check Your Public IP Address](internet/check-your-public-ip-address.md)
|
- [Check Your Public IP Address](internet/check-your-public-ip-address.md)
|
||||||
- [Digraph Unicode Characters Have A Titlecase](internet/digraph-unicode-characters-have-a-titlecase.md)
|
- [Digraph Unicode Characters Have A Titlecase](internet/digraph-unicode-characters-have-a-titlecase.md)
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
# Do Something N Times
|
|
||||||
|
|
||||||
With Go 1.23 there is a new for-range syntax that makes looping a bit easier
|
|
||||||
and more compact.
|
|
||||||
|
|
||||||
Instead of needing to set up our 3-part for-loop syntax, we can say we want to
|
|
||||||
do something `N` times with `for range N`.
|
|
||||||
|
|
||||||
```go
|
|
||||||
for range n {
|
|
||||||
// do something
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Let's look at an actual, runnable example:
|
|
||||||
|
|
||||||
```go
|
|
||||||
package main
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
import "math/rand"
|
|
||||||
import "time"
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
|
|
||||||
food := []string{"taco", "burrito", "torta", "enchilada", "tostada"}
|
|
||||||
|
|
||||||
for range 5 {
|
|
||||||
randomIndex := rand.Intn(len(food))
|
|
||||||
fmt.Println(food[randomIndex])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
The output is random and might look something like this:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ go run loop.go
|
|
||||||
taco
|
|
||||||
burrito
|
|
||||||
tostada
|
|
||||||
taco
|
|
||||||
enchilada
|
|
||||||
```
|
|
||||||
|
|
||||||
I appreciate this syntax addition because it feels very akin to Ruby's `#times`
|
|
||||||
method:
|
|
||||||
|
|
||||||
```ruby
|
|
||||||
5.times do
|
|
||||||
# do something
|
|
||||||
end
|
|
||||||
```
|
|
||||||
|
|
||||||
[source](https://eli.thegreenplace.net/2024/ranging-over-functions-in-go-123/)
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
# Add Styled Alerts To GitHub Markdown Documents
|
|
||||||
|
|
||||||
The GFM (GitHub Flavored Markdown) variant of markdown adds some nice features
|
|
||||||
to our GitHub-rendered markdown documents.
|
|
||||||
|
|
||||||
One such feature that has been around for a couple years, but which I only just
|
|
||||||
learned about, are these styled alerts. There are five of them each with a
|
|
||||||
different color and icon to help convey meaning.
|
|
||||||
|
|
||||||
```
|
|
||||||
> [!NOTE]
|
|
||||||
> Useful information that users should know, even when skimming content.
|
|
||||||
|
|
||||||
> [!TIP]
|
|
||||||
> Helpful advice for doing things better or more easily.
|
|
||||||
|
|
||||||
> [!IMPORTANT]
|
|
||||||
> Key information users need to know to achieve their goal.
|
|
||||||
|
|
||||||
> [!WARNING]
|
|
||||||
> Urgent info that needs immediate user attention to avoid problems.
|
|
||||||
|
|
||||||
> [!CAUTION]
|
|
||||||
> Advises about risks or negative outcomes of certain actions.
|
|
||||||
```
|
|
||||||
|
|
||||||
I just added the following to the top of one of my project's READMEs to help me
|
|
||||||
remember that it is not under active development.
|
|
||||||
|
|
||||||
```
|
|
||||||
> [!WARNING]
|
|
||||||
> This repo is not under active development, you might be looking for
|
|
||||||
> [til-visualmode-dev](https://github.com/jbranchaud/til-visualmode-dev).
|
|
||||||
```
|
|
||||||
|
|
||||||
Visit the GitHub docs for
|
|
||||||
[Alerts](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts)
|
|
||||||
to see examples of how these render.
|
|
||||||
|
|
||||||
[source](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts)
|
|
||||||
Reference in New Issue
Block a user