Skip to content

Instantly share code, notes, and snippets.

View manan19's full-sized avatar
🪐
Identity. Network. Content.

Manan manan19

🪐
Identity. Network. Content.
View GitHub Profile
@manan19
manan19 / insert_root_parent_cast_and_return_count
Created September 6, 2023 00:02
PostgreSQL function to calculate the threadHash or root_parent_hash for all casts
DECLARE
rows_inserted INTEGER;
BEGIN
WITH RECURSIVE root_mapping AS (
-- Base case: Casts without a parent and with a timestamp in the last hour
SELECT hash, timestamp, hash AS root_parent_hash
FROM casts
WHERE parent_hash IS NULL
@manan19
manan19 / signed_key.ts
Last active November 30, 2023 02:55
Generating an ECDSA signature
/****
Note - This snippet will not be maintained / updated as of Nov 29, 2023.
Please check out the to generate signers with Neynar https://github.com/neynarxyz/nodejs-sdk
Or you can also use the utility function signKeyRequest inside this package https://github.com/farcasterxyz/hub-monorepo/blob/main/packages/core/src/signers/viemLocalEip712Signer.ts
****/
@manan19
manan19 / get-casts-example.js
Last active November 10, 2023 00:53
Sample code to get casts by fid from your Neynar-hosted Farcaster hub using a secure client
const { getSSLHubRpcClient } = require('@farcaster/hub-nodejs');
const getCastsByFid = async (hubRpcEndpoint, fid) => {
let client = getSSLHubRpcClient(hubRpcEndpoint);
client.$.waitForReady(Date.now() + 2000, async (e) => {
if (e) {
console.error(`Failed to connect to ${hubRpcEndpoint}`);
} else {
console.log(`Connected to ${hubRpcEndpoint}`);
@manan19
manan19 / hub-web-dist.js
Created April 15, 2023 00:57
hub web's distribution
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
require("dotenv").config();
const ethers = require("ethers");
const axios = require('axios').default;
const provider = new ethers.providers.JsonRpcProvider(`https://eth-mainnet.alchemyapi.io/v2/${process.env.NEXT_PUBLIC_ALCHEMY_API_KEY}`);
const alg = new ethers.Contract(
"0x32353A6C91143bfd6C7d363B546e62a9A2489A20",
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"inde
Code cleanup
https://github.com/peripheryapp/periphery
Asset cleanup
https://github.com/onevcat/FengNiao
Verifying my Blockstack ID is secured with the address 1GhWYtTRchygtbiiPSycukf7DgFiURSVKu https://explorer.blockstack.org/address/1GhWYtTRchygtbiiPSycukf7DgFiURSVKu
@manan19
manan19 / .bash_profile
Last active December 21, 2016 17:52
Find and crush all pngs
# Image Resizing
alias cpng='find . -iname '*png' -exec pngcrush -ow -brute {} {}.crush \;'
alias spng="find . -name '*png' -ls | awk '{total += $7} END {print total}'"
@manan19
manan19 / .bash_profile
Created August 19, 2014 18:37
Opens the github page for the current git repo/branch in your browser
# Opens the github page for the current git repo/branch in your browser
function gh() {
giturl=$(git config --get remote.origin.url)
if [ "$giturl" == "" ]
then
echo "Not a git repository or no remote.origin.url set"
else
giturl=${giturl/git\@github\.com\:/https://github.com/}
giturl=${giturl/\.git/\/tree/}
@manan19
manan19 / .bash_profile
Last active December 21, 2016 17:44
git branch in terminal
# git
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "