Skip to content

Instantly share code, notes, and snippets.

View anshajk's full-sized avatar
🎯
Focusing

Anshaj anshajk

🎯
Focusing
View GitHub Profile
@anshajk
anshajk / Dockerfile
Created December 13, 2020 12:44
Example buildspec.yml file and dockerfile for building docker image with AWS CloudBuild
FROM ubuntu:12.04
# Install dependencies
RUN apt-get update -y
RUN apt-get install -y apache2
# Install apache and write hello world message
RUN echo "Hello Cloud Gurus!!!! This web page is running in a Docker container!" > /var/www/index.html
# Configure apache
RUN a2enmod rewrite
@anshajk
anshajk / appspec.yml
Created December 13, 2020 09:00
Example appspec.yml for AWS CodeDeploy
version: 0.0
os: linux
files:
- source: /index.html
destination: /var/www/html/
hooks:
BeforeInstall:
- location: scripts/install_dependencies.sh
timeout: 300
runas: root
@anshajk
anshajk / serverless_scraper.py
Last active July 13, 2020 17:43
A python script which uses google cloud functions to do some web scraping and saves the data in a GCS bucket
import csv
import datetime
import json
import logging
import os
from google.cloud import storage
from twitter_scraper import get_tweets
log = logging.getLogger()
@anshajk
anshajk / property_decorator_python.py
Created July 12, 2020 10:41
@Property decorator example in python
# Using @property decorator
# Source - https://www.programiz.com/python-programming/property
class Celsius:
def __init__(self, temperature=0):
self.temperature = temperature
def to_fahrenheit(self):
return (self.temperature * 1.8) + 32
@property
@anshajk
anshajk / windowed_dataset.py
Created June 20, 2020 11:25
A small function for creating a windowed dataset for sequential networks using tensorflow 2.x
def windowed_dataset(series, window_size, batch_size, shuffle_buffer):
"""Function for creating a windowed dataset for sequence training"""
dataset = tf.data.Dataset.from_tensor_slices(series)
dataset = dataset.window(window_size + 1, shift=1, drop_remainder=True)
dataset = dataset.flat_map(lambda window: window.batch(window_size + 1))
dataset = dataset.shuffle(shuffle_buffer).map(lambda window: (window[:-1], window[-1]))
dataset = dataset.batch(batch_size).prefetch(1)
return dataset
@anshajk
anshajk / file.py
Created January 31, 2020 06:45
File
import numpy as np
for i in list_vals:
print('Anshaj')