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
// Modify contrast using a ColorMatrix (on Android) | |
ColorMatrixColorFilter setContrast(float contrast) { | |
float scale = contrast + 1.f; | |
float translate = (-.5f * scale + .5f) * 255.f; | |
float[] array = new float[] { | |
scale, 0, 0, 0, translate, | |
0, scale, 0, 0, translate, | |
0, 0, scale, 0, translate, | |
0, 0, 0, 1, 0}; | |
ColorMatrix matrix = new ColorMatrix(array); |
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
class ColorDict(object): | |
"""Provides a color for each key, trying to create as distinct a set | |
of colors as possible. | |
""" | |
# Minimum difference in hue between unique colors, before we begin | |
# to recycle old colors rather than generating new ones. | |
THRESHOLD = 0.05 | |
def __init__(self): |
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
The idea is two provide optional variations for your stylesheet, for | |
presentation purposes, and have a switcher built into the page to | |
enable/disable them. | |
Usage - include the Javascript code in your page: | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<script src="cssoptions.js"></script> | |
Note that jQuery >= 1.7 is required. |
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
class ServerRack(object): | |
"""Manages multiple gevent Servers. Works with anything that has | |
start() and stop() methods. | |
Adapted from: | |
https://gist.github.com/1008826 | |
""" | |
def __init__(self): | |
self._servers = [] |
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 webassets.test import TempEnvironmentHelper | |
from webassets import * | |
with TempEnvironmentHelper() as h: | |
h.create_files({ | |
'empty': '', | |
'scss/styles1.scss': 'h1 { color: red }', | |
'scss/styles2.scss': 'h2 { color: green }', | |
}) |
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
"""Make PyYAML output an OrderedDict. | |
It will do so fine if you use yaml.dump(), but that generates ugly, | |
non-standard YAML code. | |
To use yaml.safe_dump(), you need the following. | |
""" | |
def represent_odict(dump, tag, mapping, flow_style=None): | |
"""Like BaseRepresenter.represent_mapping, but does not issue the sort(). |
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
""" | |
Usage with the following directory structure : :: | |
sources/ | |
js/ | |
css/ | |
images/ | |
_build/ | |
static/ | |
css/ |
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
/** | |
* Implement a very basic TableController. | |
* | |
* In particular, consider these limitations for now: | |
* | |
* - Only databind in one direction, from model to table. | |
* - When changes occur, we currently simply recreate all rows. | |
* | |
* Design-wise, one could imagine different approaches. Because the table | |
* is so old, it's usage is totally different from the rest of Qooxdoo. It |
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
/** | |
* Add an "CMS internal link" option to the Link plugin. | |
* | |
* This was adapted from a similar plugin for Drupal (version 7.x-2.3): | |
* Written by Henri MEDOT <henri.medot[AT]absyx[DOT]fr> | |
* http://www.absyx.fr | |
* https://drupal.org/project/ckeditor_link | |
* | |
* Portions of code: | |
* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. |
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
// When logged in, go to "Settings > Checkout > Checkout Language", click the "View and customize this translation" link. | |
// A page with a url like this opens: "https://yourshop.myshopify.com/admin/settings/locales/[locale_id]". | |
// copy [locale_id]. | |
// Go Back and choose "create a new one". | |
// Open the Javascript console, paste this (change to your shop/locale_id first): |
OlderNewer