Skip to content

Instantly share code, notes, and snippets.

@Jiayi-Pan
Created May 17, 2023 02:53
Show Gist options
  • Save Jiayi-Pan/e8f3ff4b99930ae5f6926725d3d817e2 to your computer and use it in GitHub Desktop.
Save Jiayi-Pan/e8f3ff4b99930ae5f6926725d3d817e2 to your computer and use it in GitHub Desktop.
StorageHack.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyN9t4LltEN0Dw4mVbeVSYwc",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/Jiayi-Pan/e8f3ff4b99930ae5f6926725d3d817e2/storagehack.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"source": [
"### Fill your Google Drive with 36 GB of random files\n",
"Why? \"Per Berkeley's policy, If your account holds more than 35 GB of content, you will receive an extended 150 GB limit on July 5, 2023.\n",
"All other accounts holding less than 35 GB of content will have the final limit of 50 GB applied on July 5, 2023.\""
],
"metadata": {
"id": "4TaEeMx9lJz0"
}
},
{
"cell_type": "code",
"source": [
"from google.colab import drive\n",
"from tqdm import tqdm\n",
"drive.mount('/content/drive')\n",
"\n",
"import os\n",
"\n",
"folder_path = '/content/drive/My Drive/random_data'\n",
"file_size_gb = 1\n",
"num_files = 36\n",
"\n",
"# Create the folder if it doesn't exist\n",
"if not os.path.exists(folder_path):\n",
" os.makedirs(folder_path)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "giPAgVZilKGm",
"outputId": "f1eb32a0-84bf-4189-9d06-fed2614c01ec"
},
"execution_count": 4,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"# Generate files\n",
"for i in tqdm(range(num_files)):\n",
" file_path = os.path.join(folder_path, f'file{i+1}.txt')\n",
" with open(file_path, 'wb') as file:\n",
" file.write(b'\\0' * (file_size_gb * 1024 * 1024 * 1024))\n"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "_2fYALxzlVjp",
"outputId": "42c9efd0-c4ac-40b5-8707-3a0fcabcbe77"
},
"execution_count": 5,
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"100%|██████████| 36/36 [08:31<00:00, 14.20s/it]\n"
]
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment