Skip to content

Instantly share code, notes, and snippets.

View AbhiPrasad's full-sized avatar

Abhijeet Prasad AbhiPrasad

View GitHub Profile
import { startSpan, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_STATUS_ERROR } from '@sentry/core';
const patchedStatement = new WeakSet<D1PreparedStatement>();
function instrumentD1PreparedStatementQueries(statement: D1PreparedStatement, query: string): D1PreparedStatement {
if (patchedStatement.has(statement)) {
return statement;
}
statement.first = new Proxy(statement.first, {
@AbhiPrasad
AbhiPrasad / promise-catch-monkey-patch.js
Created June 6, 2024 14:08
Monkey patch `Promise.catch`
// Please don't do this in production
// It's only really useful for debugging stuff
globalThis.Promise.prototype.catch = new Proxy(
globalThis.Promise.prototype.catch,
{
apply(target, thisArg, catchArgs) {
console.log("Promise.prototype.catch called");
catchArgs[0] = new Proxy(catchArgs[0], {
apply(target, thisArg, callbackArgs) {
// callbackArgs[0] is the error passed to the catch callback
const opentelemetry = require("@opentelemetry/sdk-node");
const {
getNodeAutoInstrumentations,
} = require("@opentelemetry/auto-instrumentations-node");
const sdk = new opentelemetry.NodeSDK({
traceExporter: new opentelemetry.tracing.ConsoleSpanExporter(),
instrumentations: [getNodeAutoInstrumentations()],
});
test = np.zeros((4, 8))
def get_move(board, piece_scaler, attack_scaler):
X = {
"global": {
"side": [],
"white queen castle": [],
"white king castle": [],
"black queen castle": [],
"black king castle": [],
@AbhiPrasad
AbhiPrasad / learn-video-slider
Last active January 12, 2021 18:03
Learn Video Fastforward
javascript:(function()%7Blet%20container%20%3D%20document.createElement(%22div%22)%3Bcontainer.id%20%3D%20%22--slider-container%22%3Blet%20labelElement%20%3D%20document.createElement(%22label%22)%3BlabelElement.id%20%3D%20%22--slider-label%22%3BlabelElement.style.width%20%3D%20%22100px%22%3Blet%20inputElement%20%3D%20document.createElement('input')%3BinputElement.id%20%3D%20%22--slider-input%22%3BinputElement.type%20%3D%20%22range%22%3BinputElement.min%20%3D%200.5%3BinputElement.max%20%3D%203%3BinputElement.step%20%3D%200.25%3BinputElement.value%20%3D%201%3BinputElement.oninput%20%3D%20()%20%3D%3E%20%7BlabelElement.textContent%20%3D%20inputElement.value%3Bconst%20videoElement%20%3D%20document.getElementsByTagName('video')%5B0%5D%3Bif%20(videoElement%20!%3D%20null)%20%7BvideoElement.playbackRate%20%3D%20inputElement.value%3B%7D%20else%20%7Bconst%20root%20%3D%20document.getElementsByTagName(%22d2l-labs-media-player%22)%5B0%5D.shadowRoot%3Broot.getElementById(%22d2l-labs-media-player-video%22).playbackRate%20%3D
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using QuickType;
//
// var coordinate = Coordinate.FromJson(jsonString);
namespace QuickType
{
@AbhiPrasad
AbhiPrasad / glb.sh
Created April 26, 2019 19:37
Check which branches you've worked on
alias glb="git for-each-ref --sort=-committerdate refs/heads/ --format='%(authordate:short) %(color:red)%(objectname:short) %(color:yellow)%(refname:short)%(color:reset) (%(color:green)%(committerdate:relative)%(color:reset))'"
@AbhiPrasad
AbhiPrasad / help_regex.js
Last active January 25, 2019 15:05
helpful regex
// URL
const URL_REGEX = /(?:(?:https?:))/i;
// Find two words
const FIND_TWO_WORDS = /^.*?\b(WORD_ONE)\b.*?\b(WORD_TWO)\b.*?$/i;

Keybase proof

I hereby claim:

  • I am abhiprasad on github.
  • I am abhijeetprasad (https://keybase.io/abhijeetprasad) on keybase.
  • I have a public key whose fingerprint is 8932 7218 5B12 A5BA A6F1 DF6A 8A1B BA05 1A5D BDC8

To claim this, I am signing this object:

@AbhiPrasad
AbhiPrasad / backbone-boilerplate.js
Created March 22, 2017 17:52
A simple boilerplate to test backbone stuff
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://underscorejs.org/underscore-min.js"></script>