Skip to content

Commit

Permalink
Merge branch 'main' of github.com:rnemeth90/rnemeth90.github.io
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan nemeth committed Dec 25, 2024
2 parents 994d9cd + 3acc2bd commit a26fa65
Show file tree
Hide file tree
Showing 398 changed files with 71,253 additions and 94,814 deletions.
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@
[submodule "themes/anubis"]
path = themes/anubis
url = https://github.com/mitrichius/hugo-theme-anubis.git
[submodule "themes/black-and-light"]
path = themes/black-and-light
url = https://github.com/davidhampgonsalves/hugo-black-and-light-theme.git
[submodule "themes/anubis2"]
path = themes/anubis2
url = https://github.com/Junyi-99/hugo-theme-anubis2.git
[submodule "themes/hugo-coder"]
path = themes/hugo-coder
url = https://github.com/rnemeth90/hugo-coder.git
Binary file added Screenshot 2024-09-04 at 11.13.40.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
109 changes: 109 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
languageCode = "en-us"
name = "GeekyRyan"
baseUrl = "https://rnemeth90.github.io"
title = "GeekyRyan"
theme = "hugo-coder"
paginate = 10
enableRobotsTXT = true

[pagination]
pagerSize = 10 # Added field from Coder theme

[services]
[services.disqus]
# Enable Disqus comments
# shortname = "yourdiscussshortname" # Added section from Coder theme

[markup.highlight]
style = "base16-snazzy"
noClasses = false # Added field from Coder theme

[markup.goldmark.renderer]
unsafe = true # enable raw HTML in Markdown

[params]
author = "Ryan Nemeth"
email = "[email protected]" # used for microformats
avatar = "/images/bobble.jpg" # used for microformats
description = "Ryan Nemeth's personal website"
keywords = "blog,developer,personal,devops"
info = ["Full Stack DevOps Engineer"]
avatarURL = "images/bobble.jpg" #
dateFormat = "2006-01-02"
name = "GeekyRyan"
paginationSinglePost = true
style = "dark"
readMore = true # show read more button
readNextPosts = 5 # show 5 related posts, 0 by default
disableSummary = false
copyCodeButton = true # true by default
rssAsSocialIcon = true
since = 2012
rtl = false # Added from Coder theme
colorScheme = "auto" # Added from Coder theme
hideColorSchemeToggle = false # Added from Coder theme
maxSeeAlsoItems = 5 # Added from Coder theme
customCSS = [] # Added from Coder theme
customSCSS = [] # Added from Coder theme
customJS = [] # Added from Coder theme
customRemoteJS = [] # Added from Coder theme

[[params.social]]
url = "https://github.com/rnemeth90/"
name = "Github"
icon = "fa-brands fa-github fa-2x"
weight = 1

# [[params.social]]
# name = "Twitter"
# icon = "fa-brands fa-x-twitter fa-2x"
# weight = 3
# url = "https://twitter.com/johndoe/" # Added from Coder theme

[[params.social]]
name = "LinkedIn"
icon = "fa-brands fa-linkedin fa-2x"
weight = 2
url = "https://www.linkedin.com/in/ryan-nemeth-b0b1504b/"

[[params.social]]
name = "RSS"
icon = "fa-solid fa-rss fa-2x"
weight = 3
url = "https://rnemeth90.github.io/index.xml"
rel = "alternate"
type = "application/rss+xml" # Added from Coder theme

[taxonomies]
category = "categories"
tag = "tags"
series = "series" # Added from Coder theme
author = "authors" # Added from Coder theme

[languages.en]
languageName = ":uk:"

[[languages.en.menu.main]]
name = "About"
weight = 1
url = "about/"

[[languages.en.menu.main]]
name = "Blog"
weight = 2
url = "posts/"

[[languages.en.menu.main]]
name = "Projects"
weight = 3
url = "projects/"

[[languages.en.menu.main]]
name = "Tags"
url = "/tags/"
weight = 4

# [[languages.en.menu.main]]
# name = "Contact me"
# weight = 5
# url = "contact/"
85 changes: 0 additions & 85 deletions config.yaml

This file was deleted.

72 changes: 72 additions & 0 deletions config.yaml.old
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
languageCode: 'en-us'
name: 'GeekyRyan'
baseUrl: 'https://rnemeth90.github.io'
title: 'GeekyRyan'
theme: 'anubis2'
paginate: 10
enableRobotsTXT: true

menu:
main:
- identifier: archive
name: Archive
title: Archive
url: /posts/
weight: 3
- identifier: about
name: About
title: about
url: /about
weight: 1
- identifier: tags
name: Tags
title: tags
url: /tags/
weight: 2

taxonomies:
category: 'categories'
tag: 'tags'

params:
author: 'Ryan Nemeth'
email: [email protected] # used for microformats
avatar: '/images/bobble.jpg' # used for microformats
description: ''
dateFormat: '2006-01-02'
name: 'GeekyRyan'
paginationSinglePost: true
style: dark
readMore: true # show read more button
readNextPosts: 5 # show 5 related posts, 0 by default
disableSummary: false
copyCodeButton: true # true by default
rssAsSocialIcon: true
utterancesRepo: '' # mandatory
utterancesTheme: '' # optional
utterancesIssue: '' # optional
utterancesLabel: '' # optional
isso:
enabled: true # mandatory
data: 'https://comments.example.com/' # mandatory
jsLocation: 'https://comments.example.com/js/embed.min.js' # mandatory
css: true # optional
lang: 'de' # optional
replyToSelf: true # mandatory
requireAuthor: true # mandatory
requireEmail: true # mandatory
id: 'thread-id' # optional
avatar: true # optional
avatar-bg: '#f0f0f0' # optional
feed: false # optional
graphcommentId: ''
social:
- id: github
name: rnemeth90

markup:
highlight:
style: 'base16-snazzy'
goldmark:
renderer:
unsafe: true # enable raw HTML in Markdown
Binary file added content/images/acr-403-02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/images/acr-403.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions content/posts/2024-03-27-golang-detect-file-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
title: 'Detecting MIME Types in Go'
author: Ryan
date: '2024-03-27'
layout: post
draft: false
categories:
- golang
- web development
- software development
tags:
- golang
- web development
- software development
- url
---

# Introduction

Knowing the type of a file you're working with is not just a matter of curiosity — it's often a necessity. This is especially true when you're deciding whether or not a particular operation can be carried out on that file. Go, with its comprehensive standard library, offers a straightforward approach to identifying a file's MIME type, ensuring that developers have the tools they need to make informed decisions about file manipulation. You may expect to find this functionality in the `file` package, but you'd be wrong! Read on...

## The net/http Package: Your Gateway to MIME Detection

At the heart of Go's approach to MIME type detection is the `net/http` package. This package provides everything developers need for identifying file types. The method in question, `DetectContentType()`, is nothing short of a detective dedicated to uncovering the secrets held within the first 512 bytes of a file.

Imagine you're downloading an image for processing from a URL, but before you proceed, you need to confirm its type. Here's how you'd *go* about it:

```
resp, err := client.Get("https://rnemeth90.github.io/images/synology-cloud-sync-01.png")
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
bytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
// detecting the MIME type
mimeType := http.DetectContentType(bytes)
fmt.Println(mimeType) // Voila! It's an image/png
```

In this snippet, `DetectContentType()` takes the stage, examining the initial bytes of the file and returning a MIME type, such as `image/png`. Should it find itself at a loss, unable to pin down the file's type, it defaults to `application/octet-stream`, a way of saying, "This is a file, but beyond that, you're on your own."

# Beyond the Basics: When You Need More

While `DetectContentType()` serves well for a number of common file types, its repertoire is not unlimited. There are scenarios where you might find yourself needing to identify more obscure or specific file types. This is where the mimetype library steps in, offering a more extensive catalog of file types. If `DetectContentType()` isn't able to help you, considering this library might just be your next move.

# Conclusion

Go's `net/http` package, with its `DetectContentType()` method, provides a solid foundation for this task. And for those times when you need to *go* further, the `mimetype` library is there to help.

Whether you're safeguarding against the wrong file types in an upload process or curating content based on its nature, understanding and utilizing MIME type detection is an invaluable skill. Thanks for reading!

Loading

0 comments on commit a26fa65

Please sign in to comment.