Skip to content

Instantly share code, notes, and snippets.

View huksley's full-sized avatar
🐈
Step on no pets

Ruslan Gainutdinov huksley

🐈
Step on no pets
View GitHub Profile
@huksley
huksley / claude-rename-images.js
Created October 15, 2024 12:53
Rename portraits with Claude. Reads directory of files with photos of a person and asks Claude to rename them according to the surrounding.
/* eslint-disable @typescript-eslint/no-require-imports */
const crypto = require("node:crypto");
const fs = require("node:fs");
const sharp = require("sharp");
const logger = console;
const Redis = require("ioredis");
const redis = new Redis(process.env.REDIS_URL || "redis://localhost:6379", {
enableOfflineQueue: true,
commandTimeout: 3000,
@huksley
huksley / ai-agents.md
Created October 13, 2024 07:58
AI agent infrastructure (from https://www.j12ventures.com/whatsnext)

Agents have arrived and they need their own picks and shovels

We’re seeing a strong wave of AI agent applications increasingly capable of taking on and automating complex workflows. A lot of what is driving this is taking place in the model layer - with frontier models better able to plan and reason. As Sam Altman has outlined, the emergence of better reasoning capabilities in models such as OpenAI o1 provides the foundation for potentially quick advancement to highly capable AI agents that can understand context, plan and reason in order to make decisions, and then take actions in order to achieve goals.

However, improved models alone will not deliver us advanced and autonomous agents, and, as of today, most models remain poor planners and low-level reasoners. This means that most AI agents are still susceptible to errors that become compounded across multi-step processes, meaning they are unable to reliably take on complex end-to-end tasks. As a result, an ecosystem of enabling software and new architec

Responsible AI in the Enterprise

As enterprises seek to gain AI maturity, and move along the path from experimentation to scaling applications, greater efficiency and success can be achieved through the establishment of a holistic Responsible AI approach to identifying opportunities and managing risks.

BCG defines Responsible AI (RAI) as “an approach to deploying AI systems that is aligned with the company’s purpose and values while still delivering transformative business impact.”

Put so succinctly, it sounds simple, but in practice, it entails establishing the following, across a large and complex organisation:

  • Strategy - Comprehensive AI strategy linked to the firm's values that ties back to risk strategy and ethical principles.
@huksley
huksley / testzod.ts
Created September 5, 2024 09:15
Zod do not plays well with default? catch?
import type { ZodSchema } from "zod";
// eslint-disable-next-line no-duplicate-imports
import { z } from "zod";
// Define a Zod schema
const userSchema = z.object({
// Fix 1. Do not use catch - wreks the input type https://github.com/colinhacks/zod/issues/2852
// Fix 2. Use optional() before default(), don't use at all???
page: z.number().default(1),
sort: z.string().optional(),
@huksley
huksley / testcontainer.js
Last active September 1, 2024 15:53
Test container withLogConsumer does not stream any logs
const { GenericContainer } = require("testcontainers");
const container = new GenericContainer("ubuntu:latest")
.withLogConsumer(consumer => {
consumer.on("data", data => {
console.log("LOG", data.toString());
});
consumer.on("err", data => {
console.log("ERR", data.toString());
});
@huksley
huksley / requestTracker.js
Last active August 20, 2024 07:40
Implementation of async NodeJS request tracing
/**
* Robust implementation of request tracing.
* Just add getRequestTracker().withRequest(req) at the first instance of incoming http request and
* it will persist request details during the whole request processing chain, async or not.
*
* Similar how AWS X-Ray works, or how NextJS 13+ cookies() method were implemented.
*
* Licensed under: MIT License
*
* Copyright (c) 2024 Ruslan Gainutdinov
@huksley
huksley / ai-use-cases.md
Created July 25, 2024 13:39
AI usecases from AWS GenAI survey

Which of the following best describes your organization’s current usage or future intentions for using generative AI for each of the following specific use cases?

  • Content categorization (e.g., auto-tagging and indexing media libraries, identifying medical or insurance codes, product descriptions, etc.)
  • Fraud detection and prevention (e.g., detecting fraud in financial services, healthcare claims/billing, etc.)
  • Chatbot/self-service for customer support (e.g., product help, searching documentation, etc.)
  • Quality control and anomaly detection
  • Customer feedback analysis
  • Generating marketing/sales content (e.g., blogs, proposals, articles, etc.)
  • Supply chain optimization and management (e.g., route optimization, loading schedules, etc.)
class Smoothmq < Formula
desc "Real-time message queue with persisted topics"
homepage "https://github.com/poundifdef/smoothmq"
url "https://github.com/poundifdef/smoothmq.git",
tag: "v0.2.3",
revision: "a023548ff08a8a8fab18b4e1011c81b56288a814"
license "MIT"
head "https://github.com/poundifdef/smoothmq.git", branch: "main"
depends_on "go" => :build
@huksley
huksley / Dockerfile
Created February 14, 2024 19:05
Simple PHP dokku application with a custom Docker container
FROM php:8.2-apache
RUN apt-get update && apt-get install -y \
libfreetype-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
@huksley
huksley / day-night-lighthouse-illustration-css.markdown
Created January 29, 2024 20:04
Day/Night Lighthouse Illustration - CSS