This file contains hidden or 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
| import { createContext, useRef, useState } from 'react' | |
| export const PyodideContext = createContext() | |
| export default function PyodideProvider({ children }) { | |
| const pyodide = useRef(null) | |
| const hasLoadPyodideBeenCalled = useRef(false) | |
| const [isPyodideLoading, setIsPyodideLoading] = useState(true) | |
| return ( |
This file contains hidden or 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
| echo '#!/bin/sh' >/home/pi/r2p.sh | |
| echo >>/home/pi/r2p.sh | |
| echo '/home/pi/raspi2png-master/raspi2png --pngname /home/pi/Pictures/$(date +snapshot-%Y%m%d-%H%M%S.png)' >>/home/pi/r2p.sh | |
| sed -i.bak 's/scrot/sh \/home\/pi\/r2p.sh/g' /home/pi/.config/openbox/lxde-pi-rc.xml | |
| openbox --reconfigure |
This file contains hidden or 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
| #!/bin/bash | |
| NAME="hello_app" # Name of the application | |
| DJANGODIR=/webapps/hello_django/hello # Django project directory | |
| SOCKFILE=/webapps/hello_django/run/gunicorn.sock # we will communicte using this unix socket | |
| USER=hello # the user to run as | |
| GROUP=webapps # the group to run as | |
| NUM_WORKERS=3 # how many worker processes should Gunicorn spawn | |
| DJANGO_SETTINGS_MODULE=hello.settings # which settings file should Django use | |
| DJANGO_WSGI_MODULE=hello.wsgi # WSGI module name |
This file contains hidden or 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
| import base64 | |
| import cStringIO | |
| from django.core.files.uploadedfile import InMemoryUploadedFile | |
| # ... | |
| if request.POST.get('file') and request.POST.get('name'): | |
| file = cStringIO.StringIO(base64.b64decode(request.POST['file'])) | |
| image = InMemoryUploadedFile(file, | |
| field_name='file', |
This file contains hidden or 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
| import mongoengine | |
| class MongoModelSerializer(serializers.ModelSerializer): | |
| def get_default_fields(self): | |
| cls = self.opts.model | |
| opts = get_concrete_model(cls) | |
| #pk_field = opts.pk | |
| fields = [] | |
| fields += [getattr(opts, field) for field in opts._fields] | |
| #fields += [field for field in opts.many_to_many if field.serialize] |
This file contains hidden or 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
| #!/usr/bin/env python | |
| #-*- coding: utf-8 -*- | |
| import time, random | |
| import urllib, urllib2 | |
| import hmac, hashlib | |
| import cgi | |
| # | |
| # OAuth Module for Twitter |
This file contains hidden or 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
| """ | |
| jQuery templates use constructs like: | |
| {{if condition}} print something{{/if}} | |
| This, of course, completely screws up Django templates, | |
| because Django thinks {{ and }} mean something. | |
| Wrap {% verbatim %} and {% endverbatim %} around those | |
| blocks of jQuery templates and this will try its best |