Skip to content

Instantly share code, notes, and snippets.

View flipdazed's full-sized avatar

Alexander McFarlane flipdazed

View GitHub Profile
@flipdazed
flipdazed / almgren_chriss.py
Created April 30, 2019 22:41
Linear Almgren-Chriss python model
import numba as nb
import numpy as np
def impact_perm(nu, gamma, beta):
"""Returns the permenant dollar price impact per unit time
In paper as :math:`g(\nu)`
Args:
@flipdazed
flipdazed / Export-ExcelProject.ps1
Created September 26, 2019 18:21 — forked from atifaziz/Export-ExcelProject.ps1
PowerShell script to export VBA project components (classes, modules, etc.) from an Excel workbook
# Copyright (c) 2014 Atif Aziz. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@flipdazed
flipdazed / secp256k1_malleable.py
Last active September 6, 2022 00:12
Demonstrates why you can get a malleable ECDSA (secp256k1) signature in Python
"""
This code is adapted from one of Vitalik's earliest implementations of Ethereum,
written in python surprisingly. It helps demonstrate the process behind ECDSA
"""
import numpy as np
import hashlib, hmac
import sys
if sys.version[0] == '2':
safe_ord = ord
else:
import os
import time
import numpy as np
import re
import unicodedata
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
@flipdazed
flipdazed / grab_contacts_from_telegram.py
Created November 14, 2022 01:33
Grab all contacts from Telegram
"""
Expects a config file containing the app data from https://my.telegram.org/apps
to be saved at ``'~/.telegram/conf.yaml'``
```yaml
cgrab:
id: <yourId>
hash: <yourHash>
servers:
test:
@flipdazed
flipdazed / create-branch-protection-rule.sh
Last active March 26, 2023 07:29
Create Branch Protection with GitHub API
#!/bin/bash
set -ue
err() { echo 1>&2 "$*"; }
die() { err "ERROR: $*"; exit 1; }
mustBool() {
[[ "${1#*=}" = "true" || "${1#*=}" = "false" ]] ||
die "bad boolean property value: $1"
}
mustInt() {
[[ "${1#*=}" =~ [0-9]+ ]] ||
@flipdazed
flipdazed / pr-unresolved-review-comments.sh
Last active November 12, 2023 23:02
Retrieve/Count unresolved review comments
# Script Name: pr-unresolved-review-comments
#
# Description:
# This script is used to fetch unresolved review comments from a pull request in a Github repository.
# The script uses Github's GraphQL API to query the repository and filter out resolved comments.
# It returns a list of unresolved comment threads, which can then be processed as per requirements.
#
# Usage:
# There are two general use cases for this script.
#
@flipdazed
flipdazed / list-all-non-project-issues.sh
Last active November 17, 2023 21:03
Lists all issues that are not assigned to a project
#!/bin/bash
# This script lists all the open issues in specified owner's repository or all repositories if no specific one is given.
# The mandatory parameter is -o (owner) and optional parameters are -r (repository) and -c (cache time).
# If no repository(-r) is mentioned, it fetches issues from all repositories of that owner.
# It also caches results of recently fetched project issues based on cache_time (-c). The default cache_time is 3600 seconds if not passed.
# After fetching all issues, it finds the difference between all_issues and issue_details to get issues not allocated to any project.
# Usage: ./script_name.sh -o [owner] -r [repository] -c [cache_time]
# Example: ./script_name.sh -o Microsoft -r vscode -c 5000
@flipdazed
flipdazed / get-issues-by-project-status.sh
Created November 12, 2023 23:00
This script fetches issues or pull requests from the specified project number with a specific status from the given owner's repository.
#!/bin/bash
# Usage: ./script.sh -o [owner-name] <PROJECT_NUMBER> <STATUS>
#
# This script fetches issues or pull requests from the specified project number with a specific status
# from the given owner's repository.
# The mandatory parameters are 'owner' passed as a flag -o and PROJECT_NUMBER, STATUS passed as positional arguments.
# It also accepts an optional parameter '-j' for JSON output. If provided, it pretty prints the output in markdown format.
# Example: ./script.sh -o my-org 123 "In Progress"
# ./script.sh -o my-org -j json 123 "In Progress"
@flipdazed
flipdazed / secondary_liquidity_of_tokens.py
Last active January 5, 2024 15:44
Plotting the Network of Secondary Liquidity of Tokens
"""
Analyze and visualize Ethereum contract transactions.
It connects to the Ethereum mainnet, retrieves transaction logs, and creates an interactive graph showing
transaction history between various addresses. The script supports command-line arguments for customization such
as specifying contract addresses, enabling circular layouts, and excluding certain types of addresses.
Author: Alex McFarlane <alexander.mcfarlane@physics.org>
License: MIT
Can be called like as follows (example is USDY):