Skip to content

Instantly share code, notes, and snippets.

View dave-ops's full-sized avatar
🎯
Focusing

dave-ops

🎯
Focusing
  • United Staters of America
View GitHub Profile
@dave-ops
dave-ops / api.py
Created February 18, 2025 19:58
py-gist
import json
import requests
import os
from utils import make_content_json_safe
def create_gist(content, description, github_token):
url = 'https://api.github.com/gists'
headers = {
'Authorization': f'token {github_token.strip()}',
'Accept': 'application/vnd.github.v3+json',
@dave-ops
dave-ops / Mud.ts
Created March 10, 2025 03:06
pub-gob
import http from 'http';
import { connectToDatabase, disconnectFromDatabase } from './db';
import { Logger } from './logger/Logger';
import { DEBUG } from './logger/constants';
import { StaticWebServer } from './StaticWebServer';
import User from './models/User';
import { WebSocketServer } from 'ws';
const log = new Logger(DEBUG, __filename);
@dave-ops
dave-ops / Mud.ts
Created March 10, 2025 03:18
pub-gob
import http from 'http';\\r\\nimport { connectToDatabase, disconnectFromDatabase } from './db';\\r\\nimport { Logger } from './logger/Logger';\\r\\nimport { DEBUG } from './logger/constants';\\r\\nimport { StaticWebServer } from './StaticWebServer';\\r\\nimport User from './models/User';\\r\\nimport { WebSocketServer } from 'ws';\\r\\n\\r\\nconst log = new Logger(DEBUG, __filename);\\r\\n\\r\\nexport class Mud {\\r\\n private readonly wss: WebSocketServer;\\r\\n\\r\\n constructor(server: http.Server) {\\r\\n log.info('loading web socket');\\r\\n this.wss = new WebSocketServer({ server });\\r\\n }\\r\\n\\r\\n start() {\\r\\n this.wss.on('connection', (ws) => {\\r\\n console.log('New client connected');\\r\\n\\r\\n ws.on('message', (message) => {\\r\\n console.log('Received:', message.toString());\\r\\n // Echo the message back to the client\\r\\n ws.send(`Server received: ${message}`);\\r\\n });\\r\\n
 (F  (n00 (-� ��F(  $]��]$ �������� 8����������8��������������������������#���OOO�������������������������ggg����#Y����������������������������555����Y�����kkk�������������������������������\\t\\t\\t�����������������������Y�����JJJ���������kkk������Y#��������������\\t\\t\\t������#������111�DDD�������������������8����������8
 (F  (n00 (-� ��F(  $]��]$ �������� 8����������8��������������������������#���OOO�������������������������ggg����#Y����������������������������555����Y�����kkk������������������������������� �����������������������Y�����JJJ���������kkk������Y#�������������� ������#������111�DDD�������������������8����������8
import { NextRequest, NextResponse } from 'next/server';
import { MongoDBRepository } from '../../../../lib/mongodb-repository';
interface Item {
_id?: string;
name: string;
description: string;
}
const itemRepository = new MongoDBRepository<Item>('completions');
using GrokCLI.Helpers;
namespace GrokCLI;
public class ChatApiClient
{
private readonly string _apiKey;
private readonly string _baseUrl;
public ChatApiClient(string apiKey, string baseUrl)
{
using GrokCLI.Helpers;\r\n\r\nnamespace GrokCLI;\r\npublic class ChatApiClient\r\n{\r\n private readonly string _apiKey;\r\n private readonly string _baseUrl;\r\n\r\n public ChatApiClient(string apiKey, string baseUrl)\r\n {\r\n _apiKey = apiKey;\r\n _baseUrl = baseUrl;\r\n }\r\n\r\n public async Task<string> GetChatResponseAsync(string model, List<Message> messages)\r\n {\r\n Logger.Info($\"Calling API at {_baseUrl} with model {model}\");\r\n // Simulated response incorporating the parameter\r\n throw new NotImplementedException();\r\n }\r\n}\r\n\r\npublic class Message\r\n{\r\n public string Role { get; set; }\r\n public string Content { get; set; }\r\n\r\n public Message(string role, string content)\r\n {\r\n Role = role;\r\n Content = content;\r\n }\r\n}
using GrokCLI.Helpers;
namespace GrokCLI;
public class ChatApiClient
{
private readonly string _apiKey;
private readonly string _baseUrl;
public ChatApiClient(string apiKey, string baseUrl)
{
using GrokCLI.Helpers;
namespace GrokCLI;
public class ChatApiClient
{
private readonly string _apiKey;
private readonly string _baseUrl;
public ChatApiClient(string apiKey, string baseUrl)
{