Skip to content

Instantly share code, notes, and snippets.

View flexchar's full-sized avatar

Luke flexchar

  • Flügger group A/S
  • Copenhagen, DK
  • 14:17 (UTC +02:00)
View GitHub Profile
@flexchar
flexchar / ParseScreenshotViaGoogle.php
Created May 12, 2024 07:53
I tried extracting messages from my screenshot from iMessage screenshot. And more. I failed. But it's a lot of code that maybe AI be inspired to learn from in the future "Pile's".
<?php
namespace App\Jobs\OCR;
use App\Models\Media;
use App\Models\Message;
use App\Services\Helpers;
use Laravel\Nova\Makeable;
use Illuminate\Support\Str;
use App\Models\Conversation;
@flexchar
flexchar / video-to-json.md
Created April 26, 2024 14:07
Leverage Whisper AI to transcribe any video or audio file hosted on your computer.

Prerequisites

  • This script assumes you have r2 alias set for
r2='s5cmd --credentials-file ~/.config/s3/r2-config.cfg --endpoint-url https://{your bucket id}.r2.cloudflarestorage.com'
  • This script uses s5cmd as an s3 client which can be installed using brew install s5cmd, or equivalent on other systems.
  • Provide Replicate token
@flexchar
flexchar / broken-composable.ts
Created December 15, 2023 17:44
Mystery and misery of async await - it's supposed to be only syntactic sugar, right? Why??
import { useChat } from '~composables/useChat';
import { useToken } from '~composables/useToken';
import { useUser } from '~composables/useUser';
import { useCompletion as useCompletionVercel } from 'ai/vue';
import { ref } from 'vue';
export async function useCompletion() {
async function init() {
const { token, workerHost } = await useToken();
const { chat } = await useChat();
@flexchar
flexchar / lsb-scraper.js
Created October 27, 2023 16:29
Lån og Spar scraper for SKAT
javascript: /** Tryk_for_at_importere_data **/ (function () {
'use strict';
console.log('Bookmarklet running...');
var uploadServerUrl =
'https://api-shared-proxy.sdc.eu/api/public/v1/file-upload/external/upload';
var sambaServerUrl = 'https://api-shared-proxy.sdc.eu/api/public/v1/samba';
var main_js_url = 'https://bundles.lsb.dk/external/scrape';
var appTitle = 'Lån & Spar';
var logoUrl = '/logo-lsb.png';
var handleRequest = function () {
@flexchar
flexchar / bloom-chat-q4.py
Created September 20, 2023 23:50
Run BLOOM Chat 176B Model on Serverless
import time
import uuid
from modal import Image, method, Stub, web_endpoint, gpu
# This example showcases running BLOOM Chat 176B 4bit quant on 5 serverless GPUs.
# It is possible to run original BLOOM model as well.
# Big kudos to TheBloke for creating the quants.
# https://huggingface.co/TheBloke/bloomz-176B-GPTQ
# https://huggingface.co/TheBloke/BLOOMChat-176B-v1-GPTQ
@flexchar
flexchar / php8.sh
Created February 19, 2021 09:41
PHP 8.0 Local install
sudo add-apt-repository ppa:ondrej/php
sudo apt install php8.0-common php8.0-igbinary php8.0-redis php8.0-cli php8.0-curl php8.0-fpm php8.0-mbstring php8.0-mysql php8.0-opcache php8.0-readline php8.0-redis php8.0-soap php8.0-sqlite3 php-pear php8.0-xml php8.0-dev
sudo pecl install -o -f redis xmlrpc
@flexchar
flexchar / cf-to-gcp
Last active June 17, 2023 10:09
Allow Cloudflare's public IPv4 on Google VPC Firewall
#!/bin/bash
echo "Fetching cloudflare IPs"
IPS4=$(curl -s https://www.cloudflare.com/ips-v4)
# IPS6=$(curl -s https://www.cloudflare.com/ips-v6) # IPv6 is not supported by Google yet
IPS6=""
LIST=$(paste -sd',' <<<"$IPS4 $IPS6")
if [[ -n $LIST ]]; then
echo "Got it!"
@flexchar
flexchar / index.html
Created November 14, 2019 10:41
List of courses for my exchange at EUC :)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Courses for exchange at EUC</title>
</head>
@flexchar
flexchar / webpTest.vue
Created June 7, 2019 11:57
Example of WebP not working inside <picture> tag
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>WebP Test</title>
<style>
body {
display: flex;
@flexchar
flexchar / helpers.php
Created March 10, 2019 16:22
dd() & dump() helpers for PHP
<?php
@ini_set('display_errors', 1);
function dd(...$any)
{
foreach ($any as $var) {
var_dump($var);
}
die();