Skip to content

Instantly share code, notes, and snippets.

@yuchant
yuchant / viewport.coffee
Created January 25, 2014 02:33
Viewport Units with Coffee
class root.utils.ViewportHeight
'The VH unit is not well supported. Use data-tags instead.
data-viewport-unit="line-height: 100vh; height: 100vh;'
constructor: ({@element, @styles}={}) ->
@$element = $ @element
@$window = $ window
@_bindHandlers()
_getStyles: ->
@yuchant
yuchant / generational_cache.py
Created February 12, 2014 08:45
Generational Caching
import logging
import pylibmc
from werkzeug.contrib.cache import MemcachedCache
from flask import request
from flask.ext.cache import Cache
log = logging.getLogger(__name__)
@yuchant
yuchant / gist:9108622
Created February 20, 2014 07:32
very simple git revision based cache buster
# very simple git revision based cache buster
app = make_app()
def get_git_revision_hash():
'''
Get current revision short hash and use as cache buster key.
'''
import subprocess
return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD'])
<link href="/static/css/select2.css" type="text/css" media="screen" rel="stylesheet" />
<script type="text/javascript" src="/static/js/select2.js"></script>
<script type="text/javascript">
$(function () {
select2Options = {
'width': 'resolve',
}
$("#content-main select:not(.select2-offscreen)").select2(select2Options);
# custom validation logic
$.validator.addMethod 'validateShipState', (value, element) ->
# if the element contains an arbitrary piece of data called `custom-validator-exception`, don't allow form to validate.
if $(element).data('custom-validator-exception')
return false
return true
, ->
return $("[name=s_state]").data('custom-validator-exception')
var fitPhotoTargetSelector = name + " .fittingbox-fitphoto-target";
window.fitPhoto = FitPhoto.create(fitPhotoTargetSelector, {
width: 327,
glassID: glassID,
localeChain: 'en_US'
});
// handle change sku
$actionContainer.find('.fittingbox-sku').unbind('click').click(function() {
var sku = $(this).data('sku');
def pull_down_remote_db():
""" Export database and files.
"""
local_db_dump_path = os.path.join(PROJECT_ROOT, 'remote_db_dump/auto_db_dump.sql')
with settings(sudo_user='postgres'):
with cd('/var/lib/postgresql'):
run('pwd')
print("Dumping database on remote..")
sudo('pg_dump db_krownlab > auto_db_dump.sql')
@yuchant
yuchant / 0_reuse_code.js
Created August 13, 2014 05:51
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@yuchant
yuchant / shopify-cart-options.liquid
Created March 29, 2016 18:09
Shopify Iterate over options in cart
<div class="cart__options">
{% for i in (0..2) %}
{% assign variant_option_key = i | plus: 1 | prepend: "option" %}
{% assign variant_value = item.variant[variant_option_key] %}
{% if variant_value %}
<div class="cart__option">
{{ item.product.options[i] }}: {{ variant_value }}
</div>
{% endif %}
{% endfor %}
@yuchant
yuchant / Contract Killer 3.md
Last active July 20, 2016 23:02
The latest version of my ‘killer contract’ for web designers and developers
We couldn’t find that file to show.