Skip to content

Instantly share code, notes, and snippets.

View yardensachs's full-sized avatar

Yarden Sachs yardensachs

  • Sure
  • Los Angeles
View GitHub Profile
@yardensachs
yardensachs / resetmigrations.py
Last active August 12, 2024 01:19
This Django management command deletes all migration records from the django_migrations table, and recreates a fake initial migration record. This can be helpful for resetting the migration history during development.
"""
This Django management command deletes all migration records from the django_migrations table,
and recreates a fake initial migration record.
Usage:
python manage.py resetmigrations --database=<database_name>
"""
from django.core import management
from django.core.management.base import BaseCommand, CommandParser
@yardensachs
yardensachs / README.md
Last active October 9, 2018 20:00
Terraform state moving script

Terraform state moving script

This script will use a mapping of old and new Terraform resources path to move from an exisiting state to a new state. This is handy when restructuring a Terraform project.

Steps before running this script:

  • In exisiting project:
    • Make sure you have intiiated with the correct state backend (if you are using different state backends)
    • Run terraform state list and grab the paths. you would need to filter between resource paths and other paths like data blocks
  • In new structure:
  • Run terraform init
@yardensachs
yardensachs / README.md
Last active October 8, 2018 10:55
Django TestCase assert method for counting executed queries with a specified model.

Specified model Django TestCase assertion

Django TestCase assert method for counting executed queries with a specified model.

Built using example from the django assertNumQueries method.

Usage:

with self.assertModelAndNumQueries([
### Keybase proof
I hereby claim:
* I am yardensachs on github.
* I am yarden (https://keybase.io/yarden) on keybase.
* I have a public key ASBCUWIt0RVHeNxG7UMmOf2s7n8VyWGz28IsVyXDX2df9wo
To claim this, I am signing this object: