One of the problems I have when testing giant TensorFlow models in TensorFlow.js is that they're huge (like 500 MB) and they take forever to download, every time I refresh the page. This is how I setup my ServiceWorker code so that at least in testing I only have to download the model once, and then it's saved in the cache for the next time.
| To change a field name in django 1.7+ | |
| 1. Edit the field name in the model (but remember the old field name: you need it for step 3!) | |
| 2. Create an empty migration | |
| $ python manage.py makemigrations --empty myApp | |
| 3. Edit the empty migration (it's in the migrations folder in your app folder, and will be the most recent migration) by adding | |
| migrations.RenameField('MyModel', 'old_field_name', 'new_field_name'), | |
| to the operations list. |
| #! /bin/sh | |
| green='\033[0;32m' | |
| nc='\033[0m' | |
| # Start from the repository root. | |
| cd ./$(git rev-parse --show-cdup) | |
| # Delete .pyc files and empty directories. | |
| echo "${green}Deleting PYC files...${nc}" | |
| find . -name "*.pyc" -delete |
| <html> | |
| <head> | |
| <style> | |
| .item {width:300px; display: inline-block; } | |
| .item .itemtitle {font-weight:bold; font-size:2em;} | |
| .hidden {display:none;} | |
| </style> | |
| </head> | |
| <body> | |
| <h1>Amalgam Comics Characters</h1> |
| # pip install django-debug-toolbar==1.4.0 | |
| # /api/endpoint/?format=json&debug | |
| from django.http import HttpResponse | |
| import json | |
| INSTALLED_APPS += ('debug_toolbar',) | |
| MIDDLEWARE_CLASSES += ( | |
| 'debug_toolbar.middleware.DebugToolbarMiddleware', |
| '/Applications/VMware Fusion.app/Contents/Library/vmrun' stop '</path/to/virtual/machine>/<virtual_machine_name>.vmwarevm' |
| '/Applications/VMware Fusion.app/Contents/Library/vmrun' start '</path/to/virtual/machine/><virtual_machine_name>.vmwarevm' nogui |
This setup aims to create a clean development environment, by keeping development tools and libraries in a virtual machine, separate from the host computer. Separation has several advantages: you can back up the virtual machine, move it to a different host, keep multiple environments around (e.g. for wokring on projects with wildly different dependencies, or upgrading the development toolchain without risking downtime), and base the development environment on a different OS (hello Linux!). Last but not least, it keeps the host machine clean.
The downside is that you're running code inside a VM. You need to log in (we'll use SSH), make sure the code is available and in sync (we'll set up NFS). There's also some I/O overhead, and you need to decide on how much memory, CPU and disk space you allocate to the VM. You can change your mind later, but it's a bit of a hassle to resize virtual disks and partitions.
We assume you're running MacOS and have VMware Fusion already installed
| def get_object_list(self, request): | |
| """ Usage: http://<example.com>/api/v1/<myresource>/?exclude_ids=1,2,3,4 | |
| """ | |
| if request.GET.get('exclude_ids'): | |
| bundle = super(<MyResource>, self).get_object_list(request).exclude( | |
| id__in=request.GET.get('exclude_ids').split(',') | |
| ) | |
| return bundle |
| rsync -avlzp <hostname>:</remote/folder/path> </local/folder/path> |