Skip to content

Instantly share code, notes, and snippets.

View omerasif57's full-sized avatar

Omer Asif omerasif57

View GitHub Profile
@omerasif57
omerasif57 / django-queryset-evaluation.note
Created January 30, 2021 12:32
When Django QuerySets are evaluated?
When QuerySets are evaluated
You can concatenate as many filters as you like to a QuerySet, and you will not hit the database until the QuerySet is evaluated. QuerySets are only evaluated in the following cases:
The first time you iterate over them
When you slice them, for instance, Post.objects.all()[:3]
When you pickle or cache them
When you call repr() or len() on them
When you explicitly call list() on them
@omerasif57
omerasif57 / lorempicsum.py
Last active February 10, 2021 09:42
Lorempicsum photo downloads using multi threads
from multiprocessing.pool import ThreadPool
from time import time
import wget
urlp = "https://picsum.photos/id/{}/720/1200"
urls = [(urlp.format(x), "{}.jpg".format(x)) for x in range(10)]
@omerasif57
omerasif57 / networkresdown.dart
Created February 28, 2021 12:08
Download A Network Image In Flutter using Dio Library
Future<Null> _downloadNetworkImage() async {
Dio dio = Dio();
try {
var dir = await getTemporaryDirectory();
print(dir);
Scaffold.of(context).showSnackBar(
SnackBar(content: Text("Downloading image. Please wait...")));
await dio.download(url, '${dir.path}/image.jpeg',
onReceiveProgress: (rec, total) {
@omerasif57
omerasif57 / bootomAppBar.dart
Created March 29, 2021 18:56
bottom appbar elevation plus rounded
bottomNavigationBar: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
decoration: BoxDecoration(boxShadow: [
BoxShadow(
blurRadius: 4.0,
offset: Offset(0.0, 0.0),
color: Colors.grey,
),
], borderRadius: BorderRadius.circular(36.0)),