Skip to content

Instantly share code, notes, and snippets.

View viveknair's full-sized avatar
🤖
Working on Gentrace

Vivek Nair viveknair

🤖
Working on Gentrace
View GitHub Profile
@viveknair
viveknair / git-loc-changes.sh
Created January 2, 2025 17:12
Git LOC Analytics: bash script to analyze code changes by extension and author
#!/bin/bash
# Script to analyze git LOC changes
# Usage: ./git-loc-changes.sh [options]
# Options:
# -s, --since DATE Show changes since DATE (e.g., "1 week ago", "2023-01-01")
# -a, --author NAME Filter by author
# -h, --help Show this help message
print_help() {
@viveknair
viveknair / cursor-otel-trace-prompt
Created October 14, 2024 14:16
Cursor OTEL trace prompt
If I ask to trace a block of code for editing, make sure you use the tracer.startActiveSpan() API from OpenTelemetry and prefix the span name with gt-. Use kebab case for the autogenerated span name (e.g. gt-testing-insertion-values). Make sure spans are ended correctly. If you need to create the tracer with getTracer('...'), name the tracer "gentrace-tracer". You should use the global "trace" instance directly provided by the OTEL SDK library. tracer.startActiveSpan() should be awaited if the function that's is being wrapped is async. If the code block that I'm asking you to trace has variables, make sure the variables don't go out of scope for the existing code. If you add a span.recordException() invocation, make sure you cast with "span.recordException(error as Error)"
DO NOT add trace logic unless my query specifies you to "trace"
@viveknair
viveknair / cursor-ai-log-generator
Created October 14, 2024 14:11
Cursor log generator
If I say "clog", use regular console.log() NOT trace. In console.log() statements, always include a descriptive message and include a CONSISTENT prefix to identify all clogs created in that generation.
Also, include variables that are helpful to understanding the context of the logs as additional arguments to the console.log(). The generated lines should be a SINGLE statement, ideally a SINGLE line. Do NOT include prefixes as separate variables - prefer to rewrite the prefix for each log generated. Do NOT delete other logic or comments in the process of generating logs.
@viveknair
viveknair / handle-pg-error.js
Created May 31, 2021 20:14
PagerDuty Events API
import fetch from 'node-fetch
const handlePGError = async ({ id, server, routingKey, summary, dedupKey, ts }) => {
const request = {
routing_key: routingKey,
event_action: 'trigger',
dedup_key: dedupKey,
payload: {
summary,
source: id,
<html>
<head>
<title>Rive Canvas Example</title>
<link rel="stylesheet" href="/stylesheets/style.css">
</head>
<body>
<h1>Rive Context 2D Example</h1>
<p>For more info, check out the <a href="https://www.npmjs.com/package/rive-canvas"> Rive web canvas package</a>.</p>
@viveknair
viveknair / index.html
Created October 2, 2012 05:32
Olympic Countries (Medal Breakdown and GDP Analysis)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.1.min.js"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.29.1"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geo.js?1.29.1"></script>
<style>
body {
@viveknair
viveknair / index.html
Created October 2, 2012 04:47
Olympic Countries (Medal Breakdown and GDP Analysis)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.1.min.js"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.29.1"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geo.js?1.29.1"></script>
<style>
body {
@viveknair
viveknair / index.html
Created September 30, 2012 00:23
Sampling of Olympic Countries in-depth
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.1.min.js"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.29.1"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geo.js?1.29.1"></script>
<style>
body {
@viveknair
viveknair / index.html
Created September 30, 2012 00:22
Sampling of Olympic Countries in-depth
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.1.min.js"></script>
<script type="text/javascript" src="libs/d3/d3.js"></script>
<script type="text/javascript" src="libs/d3/d3.geo.js"></script>
<style>
body {
@viveknair
viveknair / index.html
Created September 30, 2012 00:18
Sampling of Olympic Countries in-depth
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.1.min.js"></script>
<script type="text/javascript" src="libs/d3/d3.js"></script>
<script type="text/javascript" src="libs/d3/d3.geo.js"></script>
<link type="text/css" rel="stylesheet" href="style/style.css"/>
<link type="text/css" rel="stylesheet" href="libs/colorbrewer/colorbrewer.css"/>