Skip to content

Instantly share code, notes, and snippets.

@a9
a9 / .py
Created March 17, 2025 17:55 — forked from Madhav-MKNC/coding-agent.py
All the code you need to create a powerful agent that can create and edit any file on your computer using the new text_editor tool in the Anthropic API.
import anthropic
import os
import sys
from termcolor import colored
from dotenv import load_dotenv
class ClaudeAgent:
def __init__(self, api_key=None, model="claude-3-7-sonnet-20250219", max_tokens=4000):
"""Initialize the Claude agent with API key and model."""
@a9
a9 / fast-dns-checker.js
Created February 6, 2025 08:28 — forked from modulsx/fast-dns-checker.js
Fast DNS Record Checker
const { argv } = require('node:process');
const dns = require('node:dns').promises;
const ALLOWED_RECORD_TYPES = ['A', 'AAAA', 'ANY', 'CAA', 'CNAME', 'MX', 'NS', 'NAPTR', 'PTR', 'SOA', 'SRV', 'TXT']
async function checkDNSRecord(domain, value, recordType = 'A'){
return new Promise(async (resolve, _) => {
try{
const resolver = new dns.Resolver();
const apexDomain = domain.split('.').splice(-2).join('.')
@a9
a9 / index.ts
Created August 20, 2024 01:09 — forked from rishi-raj-jain/index.ts
Google OAuth 2.0 on the Edge with Hono and Cloudflare Workers
// Do enable nodejs_compat
// https://developers.cloudflare.com/workers/runtime-apis/nodejs/
import crypto from 'node:crypto'
import { Context, Hono } from 'hono'
const app = new Hono()
function generateJWT(payload, secret, expiresIn) {
const header = { alg: 'HS256', typ: 'JWT' }
const encodedHeader = base64UrlEncode(JSON.stringify(header))
@a9
a9 / testRegex.js
Created August 16, 2024 04:47 — forked from hanxiao/testRegex.js
Regex for chunking by using all semantic cues
// Updated: Aug. 15, 2024
// Run: node testRegex.js testText.txt
// Used in https://jina.ai/tokenizer
const fs = require('fs');
const util = require('util');
// Define variables for magic numbers
const MAX_HEADING_LENGTH = 7;
const MAX_HEADING_CONTENT_LENGTH = 200;
const MAX_HEADING_UNDERLINE_LENGTH = 200;
@a9
a9 / appendBlur.swift
Created February 18, 2020 11:19
Append Blur to a NSView, NSButton, NSTextField
//
// appendBlur.swift
//
// Created by Wesley de Groot on 09-07-16.
// Copyright © 2016 Wesley de Groot. All rights reserved.
//
import Foundation
enum blur: String {
case light = "light"
@a9
a9 / chrome-dark.css
Created June 16, 2019 02:37
chrome prefers-color-scheme dark
@media (prefers-color-scheme: dark) {
body {
color: white;
background-color: black;
}
}
@a9
a9 / vue-typescript-component.vue
Last active May 30, 2019 13:59
Vue Typescript Component File Template as WebStorm #vue
#set( $ClassName = "${Prefix}-${NAME}" )
#set( $ComponentNamePrefix = ${StringUtils.removeAndHump(${Prefix}, "-")} )
#set( $ComponentName = ${StringUtils.removeAndHump(${NAME}, "-")} )
<template>
<div class="${ClassName}">#[[$END$]]#</div>
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'
@a9
a9 / effective-graphql-and-antd.md
Created September 12, 2018 07:41
Effective GraphQL + Antd

高效的 GraphQL + Antd

本文原载于我的独立博客 https://lutaonan.com/blog/effective-graphql-and-antd/

在过去的几年,不论是面向内部的系统,还是面向外部的产品,我们都大量地使用了 Ant.Design —— 一个基于 React 的 UI 组件库。

在做内部系统时,Ant.Design 解决了几乎 60% 的问题。剩下的问题在业务逻辑和代码组织的复杂度。我见过很多内部系统因为滥用状态管理而使代码变得复杂,他们之所以使用状态管理库,并不是因为应用的状态复杂,而是因为需要一个状态树来管理网络请求的状态、接口返回的数据等等这些和接口相关的状态。

真的需要状态管理库吗?在之前,我没有信心回答这个问题。但在使用了 GraphQL (Apollo) 后,我确信,在大多数场景,你不再需要状态管理。

@a9
a9 / compress.go
Created May 11, 2018 06:13 — forked from iamralch/compress.go
ZIP archives in Golang
import (
"archive/zip"
"io"
"os"
"path/filepath"
"strings"
)
func zipit(source, target string) error {
zipfile, err := os.Create(target)
@a9
a9 / CreateJob.sh
Created April 24, 2018 08:35 — forked from stuart-warren/CreateJob.sh
Create a job in Jenkins (or folder) using the HTTP API
# check if job exists
curl -XGET 'http://jenkins/checkJobName?value=yourJobFolderName' --user user.name:YourAPIToken
# with folder plugin
curl -s -XPOST 'http://jenkins/job/FolderName/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken
# without folder plugin
curl -s -XPOST 'http://jenkins/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken
# create folder