Skip to content

Instantly share code, notes, and snippets.

View jobelenus's full-sized avatar

John Obelenus jobelenus

View GitHub Profile
@jobelenus
jobelenus / websockets-best-practices.md
Last active March 8, 2023 06:52
Websockets with Django - Best Practices

John Obelenus, [email protected]

Websockets are basically the same sockets you used in your college programming courses.

Base websocket class

class BaseJsonWebsocketConsumer(JsonWebsocketConsumer):

    def send(self, content, close=False):
        """
@jobelenus
jobelenus / cards.js
Created May 26, 2016 22:39
Working JS under Node
#!/usr/bin/env node
var util = require('util');
console.log('start');
var A = 14;
var K = 13;
var Q = 12;
==> default: Notice: /Stage[main]/Supervisord/File[/etc/supervisord]: Dependency Exec[install-wkhtmltopdf] has failures: true
==> default: Warning: /Stage[main]/Supervisord/File[/etc/supervisord]: Skipping because of failed dependencies
==> default: Notice: /Stage[main]/Supervisord/File[/etc/init.d/supervisord]: Dependency Exec[install-wkhtmltopdf] has failures: true
==> default: Warning: /Stage[main]/Supervisord/File[/etc/init.d/supervisord]: Skipping because of failed dependencies
==> default: Notice: /Stage[main]/Supervisord/File[/etc/supervisord/conf.d]: Dependency Exec[install-wkhtmltopdf] has failures: true
==> default: Warning: /Stage[main]/Supervisord/File[/etc/supervisord/conf.d]: Skipping because of failed dependencies
==> default: Notice: /Stage[main]/Supervisord/File[/etc/supervisord.conf]: Dependency Exec[install-wkhtmltopdf] has failures: true
==> default: Warning: /Stage[main]/Supervisord/File[/etc/supervisord.conf]: Skipping because of failed dependencies
==> default: Notice: /Stage[main]/Supe
def get_product(self, instance):
if isinstance(instance, django_models.Model):
return instance.product
else:
try:
return api.TransientProduct(instance.product)
except:
return api.TransientProduct(instance['product'])

Keybase proof

I hereby claim:

  • I am jobelenus on github.
  • I am jobelenus (https://keybase.io/jobelenus) on keybase.
  • I have a public key whose fingerprint is 60D7 508C 21E4 30DC EEFC 5044 9BE9 7BF3 3E26 854F

To claim this, I am signing this object:

jezdez: if cloudfront is such a pain, maybe we have to bite the bullet
[1:06pm] jobelenus: well.. as you were saying earlier the trouble of a "dynamic" manifest file is how to determine and store the name…
[1:06pm] jezdez: I'd then prefer the format manifest.<md5-of-content>.json and then store the name in the cache
[1:06pm] jezdez: it sucks but I can't think of a better way
[1:06pm] jobelenus: my latest thought is: "well this manifest file is really just a key->value pair… and we need persistence… why isn't this in the DB"
[1:07pm] jezdez: because there is no guarentee there will be a database
[1:07pm] jobelenus: hrmm
def get_offline_manifest_filename():
output_dir = settings.COMPRESS_OUTPUT_DIR.strip('/')
return os.path.join(output_dir, settings.COMPRESS_OFFLINE_MANIFEST)
_offline_manifest = None
def get_offline_manifest():
global _offline_manifest
import os
from compressor.conf import settings
class DynamicManifestStorageMixin(object):
"""
Use this Mixin to dynamically name the manifest file which will prevent
problems surrounding CDN edges/TTL and purge commands taking minutes
"""
def get_available_name(self, name):
* 83aa0ab (HEAD, origin/feature-internal-url, feature-internal-url) match indent to the first character of first arg
* 1a9c5fb lint white-space fix
* 5289727 lint white-space fix
* a097bbf re-working `use_internal_url` in declaration, adding test case for endpoint variable
* c1f4aec variable endpoint url
* 9109a57 (trunk) Merge remote-tracking branch 'upstream/trunk' into trunk
|\
| * 7fc910a (upstream/trunk) Update CHANGES.
| * 58f3722 Adding/Removing instances from targetpool requires a list. This fixes a bug with attaching/detaching nodes from loadbalancers. (Attach/Detach wasn't working)
| * b6f0ce8 Update upgrade notes.
SELECT
*,
(
6371 * acos(cos(radians(%s)) * cos(radians(latitude)) *
cos(radians(longitude) - radians(%s)) +
sin(radians(%s)) * sin(radians(latitude)))
) as distance