This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| public class ThingsAdapter extends RecyclerView.Adapter<ThingsAdapter.ViewHolder> { | |
| private ParseQueryAdapter<ParseObject> parseAdapter; | |
| private ViewGroup parseParent; | |
| private ThingsAdapter thingsAdapter = this; | |
| public ThingsAdapter(Context context, ViewGroup parentIn) { | |
| parseParent = parentIn; |
| import putio | |
| import logging | |
| from flexget import validator | |
| from flexget.plugin import register_plugin | |
| log = logging.getLogger('putio') | |
| class PutIOPlugin(object): | |
| """ | |
| Plugin to add and fetch your torrents on put.io |
| require 'digest/md5' | |
| module Sass::Script::Functions | |
| # Returns a url for static media (e.g. an icon) consistent with those | |
| # generated by the static_url method in Tornado templates. The method | |
| # takes an md5 hash of the given file and attaches the first five chars to | |
| # the 'v' GET param in the url (i.e. it appends "?v=<hash_slice>"). | |
| # Assumes you use a somewhat conventional Tornado layout: | |
| # myapp/myapp - your code |
| curl -s -D - -o /dev/null http://www.google.com |
| #!/bin/bash | |
| # Runs any command (the args) in the virtualenv environment where this script resides. | |
| # You need to change the ACTIVATE_PATH variable | |
| # depending on where your virtualenv activate file is relative to this script. | |
| # The WORKING_DIR var controls the directory from which the command will be run. | |
| # I put this in a bin folder at the top level of my app. | |
| # my virtualenv structure: | |
| # /my_env | |
| # /my_env/bin ( with the venv activate script ) | |
| # /my_env/my_app |
| #!/bin/bash | |
| # | |
| #Converts the input url to utf-8 from ISO-8859 (xmonad's prompt format), then | |
| #opens the url with chromium, which seems to require utf-8 urls. | |
| query=`echo ${1} | iconv -f ISO-8859-1 -t UTF-8` | |
| echo "${0} ${query}" >> /tmp/search_log.txt | |
| chromium ${query} |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| class User < ActiveRecord::Base | |
| #available roles for users | |
| ROLES = ['uber', 'admin', 'mod'] | |
| #generates methods like user.admin? for testing whether the user belongs to | |
| #the proper role | |
| ROLES.each do |role_name| | |
| self.send(:define_method, "#{role_name}?".to_sym) { self.role == role_name } | |
| end |
| import sqlalchemy as sa | |
| class EnumIntType(sa.types.TypeDecorator): | |
| impl = sa.types.SmallInteger | |
| values = None | |
| def __init__(self, values=None): | |
| sa.types.TypeDecorator.__init__(self) | |
| self.values = values |