Skip to content

Instantly share code, notes, and snippets.

@WaYdotNET
WaYdotNET / docker-volumes.md
Created January 21, 2024 08:55 — forked from onlyphantom/docker-volumes.md
Demystifying Docker Volumes for Mac and PC Users

Demystifying Docker Volumes for Mac and PC Users

  1. Docker runs on a Linux kernel

Docker can be confusing to PC and Windows users because many tutorials on that topic assume you're using a Linux machine.

As a Linux user, you learn that Volumes are stored in a part of the host filesystem managed by Docker, and that is /var/lib/docker/volumes. When you're running Docker on a Windows or Mac OS machine, you will read the same documentation and instructions but feel frustrated as that path don't exist on your system. This simple note is my answer to that.

When you use Docker on a Windows PC, you're typically doing one of these two things:

  • Run Linux containers in a full Linux VM (what Docker typically does today)
# 💡 NOTE: This only works if you are pretend to using `Django Console` feature in Pycharm
# Paste codes below into `Build, Execution, Deployment > Console > Django Console > Starting Script`
# requirements: `django_extensions`, `IPython`
import sys
import django
from IPython.core.getipython import get_ipython
from django_extensions.management.notebook_extension import load_ipython_extension
/* eslint-disable */
const enableOfflinePlugin = false
const __DEV__ = process.env.NODE_ENV === 'development'
const __OFFLINE__ = enableOfflinePlugin && !__DEV__
const path = require('path')
const glob = require('glob')
const webpack = require('webpack')
"""
Django ORM Optimization Tips
Caveats:
* Only use optimizations that obfuscate the code if you need to.
* Not all of these tips are hard and fast rules.
* Use your judgement to determine what improvements are appropriate for your code.
"""
# ---------------------------------------------------------------------------
@WaYdotNET
WaYdotNET / weasyprint_complex_headers.py
Created June 11, 2019 19:21 — forked from pikhovkin/weasyprint_complex_headers.py
Repeat on each page of complex headers (eg, tables) except the first page
# coding: utf-8
from weasyprint import HTML, CSS
def get_page_body(boxes):
for box in boxes:
if box.element_tag == 'body':
return box
@WaYdotNET
WaYdotNET / pdf.py
Created June 11, 2019 19:20 — forked from nathandem/pdf.py
Arbitrary header/footer integration in Weasyprint PDF pages
from weasyprint import HTML, CSS
class PdfGenerator:
"""
Generate a PDF out of a rendered template, with the possibility to integrate nicely
a header and a footer if provided.
Notes:
------
git log (get the commit id that you want to reset to)
git reset --hard "commit id"
git reset --soft HEAD@{1}
git commit -m "Reverting to the state of the project at commit id"
git push
@WaYdotNET
WaYdotNET / optimize.sh
Created August 31, 2018 14:53 — forked from danielantelo/optimize.sh
Optimise images in a folder for web
#!/bin/bash
commandExists () {
type "$1" &> /dev/null ;
}
installImageMagick() {
if commandExists brew; then
brew install imagemagick
else
@WaYdotNET
WaYdotNET / thread.py
Created May 31, 2018 18:22 — forked from ruedesign/thread.py
Python thread sample with handling Ctrl-C
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, time, threading, abc
from optparse import OptionParser
def parse_options():
parser = OptionParser()
parser.add_option("-t", action="store", type="int", dest="threadNum", default=1,
help="thread count [1]")
@WaYdotNET
WaYdotNET / recurse_ftp.py
Created January 30, 2018 07:00 — forked from flibbertigibbet/recurse_ftp.py
Recursively fetch files from an FTP server directory. Here, it's downloading all the zip files found in or beneath the parent directory.
#!/usr/bin/env python
from ftplib import FTP
from time import sleep
import os
my_dirs = [] # global
my_files = [] # global
curdir = '' # global