Skip to content

Instantly share code, notes, and snippets.

View sveetch's full-sized avatar
🥝
I'm a kiwi

David THENON sveetch

🥝
I'm a kiwi
View GitHub Profile
@sveetch
sveetch / renamer.py
Last active October 28, 2021 10:15
Filename renamer
"""
Command line script to rename media files.
Prerequisite:
* Python >= 3.6;
* Unicode and Emoji fonts enabled in your terminal console;
"""
import json
@sveetch
sveetch / dr_eggs.py
Last active September 16, 2021 23:45
A script to extract installed packages versions from a Buildout project
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
A script to extract installed packages versions from a Buildout project.
Install
*******
This is a "one man army" script without specific requirements. Just drop the file in
your project and use it.
@sveetch
sveetch / smart_image_format.py
Last active February 27, 2020 01:58
Class mixin and template tags samples to implement naive image smart format detection
class SmartFormatMixin(object):
"""
A mixin to inherit from a model so it will have a common helper
methods to manage image formats.
"""
def media_format(self, mediafile):
"""
Common method to perform a naive check about image format using file
extension.
@sveetch
sveetch / parsing-foundation-breakpoint.py
Created June 30, 2019 00:16
Attempt to parse foundation breakpoints to compare them in pixels
"""
Attempt to parse breakpoints to compare them in pixels
"""
from collections import OrderedDict
base_font_size = 16
base_font_unit = "px"
@sveetch
sveetch / sass-inclusion.css
Last active June 30, 2019 00:14
Some demo with placeholder, extend and mixins
/*
* Placeholder is not able to reference parent selector name like
* '&__something' but does not write anything if no selector extends it
*/
.bar, .foo {
color: red;
font-size: 1rem;
}
.title.bar, .title.foo {
content: ">";
@sveetch
sveetch / i18n.py
Last active June 30, 2019 00:11
Smart templatetag with translation and context driven from settings (save from an attempt on Richie)
"""
i18n utilities for our search app
"""
from django.conf import settings
def get_best_field_language(multilingual_field, best_language):
"""
Pick the best available language from a multilingual field.
@sveetch
sveetch / casperjs_authenticator.js
Created January 19, 2016 23:28
CasperJS script to authenticate and store persistent cookie through profile for SlimerJS
/*
*
* This is a CasperJS script.
*
* It try to authenticate so the session cookie can be stored in current profile
* and then BackstopJS+CasperJS+SlimerJS can use the same cookie during tests.
*
* Scenario
* ========
*
@sveetch
sveetch / app.js
Created February 13, 2018 11:05
Hack on Foundation 6.4.x responsive navigation drilldown to open item for current page
$(function($) {
/*
* Initialize Foundation
*/
$(document).foundation();
/*
* Trick to automatically open drilldown menu directly on the current page panel.
* This is recursive, due to drilldown mechanics, it needs to open all sub menu
* to reach item.
@sveetch
sveetch / colors.py
Last active February 1, 2018 00:20
Given a string of Sass color variables, output Sass variables for palette, color scheme models for Sveetoy and a Python list of available color names
# -*- coding: utf-8 -*-
"""
Given a string of Sass color variables, output Sass variables for palette,
color scheme models and Python list
"""
import io
COLORS_STRING = u"""
$black: #000000;
$white: #ffffff;
@sveetch
sveetch / _flexbox_support.scss
Created May 26, 2015 15:06
SCSS mixins to add support for Flexbox prefixes for IE10
@import "compass/css3";
@import "compass/css3/shared";
// For more information see https://gist.github.com/cimmanon/727c9d558b374d27c5b6
// NOTE:
// -----
// All mixins for the @box spec have been written assuming they'll be fed property values that
// correspond to the standard spec. Some mixins can be fed values from the @box spec, but don't