Skip to content

Instantly share code, notes, and snippets.

@Mukei
Mukei / submit.md
Created June 13, 2022 14:27 — forked from tanaikech/submit.md
Downloading Shared Files on Google Drive Using Curl

Downloading Shared Files on Google Drive Using Curl

When the shared files on Google Drive is downloaded, it is necessary to change the download method by the file size. The boundary of file size when the method is changed is about 40MB.

File size < 40MB

CURL

filename="### filename ###"
fileid="### file ID ###"
curl -L -o ${filename} "https://drive.google.com/uc?export=download&amp;id=${fileid}"

filter result based on images names containing "base" in their names

index = [index for index, im_similar in enumerate(im_similar) if "base" in im_similar]

im_similar = [im_similar[i] for i in index]
distances = [distances[0][i] for i in index]
@Mukei
Mukei / cookbook_kaggle_in_colab.py
Last active November 29, 2019 00:56
How to use Kaggle in Google Colaboratory
#source https://www.kaggle.com/general/64962
!pip install kaggle
#Authenticating with Kaggle API
from googleapiclient.discovery import build
import io, os
from googleapiclient.http import MediaIoBaseDownload
from google.colab import auth
auth.authenticateuser() driveservice = build('drive', 'v3')
@Mukei
Mukei / kaggle_dataset load.py
Created March 17, 2019 14:41
Some Python command to use Kaggle on Colab
# To access kaggle datasets
!pip install kaggle
# Import data from Kaggle
# Colab's file access feature
from google.colab import files
# Retrieve uploaded file
uploaded = files.upload()
@Mukei
Mukei / conda_environment_rename.sh
Created November 30, 2017 07:01
How to rename a conda environment (workaround)
#One workaround is to create clone environment, and then remove original one:
#(remember about deactivating current environment with deactivate on Windows and source deactivate on macOS/Linux)
conda create --name new_name --clone old_name --offline #use --offline flag to disable the redownload of all your packages
conda remove --name old_name --all # or its alias: `conda env remove --name old_name`
#There are several drawbacks of this method:
# time consumed on copying environment's files,
# temporary double disk usage.
@Mukei
Mukei / install_packages.sh
Last active November 27, 2017 01:56 — forked from luiscape/install_packages.sh
Install Python dependency packages from requirements.txt using conda.
#
# Original solution via StackOverflow:
# http://stackoverflow.com/questions/35802939/install-only-available-packages-using-conda-install-yes-file-requirements-t
#
#
# Install via `conda` directly.
# This will fail to install all
# dependencies. If one fails,
# all dependencies will fail to install.
@Mukei
Mukei / useful_pandas_snippets.py
Last active November 6, 2017 07:13 — forked from bsweger/useful_pandas_snippets.md
[Useful Pandas Snippets] #python #pandas #cookbook
# List unique values in a DataFrame column
# h/t @makmanalp for the updated syntax!
df['Column Name'].unique()
# Convert Series datatype to numeric (will error if column has non-numeric values)
# h/t @makmanalp
pd.to_numeric(df['Column Name'])
# Convert Series datatype to numeric, changing non-numeric values to NaN
# h/t @makmanalp for the updated syntax!
@Mukei
Mukei / docker_cookbook.md
Last active September 11, 2019 15:02
[Docker Cookbook] #docker #cookbook
@Mukei
Mukei / s3_copy_snippets.sh
Last active October 22, 2017 11:24
[S3 copy snippets] #AWS #S3 #snippets #cookbook
#!
# Using aws s3 cp will require the --recursive parameter to copy multiple files.
aws s3 cp s3://myBucket/dir localdir --recursive
#The aws s3 sync command will, by default, copy a whole directory. It will only copy new/modified files.
aws s3 sync s3://mybucket/dir localdir
#Just experiment to get the result you want.
#You can combine --exclude and --include options to copy only objects that match a pattern, excluding all others.
aws s3 cp s3://mybucket/logs/ s3://mybucket2/logs/ --recursive --exclude "*" --include "*.log"