Skip to content

Instantly share code, notes, and snippets.

View YannickFricke's full-sized avatar
:octocat:
A ❤️ for open source

Yannick Fricke YannickFricke

:octocat:
A ❤️ for open source
View GitHub Profile
@YannickFricke
YannickFricke / semantic_version.dart
Created November 17, 2024 09:40
Dart Semantic Version parser
final semanticVersionRegex = RegExp(
r'^'
r'(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)'
r'(?:-(?<preRelease>(?:[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)))?'
r'(?:\+(?<build>(?:[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)))?'
r'$',
);
/// Tries to parse the given [input] into a [SemanticVersion].
///
@YannickFricke
YannickFricke / elixir snippets.json
Created August 20, 2024 10:00
My VSCode Elixir snippets
{
"Inspect a value": {
"prefix": "ins",
"description": "Inspect a value with a label",
"body": [
"IO.inspect($1, label: \"$1\")"
]
},
"Pipe inspect": {
"prefix": "insp",
@YannickFricke
YannickFricke / utils.ex
Created July 18, 2024 15:29
Phoenix Utility methods
defmodule Utils do
@moduledoc """
## Usage
Could be imported in <project>/lib/my_app_web.ex for general access.
For example in controller/0
```elixir
import Utils
@YannickFricke
YannickFricke / twitch auth.ex
Created May 30, 2024 22:13
Twitch build authorization URL
@doc """
Builds an authorization URL which should be visited by users in order to connect Twitch to your application.
Reference: https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/#implicit-grant-flow
"""
@spec build_authorization_url(
client_id :: String.t(),
redirect_uri :: String.t(),
scopes :: list(Scope.t())
) :: String.t()
@YannickFricke
YannickFricke / flickering_effect.gd
Created May 24, 2024 14:20
Light2D flickering effect
extends Light2D
@export
var one_cycle_in_milliseconds = 1500
@export var min_alpha_number = 0
@export var max_alpha_number = 1
var intermediate_value = 0
@YannickFricke
YannickFricke / content_block.ex
Created December 23, 2023 18:33
Ecto CMS block data casting
defmodule Cms.ContentBlock do
@moduledoc false
use Ecto.Schema
import Ecto.Changeset
alias Cms.Blocks.TextBlock
@supported_block_types [
@YannickFricke
YannickFricke / day04.ex
Created December 5, 2023 22:15
AoC 2023 Day 4
defmodule AdventOfCode2023.Day04 do
@moduledoc false
require IEx
require Logger
def run do
input =
"lib/advent_of_code2023/inputs/04/part1.txt"
|> File.read!()
@YannickFricke
YannickFricke / HypeSocket.ts
Last active July 9, 2024 21:54
HypeRate Websocket
type ChannelSpecificCallback = (heartbeat: number) => void | Promise<void>;
type GeneralCallback = (
channel: string,
heartbeat: number,
) => void | Promise<void>;
/**
* An interface for describing the options which are needed by the HypeRateWebsocket
*
@YannickFricke
YannickFricke / day02.ex
Last active December 2, 2023 11:47
AoC 2023 Day 2
defmodule AdventOfCode2023.Day02 do
require Logger
def run() do
input =
File.read!("lib/advent_of_code2023/inputs/02/part1.txt")
|> String.trim()
|> String.split("\n", trim: true)
part1(input)
@YannickFricke
YannickFricke / day01.ex
Created December 1, 2023 14:28
AoC 2023 Day 01
defmodule AdventOfCode2023.Day01 do
def run() do
part1()
part2()
end
defp part1() do
File.read!("lib/advent_of_code2023/inputs/01/part1.txt")
|> String.trim()
|> String.split("\n", trim: true)