Skip to content

Instantly share code, notes, and snippets.

View HelgeSverre's full-sized avatar
🧠
LLMs gonna take our jewrbs.

Helge Sverre HelgeSverre

🧠
LLMs gonna take our jewrbs.
View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DnB Beat Generator Visualization</title>
<style>
body, html {
margin: 0;
overflow: hidden;
@HelgeSverre
HelgeSverre / AI.php
Created December 8, 2023 01:38
QUICK N DIRTY AI WRAPPER
<?php
namespace App;
use Illuminate\Support\Arr;
use OpenAI\Laravel\Facades\OpenAI;
use OpenAI\Responses\Chat\CreateResponse;
use Throwable;
class AI
@HelgeSverre
HelgeSverre / SelectorFinder.php
Created December 3, 2023 20:39
Experimental approach to selector finding using AI
<?php
namespace App\Scraping;
use App\HtmlCompressor;
use Closure;
use OpenAI;
use Spatie\Fork\Fork;
class SelectorFinder
@HelgeSverre
HelgeSverre / HtmlCompressor.php
Created December 3, 2023 20:36
Experimental code to compres HTML without losing the "structure", for a web scraping with ai use-case to reduce required token-usage.
<?php
namespace App;
use Illuminate\Support\Str;
use Symfony\Component\DomCrawler\Crawler;
class HtmlCompressor
{
protected bool $removeComments = true;
@HelgeSverre
HelgeSverre / Crawl.php
Created December 3, 2023 15:09
AI-Powered Web Crawler with crwlr/crawler
<?php
namespace App\Console\Commands;
use App\Crawler\ExtractWithAI;
use Crwlr\Crawler\HttpCrawler;
use Crwlr\Crawler\Steps\Html;
use Crwlr\Crawler\Steps\Loading\Http;
use Crwlr\Crawler\Stores\SimpleCsvFileStore;
use Crwlr\Crawler\UserAgents\BotUserAgent;
@HelgeSverre
HelgeSverre / pubspec.yaml
Created October 19, 2023 12:41
Adding Inter font to Flutter
# The package "google_fonts" has a bug related to font weights,
# dont bother using it, just do this instead:
# Click "Download Family" on https://fonts.google.com/specimen/Inter
# Unzip the file and throw the .ttf files into assets/fonts/
# Specify the Font family in your code like so:
# MaterialApp(theme: ThemeData(fontFamily: "Inter"));
## Then add this config to your pubspec.yaml file
flutter:
assets:
@HelgeSverre
HelgeSverre / PurchaseResource.php
Created September 23, 2023 10:56
How to group table rows in filamentphp by month and year
<?php
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Grouping\Group;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
class ReceiptResource extends Resource
{
<div>
@if ($data['nextInspection'])
<div
class="text-gray inline-flex items-baseline text-base font-semibold"
>
@if ($data['nextInspection']->isToday())
Your inspection is today!
@else
<span class="mr-2 text-xs font-medium text-gray-700">
{{ $data['nextInspection']->diffForhumans() }}
@HelgeSverre
HelgeSverre / OCR.txt
Created May 15, 2023 23:40
Receipt scanning with GPT-3 incl prompt
// Tokens: 371
// Characters: 833
BUNNPRIS BUNNPRIS LINDVIK Butikkdrift Akgeyik AS Foretaksregisteret ORG. NR. 813 499 002 MVA BEKKEVEIEN 14 5096. BERGEN TLF:55 29 78 67 SALGSKVITTERING Butikknr. 704 Butikknavn BUNNPRIS LINDVIK Kvitt. 1506131 23.02.2023 18:08:44 Operator 70445 Term. nr 7042 Herav mva 20.52 Ant. varer 5 *NIVEA ROLL-ON DRY COMFORT 50ML 20.93 *BLIW HANDSAPE MIKS 300ML 27.90 #MILK CHOCOLATE COOKIE AUNT MABEL 44.90 #KIMS POTETGULL PEPPER PUNCH 200G 32.90 3.00 *BAREPOSER TOTALT A BETALE 129.63 129.63 BANK MVA% Grunnlag MVA Totalt 41.46 10.37 51.83 *25.00 67.65 10.15 77.80 #15.00 Bax: 10309778-627085 23/02/2023 18:08 Overf.:400 BankAxent Contactless *******8867-7 AID: D5780000021010 Ref.: 999821 008352 KC1 TVR:8000008000 Resp.: 00 NOK KJOP 129,63 GODKJENT TAKK FOR HANDELEN Apent 09-22, lor 09-20 Besok OSS pa www.bunnpris.no B70470422302230150613
@HelgeSverre
HelgeSverre / AppServiceProvider.php
Created April 30, 2023 09:41
Allow relative links in FilamentPHP's RichEditor Field.
<?php
namespace App\Providers;
use Filament\Facades\Filament;
use Illuminate\Contracts\View\View;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{