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 shutil import copy2 | |
from django.conf import settings | |
from django.db import models | |
import os | |
def get_image_paths(queryset): | |
img_fields = [f.name for f in queryset.model._meta.fields if | |
isinstance(f, models.ImageField)] | |
images = [] |
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 flatten_list(list_to_flatten): | |
flat_list = [] | |
for item in list_to_flatten: | |
if type(item) != list: | |
flat_list.append(item) | |
else: | |
flat_list += flatten_list(item) | |
return flat_list |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Title</title> | |
<style> | |
body { | |
background-color: #585858; | |
} | |
.outer-wrapper { |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Title</title> | |
<style> | |
body { | |
font-size: 16px; | |
margin: 0; | |
} |
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 datetime | |
import random | |
import json | |
def get_rand_dates_list(amount): | |
return [ | |
datetime.datetime(random.randint(2010, 2016), random.randint(1, 12), 1) | |
for i in range(amount)] |
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
""" | |
Will not fail until the `value` in gevent.sleep(<value>) will be more than | |
timeout value. | |
""" | |
from __future__ import print_function | |
import time | |
import gevent | |
from gevent import Timeout | |
seconds = 1 |
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 __future__ import print_function | |
import this | |
print('\n-------------------------\n' | |
'DECRYPTION OF the this.s:' | |
'\n-------------------------\n') | |
def decrypt(s, d): |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Date</title> | |
</head> | |
<body> | |
<script> | |
console.log('\nFrom date to ordinal:\n'); |
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
""" | |
Study python3's ``tempfile`` library. | |
""" | |
from __future__ import print_function | |
import os | |
import tempfile | |
import unittest | |
import sys | |
import subprocess |
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
""" | |
This is the example of mocking the builtin `open` function in python 2/3. | |
""" | |
from __future__ import print_function | |
import sys | |
import unittest | |
if sys.version_info.major == 3: | |
from unittest import mock | |
else: |
NewerOlder