Skip to content

Instantly share code, notes, and snippets.

View theY4Kman's full-sized avatar

Zach Kanzler theY4Kman

View GitHub Profile
@theY4Kman
theY4Kman / gist:1559870
Created January 4, 2012 12:39
Re: reddit comment on thread -- efficient packaging

In response to: http://www.reddit.com/r/pics/comments/o2csg/efficient_packaging/c3dt857?context=3
Thread link: http://www.reddit.com/r/pics/comments/o2csg/efficient_packaging/
Thread content link: http://imgur.com/IMDtH

Well, that's just terribly inefficient. We don't become better humans by accepting something that's inefficient. If I'm making quality comments, but I'm still being prevented from posting, something needs to be done. In this case, it needs to be lifted. If not for everyone, at least for this account.

@theY4Kman
theY4Kman / gist:1559995
Created January 4, 2012 13:17
Re: reddit comment on thread -- Looking for a kraken and found this...wtf!
@theY4Kman
theY4Kman / gist:1560026
Created January 4, 2012 13:26
Re: reddit comment on thread -- Does the thought of millions of Republicans googling Santorum make anyone else happy?

In response to: http://www.reddit.com/r/politics/comments/o21ld/does_the_thought_of_millions_of_republicans/c3dtfa0?context=3
Thread link: http://www.reddit.com/r/politics/comments/o21ld/does_the_thought_of_millions_of_republicans/

This is very true, but if you live in a world of complete honesty, where we talk about all our problems, instead of worrying about them, the people who choose to live there will solve more problems. Then it won't matter who chooses not to learn. We'll revert back to the natural way of creating order out of chaos by spreading good ideas, and not bad ones.

People who recognize good ideas will build on them, and tell other people. It will snowball until so many people have these good ideas who are living extremely successful lives that the people who chose to believe their misinformation will have to adapt to survive in the new world.

If you choose to continue living in our current world with all its problems, and we don't act as we'd like other people to act, no one else will le

@theY4Kman
theY4Kman / gist:1560224
Created January 4, 2012 14:15
A website to promote effective collective learning

Let's build a better website to help us all learn. Essentially, lower the barrier as low as we can for entry, and for change. Editing your idea should be encouraged. Everyone should be able to fork an idea and run with it. There will be no comments, just forks. There will be a front page with all the ideas people post, in a stack, which is never destroyed or cleaned up. When an idea is posted, it goes to the top of the list. When an idea is forked, it goes to the top of the list. That is how we'll come up with better solutions faster. And we'll learn how to learn faster. There will be no usernames, but also no restrictions as to what you may say in your message. You can always mention your name, if you want.

Requirements:

  • No requirements to entry other than being able to enter characters into the computer.
  • No requirement for a unique identifier (user name, email address, etc).
  • No restrictions on what may be discussed.
  • Everything posted to the site must be saved.
  • No idea is thrown away, ever.
@theY4Kman
theY4Kman / gist:3033623
Created July 2, 2012 14:50
`passedargs` decorator allows the differentiation between a kwarg being passed a default value and no value being provided for a kwarg.
def passedargs(func):
"""
This (unused) decorator adds a `passed` attribute to `func`, a dict whose
keys are the parameter names of `func` and whose values are True if that
particular argument was passed, and False if not. This is useful if you
don't want to use a sentinel value to detect the lack of argument passing.
This is bad, though, because it's harder to get rid of an argument than it
is to change one.
For whatever reason, I got it in my head I wanted to create an Object.get
@theY4Kman
theY4Kman / gist:3033664
Created July 2, 2012 15:00
Python default matching decorator and default value retrieval function
class matchdefaults(object):
"""
This decorator swaps out the decorated function's default values to the
`match` function. This does not sanity check the number of parameters or
their names.
"""
def __init__(self, match):
self.match = match
@theY4Kman
theY4Kman / templatefilters.py
Created August 22, 2012 05:55
Formats a datetime object, allowing for a dash modifier to be used, stripping leading zeros from a value
def dateformat(dt, format='%-I:%m %p, %A, %B %-d, %Y'):
# Remove leading zeros if the identifier has a dash in front of it
# Implemented in Python, as in strftime it's platform-dependent
if format.find('%-') != -1:
compiled = ''
i = 0
length = len(format)
fmt = None
fmt_remove_leading = False
@theY4Kman
theY4Kman / jquery.inputhints.js
Created August 22, 2012 12:39
Simple <input> hints jQuery plug-in. Adds class 'hint' when the hint is active. It's smart. TODO: display password fields as text when hint is active.
jQuery.fn.inputHints = function() {
function hintIfBlank(elem)
{
if (elem.val() == '')
elem.val(elem.attr('title')).addClass('hint').data('hint', true);
}
$(this)
.data('hint', false)
.focus(function() {
@theY4Kman
theY4Kman / manage.py
Created September 1, 2012 19:01
pushd context manager
@contextmanager
def pushd(new_dir):
"""
A context manager that implements the `pushd` command, letting you run a
block of commands while in a different directory
"""
old_dir = os.getcwd()
os.chdir(new_dir)
try:
yield old_dir
@theY4Kman
theY4Kman / hmac_sha256.py
Created October 15, 2012 16:02
Python SHA-256 HMAC
from Crypto import HMAC, SHA256
def hmac_sha256(key, msg):
hash_obj = HMAC.new(key=key, msg=msg, digestmod=SHA256)
return hash_obj.hexdigest()