Skip to content

Instantly share code, notes, and snippets.

View Namaskar-1F64F's full-sized avatar
🙏
let's do it

Kyle Namaskar-1F64F

🙏
let's do it
View GitHub Profile
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.20;
import "forge-std/Vm.sol";
import "forge-std/console.sol";
import "forge-std/Test.sol";
import {GGPVault} from "../contracts/GGPVault.sol";
import {MockTokenGGP} from "./mocks/MockTokenGGP.sol";
import {MockStaking} from "./mocks/MockStaking.sol";
@Namaskar-1F64F
Namaskar-1F64F / middleware.ts
Created February 7, 2024 04:28
NextAuth Next.js Middleware for Authenticating GitHub Apps.
import { withAuth } from 'next-auth/middleware'
import { NextRequest, NextResponse } from 'next/server'
import { encode, getToken } from 'next-auth/jwt'
import { Octokit } from '@octokit/core'
import { GitHubAppUserAuthentication, createAppAuth } from '@octokit/auth-app'
import { logAndReportError } from './services/withErrorHandling'
import { enforceEnvVars } from 'shared-types/utils'
function signOut(request: NextRequest) {
const response = NextResponse.redirect(
@Namaskar-1F64F
Namaskar-1F64F / og.tsx
Created August 8, 2023 15:57
dAppling OG Image Generation
import { StatusType } from '@aws-sdk/client-codebuild'
import { ImageResponse } from '@vercel/og'
import { NextRequest } from 'next/server'
export const config = {
runtime: 'edge',
}
type GradientGenerator = {
generate: (seed: string) => string
@Namaskar-1F64F
Namaskar-1F64F / gradient.ts
Last active August 8, 2023 16:04
Gradient generator
type GradientGenerator = {
generate: (seed: string) => string
}
const colors = ['c051e9', '578ce6', '8cacf5', 'd8fb9f']
// Simple PRNG using Mulberry32 algorithm
function mulberry32(seed: number) {
return function () {
let temp = (seed += 0x6d2b79f5)
@Namaskar-1F64F
Namaskar-1F64F / preBuildCodeTransformations.js
Last active October 3, 2023 13:23
[pre-build] IPFS transformations
const fs = require('fs')
const path = require('path')
const jscodeshift = require('jscodeshift')
const updatePackageJson = function (fileInfo) {
const json = JSON.parse(fileInfo.source)
// Check if the package is using react-scripts
const usesReactScripts =
(json.dependencies && json.dependencies['react-scripts']) ||
@Namaskar-1F64F
Namaskar-1F64F / preBuildCodeTransformations.js
Last active October 4, 2023 08:47
[pre-build] Optimizations for IPFS websites
const fs = require("fs");
const path = require("path");
const jscodeshift = require("jscodeshift");
const updatePackageJson = function (fileInfo) {
const json = JSON.parse(fileInfo.source);
// Check if the package is using react-scripts
const usesReactScripts =
(json.dependencies && json.dependencies["react-scripts"]) ||
@Namaskar-1F64F
Namaskar-1F64F / replacepaths.ts
Last active April 21, 2023 16:41
Replace paths for IPFS
/* eslint-disable */
const fs = require("fs/promises");
const path = require('path')
const process = require('process')
const replaceRules = [
// Replace all absolute paths with relative paths
// Replace src="/example" with src="example" and href="/example" with href="example"
[/ (src|href)="\/(?!\/)/g, ' $1="'],
// Replace url("/example") with url("example")
@Namaskar-1F64F
Namaskar-1F64F / receiptUtils.ts
Last active January 4, 2023 17:50
TheGraph Subgraph Log Inspection using Transaction Receipt
/*
This function returns an address from an event log like a Transfer event.
param receipt a transaction receipt to search through
param topic the topic hash of the event
param index the topic index of the argument to return
*/
function getAddressFromEvent(
receipt: ethereum.TransactionReceipt | null,
topic: string,
index: i32
@Namaskar-1F64F
Namaskar-1F64F / woohoo.js
Created December 10, 2020 03:42
advent of code 2020 day 9
// get the full transmitted data to test
const fullTransmission = ``
.split("\n")
.map((input) => parseInt(input));
// This is the number used to generate a sliding window to use as possible inputs
const PREAMBLE_LENGTH = 25;
// Sum to the goal number using only the possible operands
function sumTo(goal, possibleOperands) {