Skip to content

Instantly share code, notes, and snippets.

View lukas-h's full-sized avatar
🎯
Focusing

Lukas Himsel lukas-h

🎯
Focusing
  • Nuremberg, Germany
  • 21:14 (UTC +01:00)
View GitHub Profile
@lukas-h
lukas-h / auth.js
Created November 19, 2024 05:54
DecapCMS Cloudflare Functions
export async function onRequest(context) {
const {
request, // same as existing Worker API
env, // same as existing Worker API
params, // if filename includes [id] or [[path]]
waitUntil, // same as ctx.waitUntil in existing Worker API
next, // used for middleware or to fetch assets
data, // arbitrary space for passing data between middlewares
} = context;
@lukas-h
lukas-h / config.yml
Created November 19, 2024 05:43
DecapCMS Config
# admin/config.yml
backend:
name: github
repo: biralo-studio/biralo-studio
branch: main
site_domain: https://biralo.studio
base_url: https://biralo.studio
auth_endpoint: /api/auth
media_folder: assets/images
public_folder: /assets/images
@lukas-h
lukas-h / repro_futures_individual_await.dart
Created November 7, 2024 14:20
Future.wait vs individual await
// ignore_for_file: unused_local_variable
Future<void> main() async {
final start = DateTime.now();
final firstFuture = Future<int>.delayed(const Duration(seconds: 1), () => 1);
final secondFuture = Future<double>.delayed(const Duration(seconds: 1), () => 1.0);
final thirdFuture = Future<String>.delayed(const Duration(seconds: 1), () => '1');
// static types are given
@lukas-h
lukas-h / counter_cubit.dart
Last active November 4, 2024 15:41
BloC Workshop
import 'package:bloc/bloc.dart';
// Business LOgic Component
class CounterCubit extends Cubit<int> {
CounterCubit(int? initialValue) : super(initialValue ?? 0);
void increment() {
emit(state + 1);
}
@lukas-h
lukas-h / async_data_structures.dart
Last active November 4, 2024 12:25
Flutter Workshop 2024 Q1
import 'dart:math';
Future<int> asyncFunc() async {
final a = Future<int>.delayed(const Duration(seconds: 3), () => 10);
final result = await a;
return result;
}
Future<void> main() async {
/*
import 'package:cron_consume_microservice/cron_consume_microservice.dart'
as cron_consume_microservice;
import 'dart:convert';
import 'dart:io';
import 'package:shelf/shelf.dart' as shelf;
import 'package:shelf/shelf_io.dart' as io;
import 'package:shelf_router/shelf_router.dart';
void main(List<String> arguments) {
import 'package:flutter/material.dart';
class EditorScreen<T> extends StatefulWidget {
final double height;
final double width;
final Widget Function(BuildContext context, T? data) builder;
const EditorScreen({
Key? key,
this.height = 200,
@lukas-h
lukas-h / Dockerfile
Created May 7, 2024 13:01
Python PIP Dockerfile
dockerfile
# Use a Python base image matching your project's Python version
FROM python:3.9
# Set the working directory to /app
WORKDIR /app
# Copy the requirements file into the container
COPY requirements.txt .
@lukas-h
lukas-h / enum.dart
Created May 2, 2024 19:09
enum de-serialization :'(
enum TimerState {
eric('stopped'),
idle('stopped'),
running('running'),
paused('paused'),
finished('finished');
final String serializeName;
const TimerState(this.serializeName);
@lukas-h
lukas-h / README.md
Last active April 12, 2024 09:37
Discord Motivational Gong Bot (on pull request merge)
  1. Put the gong-bot.yml in the folder .github/workflows in your repository
  2. Add a new webhook in the Discord Server Settings > Integrations > Webhooks
  3. Copy the webhook url
  4. Add the secret DISCORD_WEBHOOK in your GitHub repository Actions secrets

This is the gong gif: