Skip to content

Instantly share code, notes, and snippets.

@denilsonsa
denilsonsa / README.md
Last active August 15, 2023 05:01 — forked from noromanba/README.md
add permanently HEAD links on Gist for UserScript
@denilsonsa
denilsonsa / README.md
Last active December 3, 2023 04:56 — forked from a9cQ0Q/README.md

slow

This bash script offers quick shortcuts to simulate slower network connections. It is useful when you need to simulate a wireless network on a Linux network server, especially when you are using a virtual machine guest on your local machine or in the cloud.

slow 3G                   # Slow network on default eth0 down to 3G wireless speeds
slow 3G -l 600ms -p 10%   # slow network on eth0 and setup latency to 600ms packetloss to 10%
slow reset                # Reset connection for default eth0 to normal
slow vsat --latency=500ms # Simulate satellite internet  with a high latency

slow dsl -b 1mbps # Simulate DSL with a slower speed than the default

@denilsonsa
denilsonsa / timezone_and_django.py
Last active August 29, 2015 14:03 — forked from anonymous/dpaste.de_snippet.py
datetime object, when rendered to Django template, was always 6 minutes off.
class LocalDateTimeField(with_metaclass(models.SubfieldBase, models.DateTimeField)):
'''A hack/workaround version of DateTimeField that considers the datetime
from the database as local time.
'''
def to_python(self, value):
from django.utils.dateformat import format
value = models.DateTimeField.to_python(self, value)
if isinstance(value, datetime):
print('-' + repr(value))
print(strftime('%Y-%m-%d %H:%M:%S.%f', value.timetuple()))