Skip to content

Instantly share code, notes, and snippets.

View mintchaos's full-sized avatar

Christian Metts mintchaos

View GitHub Profile

Keybase proof

I hereby claim:

  • I am mintchaos on github.
  • I am mintchaos (https://keybase.io/mintchaos) on keybase.
  • I have a public key ASCg6wI5OTSM4VDENWg0HqV3Jd7h6DLTTkx0plNZvsP58Qo

To claim this, I am signing this object:

// Find all of the boxes with totals
$$('.wht_total')
// Take off the $ and turn it into a number (instead of a word made out of digits)
.map(el => Number(el.innerText.slice(1)))
// Remove any that aren't numbers (the "Total" at the top is included)
.filter(n => !isNaN(n))
// Add everything together
.reduce((t, c) => t+c)
@mintchaos
mintchaos / dota.md
Last active December 20, 2015 23:39

Had a tough day at work? Feel like you're unable to contribute? Dota 2 can help by showing you how your personal failures and inadequacies actually make your opposition stronger and cause your friends to suffer. With gorgeous graphics and beautifully detailed heroes, there's never been a more vibrant way experience your own impotence.

@mjmetts on unwinding with video games.

#positivepython

The legendary #django-social channel was once a lovely place of vibrant, cheerful discussion. I miss that.

This experimental channel is a place for off-topic, positive conversation. IRC is a great place to bitch and vent, but #positivepython is not the place for it.

Feel free to invite anyone that you feel should be a part of the group. We want to be selective, not exclusive.

@mintchaos
mintchaos / trailing_commas.py
Created April 24, 2013 20:45
Learning the hard way so you dont' have to.
tweet = Tweet() # new django object
tweet.content = item.content,
tweet.save()
tweet.content == "('%s',)" % item.content # True
# Don't accidentally end your lines with commas kids.
@mintchaos
mintchaos / snippet.py
Created July 27, 2012 18:25
Uniquify list of dicts by a key.
"""
I have data like this.
I want to uniquify it based in the url. I have written code that works.
But it just seems gross. Is there a straightforward way to do this that I'm missing?
"""
embed_list = [
{
@mintchaos
mintchaos / gist:1028150
Created June 15, 2011 21:22
ReCSS bookmarklet
javascript:void(function(){var%20i,a,s;a=document.getElementsByTagName('link');for(i=0;i%3Ca.length;i++){s=a[i];if(s.rel.toLowerCase().indexOf('stylesheet')%3E=0&&s.href)%20{var%20h=s.href.replace(/(&|%5C?)forceReload=\d+/,'');s.href=h+(h.indexOf('?')%3E=0?'&':'?')+'forceReload='+(new%20Date().valueOf())}}})();
// This returns a list of strings of everything my nav links to.
// Like this ['#weddings', '#contact', '#etc']
var sections = $.map($("#main-header a"), function(e){ var h = $(e).attr('href'); if (h.length > 1) { return h } });
// This turns that list into a jquery collection of the linked elements.
sections = $(sections.join())
function activateNav(e) {
// kill all active states
$('#main-header li').removeClass('active');
@register.filter
def exclude_fields(form, field_names):
"""
Returns the fields of a Form excluding the named fields. Usage:
{% for field in form|exclude_fields:"field1,field2,field3" %}
"""
fields = []
if isinstance(form, BaseForm):
field_names = field_names.split(',')
for field in form.fields:
<li class="formrow formrow_{{ field.name }}{% if errors %} has_errors{% endif %}{% if not field.field.required %} optional{% else %} required{% endif %}">
<label for="{{ field.auto_id }}">{{ field.label }}{% if not field.field.required %}<em> (optional)</em>{% endif %}</label>
{{ errors }}
{{ field }}
<small class="help_text">{{ help_text }}</small>{{ hiddenfields }}
</li>