Skip to content

Instantly share code, notes, and snippets.

View ReemRashwan's full-sized avatar
👩‍💻

ريم ReemRashwan

👩‍💻
View GitHub Profile
@Vibhu-Agarwal
Vibhu-Agarwal / models.py
Last active March 7, 2024 00:28
Example Describing How to Serialize Multiple Models through One Serializer (Case of Foreign Keys) | Django Rest Framework
from django.db import models
class ModelA(models.Model):
fieldA1 = models.CharField(max_length=100, unique=True)
fieldA2 = models.TextField(validators=[URLValidator()], blank=True, null=True)
fieldA3 = models.CharField(max_length=100, unique=True, null=True, blank=True)
field4 = models.BooleanField(default=True)
@soply
soply / disp_multiple_images.py
Last active January 9, 2024 14:52
Plot multiple images with matplotlib in a single figure. Titles can be given optionally as second argument.
import matplotlib.pyplot as plt
import numpy as np
def show_images(images, cols = 1, titles = None):
"""Display a list of images in a single figure with matplotlib.
Parameters
---------
images: List of np.arrays compatible with plt.imshow.
@mwarkentin
mwarkentin / json2csv.py
Created January 18, 2013 16:55
Convert a JSON datadump of a Django model into CSV format. Note: This only exports the fields dict, so you won't have pk in the output.
# -*- coding: utf-8 -*-
import codecs
import cStringIO
import csv
import json
import sys
"""
Convert Django json datadump fields into csv.
@npero
npero / gist:3633422
Created September 5, 2012 08:39
Get all remote branches and for each create an corresponding local branch.
for remote in `git branch -r | grep -v master `; do git checkout --track $remote ; done