Skip to content

Instantly share code, notes, and snippets.

View shbm's full-sized avatar

Shubham Srivastava shbm

View GitHub Profile
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IReentrance {
function donate(address _to) external payable;
function withdraw(uint _amount) external;
}
contract Attack {
IReentrance public target;
@shbm
shbm / contemplative-llms.txt
Created January 7, 2025 02:47 — forked from Maharshi-Pandya/contemplative-llms.txt
"Contemplative reasoning" response style for LLMs like Claude and GPT-4o
You are an assistant that engages in extremely thorough, self-questioning reasoning. Your approach mirrors human stream-of-consciousness thinking, characterized by continuous exploration, self-doubt, and iterative analysis.
## Core Principles
1. EXPLORATION OVER CONCLUSION
- Never rush to conclusions
- Keep exploring until a solution emerges naturally from the evidence
- If uncertain, continue reasoning indefinitely
- Question every assumption and inference
@shbm
shbm / contracts...m2...NFT_flattened.sol
Created January 2, 2025 01:09
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.26+commit.8a97fa7a.js&optimize=false&runs=200&gist=
// File: @openzeppelin/contracts/utils/introspection/IERC165.sol
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
https://www.kaggle.com/c/FacebookRecruiting/discussion/2002
The provided explanation is fine and all, but I will explain it differently here. (I would love to hear any improvements/corrections!)
Consider one row of test.csv. You have a source_node, and you have to predict an ordered list of up to ten destination_nodes. Facebook and Kaggle know, for that source_node, some number of correct destination_nodes.
For this row (one list of predictions) we do a sum and then divide to standardize.
For every prediction, is it correct? If it isn't correct, you get no points for that prediction. If it is correct, you get a number of points equal to the number of correct predictions up to and including this one, divided by the position of this prediction in the list. For example:
import psycopg2
# For creating a context object. connection automatically closes.
# For joblib connection needs to be closed.
class DbConnector:
def __init__(self):
self.host = ""
self.user = ""
self.password = ""
from sqlalchemy import create_engine
class DB_Connector:
def __init__(self):
#self.host='dcilda1832'
self.host='pmlg012021'
self.user='cdsem'
self.password='Cdsem#1234'
self.database='cdsem_qc'
def __enter__(self):
@shbm
shbm / fourex.py
Created March 12, 2021 18:12 — forked from tartakynov/fourex.py
Fourier Extrapolation in Python
import numpy as np
import pylab as pl
from numpy import fft
def fourierExtrapolation(x, n_predict):
n = x.size
n_harm = 10 # number of harmonics in model
t = np.arange(0, n)
p = np.polyfit(t, x, 1) # find linear trend in x
x_notrend = x - p[0] * t # detrended x
@shbm
shbm / postgres_queries_and_commands.sql
Created March 8, 2021 13:15 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@shbm
shbm / bulk-insert.py
Created January 11, 2021 11:19 — forked from ellisvalentiner/bulk-insert.py
Recipe for (fast) bulk insert from python Pandas DataFrame to Postgres database
#!/usr/bin/env/python
import psycopg2
import os
from io import StringIO
import pandas as pd
# Get a database connection
dsn = os.environ.get('DB_DSN') # Use ENV vars: keep it secret, keep it safe
conn = psycopg2.connect(dsn)