Skip to content

Instantly share code, notes, and snippets.

View drdmitry's full-sized avatar

Dmitry drdmitry

  • Conversion Tools
View GitHub Profile
@chenhunghan
chenhunghan / gist.md
Last active March 16, 2026 12:55
One Prompt to Save 90% Context for Any MCP Server

Local Code Mode for MCP

Most MCP servers just wrap CRUD JSON APIs into tools — I did it too with scim-mcp and garmin-mcp-app. It works, until you realize a tool call dumps 50KB+ into context.

MCP isn't dead — but we need to design MCP tools with the context window in mind.

@JagNL
JagNL / tinyadder_1p.py
Created February 27, 2026 04:59
TinyAdder-1: 1-parameter hand-coded transformer for 10-digit addition (AdderBoard submission)
#!/usr/bin/env python3
"""
TinyAdder-1: 1-parameter hand-coded transformer for 10-digit addition.
AdderBoard submission — hand-coded weights (constructive proof).
Architecture: 2L decoder, d=5→16, 5h+1h, ALiBi slope=log(BASE).
The single parameter is BASE (=10), the number base.
All weights are deterministically derived from BASE:
K_WEIGHT = BASE × (BASE² − 4) = 960
@lokisho
lokisho / pthreads_howto.md
Last active May 24, 2022 01:49
How to install multithreads (pthreads) for php 7.3 ubuntu 18.04

Tutorial

pthreads allows to use multiple threads when running a php script with php cli.

Important: it only works for php cli, not in a web browser
The reasons for that can be found in the article recommended in Acknowledgments and resources section.
We are following 3 steps.
  • Install php7.3 as usual for our web server applications (if you pretend to use only php cli in your server, you can skip this step).
@narainsagar
narainsagar / nodejs - get filesize in readable format.md
Last active January 14, 2022 05:33
node.js - function to get file and convert the file size in humanly readable format.

node.js - get the filesize in human readable format.

This will take filePath as a function parameter and reads the file via fs module and get the file and converts it's size into more humanly readable format.

const fs = require('fs');
function getFileSize(filename) {
  const stats = fs.statSync(filename);
  //console.log('stats', stats);
 const {size} = stats;
@yunghoy
yunghoy / gist:a425f91824d26461bb2e3653bc56ebbf
Last active June 2, 2022 00:34
AMQP library (RabbitMQ) - async/await
alias babel-node='babel-node --presets stage-0'
------ RECV ------
// babel-node recv2.js "#"
// babel-node recv2.js "kern.*"
const amqp = require('amqplib');
const args = process.argv.slice(2);
if (args.length == 0) {
@stephantabor
stephantabor / bb.js
Last active January 6, 2024 04:18
Bluebird .each vs .mapSeries vs .map
var Promise = require('bluebird');
var funcs = Promise.resolve([500, 100, 400, 200].map((n) => makeWait(n)));
funcs
.each(iterator) // logs: 500, 100, 400, 200
.then(console.log) // logs: [ [Function], [Function], [Function], [Function] ]
funcs
.mapSeries(iterator) // logs: 500, 100, 400, 200
@jcdarwin
jcdarwin / monit-and-gmail
Last active August 15, 2024 08:08
How to allow monit to use gmail as a smtp relay to send out alert emails
# visit https://accounts.google.com/DisplayUnlockCaptcha and click to allow access
# edit /etc/monit/monitrc to include the following
set mailserver smtp.gmail.com port 587
username "whoever@gmail.com" password "whatever"
using tlsv1
with timeout 30 seconds
# run the following to validate access
@aheckmann
aheckmann / storeImgInMongoWithMongoose.js
Created April 17, 2012 19:14
store/display an image in mongodb using mongoose/express
/**
* Module dependencies
*/
var express = require('express');
var fs = require('fs');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
// img path