Skip to content

Instantly share code, notes, and snippets.

View amol-'s full-sized avatar

Alessandro Molina amol-

View GitHub Profile
@amol-
amol- / fetch-request-fix.ts
Created May 17, 2026 14:33
pi extension to fix mistral
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
const PATCH_APPLIED = Symbol.for("amol.pi.fetch-request-fix");
export default function (_pi: ExtensionAPI) {
const state = globalThis as typeof globalThis & { [PATCH_APPLIED]?: boolean };
if (state[PATCH_APPLIED]) return;
const originalFetch: typeof fetch = globalThis.fetch.bind(globalThis);
@amol-
amol- / gist:d9dad7d98656ab02c56d44f50fd9c613
Last active November 8, 2024 18:03
Claude and Timeseries Linechart

First Iteration

Prompt

I have a JSON based api http://localhost:3000/dashboard/get_timings?project_id=${project_id}&identifier=${metric_name}&start_time=${iso8601_date}&end_time=${iso8601_date} that returns a set of values associated with a timestamp.

The response format is {"timings": [{"timestamp": iso8601_date, "value": float_value}, ...]}

Generate a web page that shows a line chart loading the data from such an API.
std::vector<Int64Builder> builders(num_chunks);
ChunkResolver index_resolver(values.chunks());
for (int64_t requested_index = 0; requested_index < num_indices; ++requested_index) {
uint64_t index = poc_get_index(indices, requested_index);
ChunkLocation resolved_index = index_resolver.Resolve(index);
int64_t chunk_index = resolved_index.chunk_index;
if (chunk_index < 0) {
// ChunkResolver doesn't throw errors when the index is out of bounds
@amol-
amol- / request_validation.py
Created September 3, 2019 21:20
Test TurboGears request.validation in minimal mode
from wsgiref.simple_server import make_server
import tg
from tg import RestController, expose, validate, MinimalApplicationConfigurator
from formencode import validators
class RootController(RestController):
@expose('json')
@amol-
amol- / HelloWorld.jsx
Last active January 23, 2017 00:36
Isomorphic React applications in Python
export class HelloWorld extends React.Component {
render() {
return (
<div className="helloworld">
Hello {this.props.name}
</div>
);
}
}
@amol-
amol- / HelloWorld.jsx
Last active September 26, 2016 20:41
React, WebAssets, Babel and DukPY
export class HelloWorld extends React.Component {
render() {
return (
<div className="helloworld">
Hello {this.props.name}
</div>
);
}
}
@amol-
amol- / tgoneline.py
Last active April 17, 2016 18:02
Oneline TurboGears2 web application
from tg import expose, TGController, AppConfig
from wsgiref.simple_server import make_server
make_server('', 8080, AppConfig(
minimal=True,
root_controller=type('RootController', (TGController,), {
'index': expose()(lambda *args, **params: 'Hello World')
})()
).make_wsgi_app()).serve_forever()
@amol-
amol- / tg2_opbeat.py
Created February 23, 2016 11:46
OpBeat integration for TurboGears2
from tg.appwrappers.base import ApplicationWrapper
class OpBeatApplicationWrapper(ApplicationWrapper):
def __init__(self, handler, config):
super(OpBeatApplicationWrapper, self).__init__(handler, config)
from tg.support.converters import aslist
import logging
log = logging.getLogger('opbeat')
@amol-
amol- / babelfilter.py
Last active October 29, 2015 09:26
WebAssets Filter to compile ES6 to ES5 using DukPY and BabelJS
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function
from webassets.filter import Filter
__all__ = ('BabelJS',)
# NOTE: When using the BabelJS compiler for code
# that needs to run in the browser make sure to add
# https://cdnjs.cloudflare.com/ajax/libs/babel-core/4.6.6/browser-polyfill.js
@amol-
amol- / tg2_appenlight
Created November 25, 2014 23:01
AppEnlight TurboGears2
TurboGears2 exception logging and performance monitoring
========================================================
Approx. integration time: **2 minutes**
WSGI middleware is the most common way to use App Enlight with your web application written in TurboGears2 web framework.
Installation and Setup
----------------------