Skip to content

Instantly share code, notes, and snippets.

View ridwanray's full-sized avatar
💭
I'm Always Learning and Implementing New Things

ridwanray

💭
I'm Always Learning and Implementing New Things
View GitHub Profile
@ridwanray
ridwanray / assert_not_raises.py
Created July 28, 2024 12:04 — forked from oisinmulvihill/assert_not_raises.py
How to test a python exception is not raised with pytests
# Updated for python3
#
# https://stackoverflow.com/questions/20274987/how-to-use-pytest-to-check-that-error-is-not-raised/35458249#35458249
#
from contextlib import contextmanager
@contextmanager
def not_raises(ExpectedException):
try:
@ridwanray
ridwanray / docker
Created February 14, 2023 17:14 — forked from jwarykowski/docker
Docker Prune Commands
As of 1.13.0, new prune commands:
docker container prune # Remove all stopped containers
docker volume prune # Remove all unused volumes
docker image prune # Remove unused images
docker system prune # All of the above, in this order: containers, volumes, images
docker system df # Show docker disk usage, including space reclaimable by pruning
{
"UserInfo": {
"id": "#{USER_ID}",
"email": "#{USER_EMAIL}",
"first_name": "#{USER_FIRST_NAME}",
"last_name": "#{USER_LAST_NAME}",
"name": "#{USER_NAME}",
"picture": "#{USER_PROFILE_PICTURE}",
"roles": {
"#{ROLE_NAME}": "#{ROLE_ID}"
@ridwanray
ridwanray / shell_script.md
Created August 27, 2022 11:16 — forked from mklef121/shell_script.md
I have put together in this gist, practicals and theories you need to know to become a shell Ninja. This is because Shell Scripting allows you to encapsulate common lists of commands in a file, automate processes and build easily configurable tools.

BASH SCRIPTING-- Bourne-Again Shell

A shell script is a computer program designed to be run by the Unix/Linux shell. A shell is a command-line interpreter and typical operations performed by shell scripts include file manipulation, program execution, and printing text.

Unix/Linux shells include

  • The Bourne Shell
    • Bourne shell (sh)
    • Korn shell (ksh)
@ridwanray
ridwanray / github-actions
Created August 15, 2022 08:08
github actions for postgres and redis for python app
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: mysite-app
on:
push:
branches: [ test-workflow ]
pull_request:
branches: [ master ]
@ridwanray
ridwanray / gist:331ad95cac585c8ac587883c4f2d4ddb
Created July 19, 2022 12:47 — forked from benbacardi/gist:227f924ec1d9bedd242b
Django reverse with a querystring
from django.utils.http import urlencode
def reverse_querystring(view, urlconf=None, args=None, kwargs=None, current_app=None, query_kwargs=None):
'''Custom reverse to handle query strings.
Usage:
reverse('app.views.my_view', kwargs={'pk': 123}, query_kwargs={'search': 'Bob'})
'''
base_url = reverse(view, urlconf=urlconf, args=args, kwargs=kwargs, current_app=current_app)
if query_kwargs:
return '{}?{}'.format(base_url, urlencode(query_kwargs))
@ridwanray
ridwanray / .gitignore
Created August 7, 2021 13:34 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@ridwanray
ridwanray / users.json
Created August 7, 2021 03:17 — forked from jefelewis/users.json
JSON Users
{
"users": [
{
"id": "1",
"firstName": "Kristin",
"lastName": "Smith",
"occupation": "Teacher",
"reviewCount": "6",
"reviewScore": "5",
},
@ridwanray
ridwanray / how-to-copy-aws-rds-to-local.md
Created July 13, 2021 17:40 — forked from syafiqfaiz/how-to-copy-aws-rds-to-local.md
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
@ridwanray
ridwanray / System Design.md
Created June 10, 2021 17:42 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?