Python: create jupyter notebook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const base64 = 'data:image/png;base65,....' // Place your base64 url here. | |
fetch(base64) | |
.then(res => res.blob()) | |
.then(blob => { | |
const fd = new FormData(); | |
const file = new File([blob], "filename.jpeg"); | |
fd.append('image', file) | |
// Let's upload the file | |
// Don't set contentType manually → https://github.com/github/fetch/issues/505#issuecomment-293064470 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DEVENV=${1:-devopenfaas} | |
kind create cluster --name "$DEVENV" | |
export KUBECONFIG="$(kind get kubeconfig-path --name="$DEVENV")" | |
kubectl rollout status deploy coredns --watch -n kube-system | |
# INSTALLING HELM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#for not running docker, use save: | |
docker save <dockernameortag> | gzip > mycontainer.tgz | |
#for running or paused docker, use export: | |
docker export <dockernameortag> | gzip > mycontainer.tgz | |
#load | |
gunzip -c mycontainer.tgz | docker load |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Download the Large-scale CelebFaces Attributes (CelebA) Dataset | |
# from their Google Drive link. | |
# | |
# CelebA: http://mmlab.ie.cuhk.edu.hk/projects/CelebA.html | |
# | |
# Google Drive: https://drive.google.com/drive/folders/0B7EVK8r0v71pWEZsZE9oNnFzTm8 | |
python3 get_drive_file.py 0B7EVK8r0v71pZjFTYXZWM3FlRnM celebA.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Below are the dependencies required for installing the common combination of numpy, scipy, pandas and matplotlib | |
# in an Alpine based Docker image. | |
FROM alpine:3.4 | |
RUN echo "http://dl-8.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories | |
RUN apk --no-cache --update-cache add gcc gfortran python python-dev py-pip build-base wget freetype-dev libpng-dev openblas-dev | |
RUN ln -s /usr/include/locale.h /usr/include/xlocale.h | |
RUN pip install numpy scipy pandas matplotlib | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from gensim.models import KeyedVectors | |
from gensim.scripts.glove2word2vec import glove2word2vec | |
if os.path.exists('cui2vec_w.txt'): | |
wv_from_text = KeyedVectors.load_word2vec_format('cui2vec_w.txt', unicode_errors='ignore') | |
print(wv_from_text.most_similar("C0000052", topn=2)) | |
wv_from_text.save_word2vec_format('cui2vec_w.bin', binary=True) | |
else: | |
with open("cui2vec_pretrained.csv",'r') as f: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Fully backup a docker-compose project, including all images, named and unnamed volumes, container filesystems, config, logs, and databases. | |
project_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )" | |
cd "$project_dir" | |
project_name=$(basename "$project_dir") | |
backup_time=$(date +"%Y-%m-%d_%H-%M") | |
backup_dir="$project_dir/data/backups/$backup_time" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a Singularity image from a Docker image that is in the Docker hub | |
// where /tmp/ is the folder where the image will be created and ubuntu:14.04 | |
// is the docker image used to convert to the Singularity image | |
docker run \ | |
-v /var/run/docker.sock:/var/run/docker.sock \ | |
-v /tmp/:/output \ | |
--privileged -t --rm \ | |
singularityware/docker2singularity \ | |
ubuntu:14.04 | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import codecs | |
data_directory = os.path.join('..', 'data', | |
'yelp_dataset_challenge_academic_dataset') | |
businesses_filepath = os.path.join(data_directory, | |
'yelp_academic_dataset_business.json') | |
with codecs.open(businesses_filepath, encoding='utf_8') as f: |