Skip to content

Instantly share code, notes, and snippets.

why-not /
Created May 15, 2024 05:26
Markdown file.

My Observable Framework Document

Here is some text before the React component.

<div id="my-react-component"></div>

Here is some text after the React component.

why-not / gist:6d3f60b0eff1151297d75899d767a52d
Last active May 5, 2024 18:22
Country's Border Page Rank
Rank Country Name PageRank
1. Namibia 0.1569
2. China 0.0147
3. Russian Federation 0.0119
4. Brazil 0.0099
5. Germany 0.0085
6. France 0.0084
7. Zambia 0.0083
8. Saudi Arabia 0.0078
why-not / shakespeare.txt
Created July 17, 2023 01:47
This file has been truncated, but you can view the full file.
First Citizen:
Before we proceed any further, hear me speak.
Speak, speak.
First Citizen:
You are all resolved rather to die than to famish?
why-not /
Created March 10, 2023 02:35
Code to get basic stats from videos in a given list of playlists (youtube)
import time
import pandas as pd
from googleapiclient.discovery import build
# Enter your API key here
api_key = "API KEY HERE"
# Create a service object for the YouTube API
youtube = build('youtube', 'v3', developerKey=api_key)
why-not /
Created November 2, 2022 21:45
useful bash functions backup.
function addpythonpath {
sed -i '' '/^PYTHONPATH/d' ~/.bashrc
sleep .5
echo PYTHONPATH=$PYTHONPATH >> ~/.bashrc
# install yt-dlp first for this to work.
# streams youtube videos via VLC.
function ytvlc {
why-not /
Last active April 15, 2022 22:54
print multiplication tables for children, with color formatting if needed. (python, pandas)
import pandas as pd
import numpy as np
def style_dataframe(df, maxvals=None):
result =
result.set_properties(**{'text-align': 'center'})
result.set_properties(**{'font-family': 'monospace'})
result.set_properties(**{'font-weight': 'bold'})
why-not /
Last active February 3, 2022 05:49
Sign and Verify Using Public/Private Keys
# generate private key
openssl genrsa -out private_key.pem 4096
# extract public key
openssl rsa -in private_key.pem -pubout >
# sign using private key
openssl dgst -sign private_key.pem -keyform PEM -sha256 -out VGG_ILSVRC_16_layers.caffemodel.sign -binary VGG_ILSVRC_16_layers.caffemodel
# extract using public key
why-not /
Created September 13, 2019 03:59
pandas data reader for stock data.
# command to install this library.
# conda install pandas-datareader
# example 1
import pandas_datareader as pdr
tsla = pdr.DataReader('tsla', data_source='google', start='2017-1-1')
# example 2
# calculates the trailing stop order price, can be used for weight loss like time series as well.
why-not /
Last active August 6, 2018 03:46
When you have a Sublime Text SFTP remote folder mapping to an Amazon AWS machine, everytime you reboot you have to update your Sublime SFTP config file so it knows where the folder/files are now. This ofcourse is massively tragic and should not be permitted in a civilized society. Hence this script. It even prints a connection string, so you can…
import json
import subprocess
FNAME = "/PATH/To/SUBLIME/SFTP/FILE/sftp-config.json"
def update_json_file(given_ip, filename):
jsonfile = open(filename, "r") # open the json file for reading
data = json.load(jsonfile) # read the json into the buffer
why-not /
Last active March 4, 2024 19:29
Automatically stopping an AWS machine when users are not actively using a machine via ssh, and the CPU load avg over the past 5 mins is less than THRESHOLD. This will avoid getting billed for the machine when not in use (except ofcourse your storage will still be billed unless you delete everything and decommission those as well, which this scri…
#!/usr/bin/env python
# shell commands being automated.
# w
# aws ec2 stop-instances --instance-id INSTANCE_ID
The script is the easy part, installing it into the unfriendly(imo) cron system and
making all the permissions and paths are set correctly is another issue altogether.