Skip to content

Instantly share code, notes, and snippets.

View sourabhxyz's full-sized avatar
🏀
λ

Sourabh sourabhxyz

🏀
λ
View GitHub Profile
@sourabhxyz
sourabhxyz / api.py
Created March 12, 2024 09:49
Python Client for `dex-contracts-api`
# Python client generated using [`servant-py`](https://github.com/erewok/servant-py) for [`dex-contracts-api`](https://github.com/geniusyield/dex-contracts-api).
from urllib import parse
import requests
def get_v0_settings(headerapikey):
"""
GET "v0/settings"
@sourabhxyz
sourabhxyz / backingBuybackEffect.py
Last active May 17, 2022 04:02
Studying the effects of buybacks on backing for various scenario
import matplotlib.pyplot as plt
def buyback (t, s):
b = t / s # backing is treasury value divided by circulating supply
nt = t - t / 100 # utilising 1% of treasury for buyback, 'nt' now holds the value of new treasury
ns = s - t / (70 * b) # buyback at 70% of backing, 'ns' now holds new circulating supply
return nt, ns
t = [290000000] # starting assumption: $290M treasury
s = [5800] # starting assumption: 5800 circulating wMEMO
@sourabhxyz
sourabhxyz / simulateConditions.cpp
Last active October 3, 2021 13:07
Given the target number (which I would suggest you to play with), this program simulates various situations to reach it.
#include <iostream>
#include <cmath>
using namespace std;
int main () {
double target = 92.51; // update this value to your marks to see possible situations.
for (int rm = 0; rm <= 100; rm++) { // number of questions removed can either be 0 or all
int availableQuestions = 100 - rm;
double perQuestionMark = ((double) 200)/(double (100 - rm));
@sourabhxyz
sourabhxyz / elementOrderSn.cpp
Created September 7, 2021 02:42
Given a positive integer n, gives number of elements of each order present in a symmetric group of order n. This is used to verify the solution of problem: CSE-2013-2(b).
/*
Program description: Given a positive integer n, gives number of elements of each order present in a symmetric group of order n.
This is used to verify the solution of problem: CSE-2013-2(b).
*/
#include <iostream>
#include <vector>
#include <map>
package simpledb.server;
import simpledb.remote.*;
import java.rmi.registry.*;
import java.sql.*;
public class Startup {
public static void main(String args[]) throws Exception {
// configure and initialize the database
if (args.length < 3) {
import java.sql.*;
import simpledb.remote.SimpleDriver;
public class CreateUniversityDB {
public static void main(String[] args) {
Connection conn = null;
try {
Driver d = new SimpleDriver();
conn = d.connect("jdbc:simpledb://localhost", null);
Statement stmt = conn.createStatement();
@sourabhxyz
sourabhxyz / smlCheatSheet.sml
Created January 23, 2019 03:38
SML Cheat Sheet
val real_division = 14.0 / 4.0 (* gives 3.5 *)
val int_division = 14 div 4 (* gives 3, rounding down *)
val int_remainder = 14 mod 4 (* gives 2, since 3*4 = 12 *)
(* andalso is same as && in c, orelse is same as || in c, not is the negation)
(* Many values can be compared using equality operators: = (==) and <> (!=) *)
list is written as "type list"
list is homogenous, list can only contain one type of thing.
'@' / '^' for list / string resp
- (2::4::6::nil) :: (2::3::5::7::nil) :: (2::4::8::16::32::nil) :: nil;
val it = [[2,4,6],[2,3,5,7],[2,4,8,16,32]] : int list list
@sourabhxyz
sourabhxyz / SML_Cheat_Sheet.sml
Created January 23, 2019 02:42
Cheat Sheet For SML
(* SML notes *)
when writing in editor, semicolon is not required but when typing in terminal we need
semicolon
val negative_number = ~15 (* Yeah, unary minus uses the 'tilde' symbol *)
(*
- Math.e;
val it = 2.71828182846 : real
- Math.cos (Math.pi/2.0);
val it = 0.0 : real
- Math.sqrt (49.01);
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
const int inf = 1000000;
const double eps = 1e-12;
vector<vector<int>> g;
int n;
vector<int> visited, par, origvis;
int bfs(int ini){
#include<bits/stdc++.h>
using namespace std;
#define inf 10000000
void solve() {
int tc;
cin >> tc;
while (tc--) {