Skip to content

Instantly share code, notes, and snippets.

View samsonq's full-sized avatar
🏀
Balling

Samson Qian samsonq

🏀
Balling
View GitHub Profile
@samsonq
samsonq / fibonacci.py
Last active January 4, 2022 22:47
Fibonacci Sequence
def fibonacci_sequence(n, n1, n2):
assert n > 0, "output length must be > 0"
sequence = [n1, n2]
while len(sequence) < n:
sequence.append(sequence[-1]+sequence[-2])
return sequence
def recursive_fibonacci(n, n1, n2, sequence=[]):
if len(sequence) < 2:
@samsonq
samsonq / pca.py
Last active November 10, 2021 00:06
Principal Component Analysis (PCA)
"""
Implementation of Principal Component Analysis
Author: Samson Qian
"""
import numpy as np
class PCA:
"""
Principal Component Analysis
"""
@samsonq
samsonq / brownian_model_grid.py
Created November 5, 2021 20:16
Brownian Motion Simulation
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import random
def brownian_model_plot(length):
# Length of array (or how long motion is modeled)
X = np.zeros((length,2))
for i in range(0,len(X) - 1):
@samsonq
samsonq / regex.txt
Created November 5, 2021 01:03
Regular Expression (RegEx)
**Basic Characters**:
^
Matches the expression to its right, at the start of a string before it experiences a line break
$
Matches the expression to its left, at the end of a string before it experiences a line break
.
Matches any character except newline
a
Matches exactly one character a
@samsonq
samsonq / random_walk.py
Created November 5, 2021 00:54
Random Walk Simulation & Visualization
import random
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import animation
from matplotlib.animation import FuncAnimation
def updatePosition(position, index, operator):
p = list(position)
if operator:
p[index] += 1
@samsonq
samsonq / send_doge.py
Created May 25, 2021 08:41
Send DOGE
from blockcypher import *
import json
from cryptos import *
def getBalance(adr):
res = get_address_full(address=adr, coin_symbol="doge")
return int(res['balance']) / 100000000
def sendDoges(fromPriv,toPub, amount):
@samsonq
samsonq / pypi_package
Created April 27, 2021 02:11
Publish/Update Python Package
// Ensure `README.md` and `setup.py` are properly set up
// Update distribution packages
python -m pip install --user --upgrade setuptools wheel
python -m pip install --user --upgrade twine
// Create package distribution files
python setup.py sdist bdist_wheel
ls dist // ensure dist files are present
@samsonq
samsonq / heroku_deploy
Last active March 11, 2021 00:31
Heroku Application
// login
heroku login -i
// add repo to heroku
// create or pick existing heroku project name
heroku git:remote -a {your-project-name}
// deploy heroku app
git push heroku master
@samsonq
samsonq / sort.py
Created March 8, 2021 23:56
Sorts
class Sort:
def __init__(self, arr):
self.arr = arr
def brute_force(self):
return
def quick_sort(self):
return
@samsonq
samsonq / git
Created March 8, 2021 23:53
Git Commands
// delete branch locally
git branch -d <branchName>
// delete branch remotely
git push origin --delete <branchName>