Skip to content

Instantly share code, notes, and snippets.

View riyasyash's full-sized avatar
🤔
"pondering the pointlessness of Whatsapp statuses on a code hosting service"

RIYAS P riyasyash

🤔
"pondering the pointlessness of Whatsapp statuses on a code hosting service"
View GitHub Profile
@riyasyash
riyasyash / image_server.py
Last active October 16, 2021 05:41
Static Image Server
from flask import Flask, request, send_from_directory
from datetime import datetime
app = Flask(__name__, static_url_path='')
@app.route('/')
def send_js():
ip =""
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
if request.environ.get('HTTP_X_FORWARDED_FOR') is None:
@riyasyash
riyasyash / delete_cloudwatch_logs.py
Created June 14, 2019 08:17
Remove all log groups and streams from AWS Cloudwatch for a region
# Python 2.7
# Script to delete all the log groups and log streams for a given account
# populate the aws_secret_access_key and aws_access_key_id
import boto3
client = boto3.client('logs', aws_access_key_id='', aws_secret_access_key='')
log_groups = [str(log_group['logGroupName']) for log_group in client.describe_log_groups()['logGroups']]
for group_name in log_groups:
log_streams = [str(log_stream['logStreamName']) for log_stream in client.describe_log_streams(logGroupName=group_name)['logStreams']]
@riyasyash
riyasyash / Django-notes.md
Created October 13, 2018 17:54
Django cheatsheet

Django Notes

Command to give sql statements run in a migration - sqlmigrate

python manage.py sqlmigrate polls 0001

Check the date/month/year property of a Datetimefield

Question.objects.get(pub_date__year=current_year)

setting up the test client

@riyasyash
riyasyash / authorization_code.py
Last active February 26, 2019 05:59
Oauth 2.0 Provider
class AuthorizationCode(models.Model):
client = models.ForeignKey(Client)
user = models.ForeignKey(User)
code = models.CharField(max_length=100, unique=True)
expires_at = models.DateTimeField()
class Meta:
managed = True
def generate_user_token(self):
try: