Skip to content

Instantly share code, notes, and snippets.

View kamilio's full-sized avatar
🇲🇽

Kamil Jopek kamilio

🇲🇽
View GitHub Profile
@kamilio
kamilio / repro-responses-google-nano-banana.mjs
Created February 3, 2026 16:10
Repro: AI SDK Responses via Poe API (google/nano-banana)
// Repro: AI SDK (OpenAI Responses) calling Poe API (google/nano-banana)
//
// Install (in an empty repo):
// npm i ai @ai-sdk/openai
//
// Run:
// node --env-file=.env tests/scripts/repro-responses-google-nano-banana.mjs
// or:
// POE_API_KEY=your_key node tests/scripts/repro-responses-google-nano-banana.mjs
@kamilio
kamilio / test-prompt-caching.mjs
Last active February 2, 2026 17:10
Test Anthropic prompt caching via Poe API
// Test prompt caching with Anthropic SDK via Poe API
//
// Run:
// node --env-file=.env tests/scripts/test-prompt-caching.mjs
// or:
// POE_API_KEY=your_key node tests/scripts/test-prompt-caching.mjs
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
@kamilio
kamilio / custom-thunk.js
Created May 10, 2016 16:08
Redux, eventBus solved with middlewares or without
// *** Middleware - custom thunk implementation (slightly diffferent though) - maybe more scalable appraoch
export default function createEventBusMiddleware(eventBus) {
return ({ dispatch, getState }) => (next) => (action) => {
// we could optimize further here and use rest operator to get all arguments and compose the middlewares
if (typeof action === 'function') {
return action({ dispatch, eventBus, getState });
}
return next(action);
};
@kamilio
kamilio / programmingWithFunctions.js
Last active August 29, 2015 14:19
Programming with Functions - Stuttgart JS Meetup
// ***************************
// Programming with functions (Kamil Jopek)
// Stuttgart JS Meetup Talk (13th April 2015)
// ***************************
// Basic functions
var add = function(a, b) {
return a + b;
};

How to configure gems

Are you writing a new gem and you are not sure how to let user configure it? Here is a short gist to show you how to do it. I like this style of configurations, inspired by many already existing gems such as Devise, Airbrake, PDFkit and many more.

# Configuration
MyShinyGem.configure do |config|
  config.binary = '/bin/ls'
 config.username = 'superuser'
RSpec::Core::RakeTask.module_eval do
def pattern
dir = EngineName.root # replace with you the name of your engine
extras = []
if File.directory?( dir )
extras << File.join( dir, 'spec', '**', '*_spec.rb' ).to_s
end
[@pattern] | extras
end
end