Skip to content

Instantly share code, notes, and snippets.

View Ian729's full-sized avatar
πŸš€

Ian729

πŸš€
View GitHub Profile
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINAka9pEckb9hukyCQ+MCohwowz6pie/Itlb4QSf2+yv noname
@Ian729
Ian729 / install-openssl.sh
Created January 17, 2025 10:28 — forked from estshorter/install-openssl.sh
Install openssl on raspberry pi
#!/bin/bash -eu
OPENSSL_VER=3.0.0
mkdir openssl
cd openssl
wget https://www.openssl.org/source/openssl-${OPENSSL_VER}.tar.gz
tar xf openssl-${OPENSSL_VER}.tar.gz
cd openssl-${OPENSSL_VER}
./config zlib shared no-ssl3
@Ian729
Ian729 / wifi.sh
Last active December 6, 2024 05:48
[ "$1" = "" ] && echo "wifi version | wifi join [ssid] [password] | wifi get";
[ "$1" = "version" ] && echo "wifi v1.0 by Ian";
[ "$1" = "join" ] && networksetup -setairportnetwork en0 $2 $3;
[ "$1" = "get" ] && networksetup -getairportnetwork en0;
@Ian729
Ian729 / do_lint.sh
Last active December 6, 2024 05:43
do Python lint
set -x
clear
for file in $(find ./ -type f -name "*.py")
do
mypy --exclude '/setup\.py$' --exclude '.*build.*' ${file}
echo "==================================================="
isort ${file}
echo "==================================================="
black --line-length 79 ${file}
@Ian729
Ian729 / dfs.py
Created January 17, 2022 12:49
Depth First Search
# Leetcode 200
# https://leetcode.com/problems/number-of-islands/
def dfs(grid, i, j):
if grid[i][j] == "1":
grid[i][j] = "0"
if i-1 >= 0:
dfs(grid, i-1, j)
if i+1 < len(grid):
dfs(grid, i+1, j)
if j-1 >= 0:
@Ian729
Ian729 / bfs.py
Last active January 17, 2022 12:46
Breadth First Search
# Leetcode 102 103
# Breadth First Search Simplest
def bfs(root):
queue = [root]
while queue:
n = queue.pop(0)
queue.append(n.left)
queue.append(n.right)
# based on that, what we are deadling with might not be a perfect binary tree
@Ian729
Ian729 / sent.py
Created January 17, 2022 12:44
Sentiment Analysis
from textblob import TextBlob
tb = TextBlob("I am very happy")
print(tb.sentiment)
@Ian729
Ian729 / pi.py
Created January 17, 2022 12:26
Monte Carlo Pi
import random
# number of all points in 1/4 circle / number of all points = pi/4
def pi(n): return sum( [random.random()**2 + random.random()**2 <= 1 for _ in range(n)] ) / n * 4
# % python3 -i pi.py
print(pi(100))
# 3.52
print(pi(1000))
# 3.104
print(pi(10000))
# 3.1448