Skip to content

Instantly share code, notes, and snippets.

View zhoudaxia233's full-sized avatar
🎯
Focusing

Zheng Zhou zhoudaxia233

🎯
Focusing
View GitHub Profile
@nghiaht
nghiaht / test_upload.py
Created March 21, 2019 09:09
Testing Django Rest Framework with multipart/form-data request
from django.test import TestCase
from rest_framework.test import APIClient
class FileUploadTestCase(TestCase):
def test_upload(self):
client = APIClient()
client.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
# or self.client (Django https://docs.djangoproject.com/en/dev/topics/testing/advanced/)
response = client.post(reverse('upload-file'), {
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active July 23, 2024 10:19
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@stared
stared / live_loss_plot_keras.ipynb
Last active February 25, 2023 10:20
Live loss plot for training models in Keras (see: https://github.com/stared/livelossplot/ for a library)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chsasank
chsasank / elastic_transform.py
Last active October 14, 2023 01:55 — forked from fmder/elastic_transform.py
Elastic transformation of an image in Python
import numpy as np
from scipy.ndimage.interpolation import map_coordinates
from scipy.ndimage.filters import gaussian_filter
def elastic_transform(image, alpha, sigma, random_state=None):
"""Elastic deformation of images as described in [Simard2003]_.
.. [Simard2003] Simard, Steinkraus and Platt, "Best Practices for
Convolutional Neural Networks applied to Visual Document Analysis", in
@ramalho
ramalho / coro_life.py
Last active July 23, 2024 03:21
John Conway's Game of Life implemented with coroutines, by Brett Slatkin
#!/usr/bin/env python3
# Copyright 2014 Brett Slatkin, Pearson Education Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@msimpson
msimpson / cfire
Created July 21, 2011 10:51
Curses based ASCII art fire animation.
#!/usr/bin/python
import curses, random
screen = curses.initscr()
width = screen.getmaxyx()[1]
height = screen.getmaxyx()[0]
size = width*height
char = [" ", ".", ":", "^", "*", "x", "s", "S", "#", "$"]
b = []