Skip to content

Instantly share code, notes, and snippets.

@dariosky
dariosky / dropbox_wise_ignore.py
Last active February 17, 2023 19:30
A Python script to be run in a Dropbox folder - so it exclude all the node_modules and __pycache__ folders - we want them locally but not in the cloud
#!/usr/bin/env python3
import argparse
import os
import shutil
from xattr import xattr
top_folder = "."
CACHE_FOLDERS = {"__pycache__", ".pytest_cache", ".cache"}
@iximiuz
iximiuz / flask_static_files_cache_invalidator.py
Last active October 28, 2019 18:56
Flask: add static file's cache invalidator param to URLs generated by url_for(). Blueprints aware.
""" Inspired by http://flask.pocoo.org/snippets/40/ """
app = Flask(__name__)
@app.url_defaults
def hashed_url_for_static_file(endpoint, values):
if 'static' == endpoint or endpoint.endswith('.static'):
filename = values.get('filename')
if filename:
if '.' in endpoint: # has higher priority
@dariosky
dariosky / gist:5081432
Created March 4, 2013 10:43
Script for creating a complex mongodb shard for testing purpose on the local machine. Wrote for the Mongodb 102 course (week6) to facilitate the setup. Change the settings on the top of the script and run it. All commands are passed to mongo via subprocess, no pyMongo required. I keep it as mongo shell reference.
#!/bin/env python
# @author: Dario Varotto
"""
Script for creating a complex mongodb shard for testing purpose on the local machine.
Wrote for the Mongodb 102 course (week6) to facilitate the setup.
Change the settings on the top of the script and run it.
All commands are passed to mongo via subprocess, no pyMongo required.
I keep it as mongo shell reference.