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
#!/usr/bin/env python | |
from datetime import datetime, timezone | |
import boto3 | |
# ###################################### | |
# | |
# Empty Bucket of all delete markers from all objects. | |
# | |
# ###################################### |
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
import json | |
from contextlib import contextmanager | |
data = {'key': 1234} | |
with open('the_json_file.json', 'wt') as json_file: | |
json.dump(data, json_file) | |
with OpenFile('the_json_file.json', 'wt') as json_file: | |
json.dump(data, json_file) |
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
# helpers.py | |
@deconstructible | |
class RandomFileName(object): | |
def __init__(self, path): | |
self.path = os.path.join(path, "%s%s") | |
def __call__(self, _, filename): | |
# @note It's up to the validators to check if it's the correct file type in name or if one even exist. | |
extension = os.path.splitext(filename)[1] | |
return self.path % (uuid.uuid4(), extension) |
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 ForceDefaultLanguageMiddleware(object): | |
""" | |
Ignore Accept-Language HTTP headers | |
This will force the I18N machinery to always choose settings.LANGUAGE_CODE | |
as the default initial language, unless another one is set via sessions or cookies | |
Should be installed *before* any middleware that checks request.META['HTTP_ACCEPT_LANGUAGE'], | |
namely django.middleware.locale.LocaleMiddleware | |
""" |
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
var express = require("express"); | |
var http = require("http"); | |
var socket = require("socket.io"); | |
// express app | |
app = express(); | |
// http server based on express app | |
server = http.createServer(app); | |
io = socket(server); |