This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update_stuff(request, pk): | |
instance = get_object_or_404(PCB, pk=pk) | |
if request.method in ('POST', 'PUT'): | |
form = FormClass(data=request.POST, files=reuqest.FILES, instance=instance) | |
if form.is_valid(): | |
form.save() | |
... | |
else: | |
form = FormClass(instance=instance) | |
render_to_response({'form':form}, ...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from compressor.filters import CompilerFilter | |
class CoffeeCompilerFinder(staticfiles.finders.AppDirectoriesFinder): | |
""" | |
A quick hacked up staticfiles-finder that will automatically recompile .coffee files to .js and serve the .js file | |
It will respond to a request for /foo/bar/baz.js and if the coffee-file with the same name in that same dir is newer then | |
then js-file requested then the js-file will be recompiled. | |
I did this to not have to manually recompile my scripts or use the watcher and still be compatible with require.js | |
without have to change the code once i deploy with compiled js-files. it depends on django-compressor at the moment | |
but if you dont use that its just a small class to lift out from it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Application | |
id: "testApp" | |
Area | |
id: "appArea" | |
class: "row" | |
state: "page1" | |
states: | |
page1: State |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GLint nUniforms, nAttributes; | |
GLchar* label = new GLchar[128]; | |
GLenum type; | |
GLsizei length(0); | |
GLint size(0); | |
glGetProgramiv(m_programId, GL_ACTIVE_UNIFORMS, &nUniforms); | |
std::cout << "\tActive uniforms ("<< yellow << nUniforms << "): "; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set nocompatible | |
set t_Co=256 | |
set lazyredraw | |
set wildmode=list:longest | |
set nobackup | |
set nowritebackup | |
set noswapfile | |
set background=dark | |
set showcmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ uvicorn test.asgi:application | |
INFO Started server process | |
INFO Uvicorn running | |
INFO Application startup complete. | |
INFO 127.0.0.1:54844 - "GET / HTTP/1.1" 200 | |
Request done at 2019-12-11 19:13:01.500296 | |
Sleepy woke at 2019-12-11 19:13:06.506096 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ScopedMethodRateThrottle(ScopedRateThrottle): | |
""" | |
If you need to set different throttles per different http method on the same view. | |
# Usage | |
## views.py | |
class MyView(SomeAPIView): | |
throttle_classes = [ScopedMethodRateThrottle,] |