brew update
brew install pyenv
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
different implementations of the simple counter app... code verbosity vs expressiveness |
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
#!/bin/bash | |
# | |
BASE=/tmp | |
PID=$BASE/app.pid | |
LOG=$BASE/app.log | |
ERROR=$BASE/app-error.log | |
PORT=11211 | |
LISTEN_IP='0.0.0.0' | |
MEM_SIZE=4 |
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
import falcon | |
import os | |
from app.db import db_session | |
from app.utils.exceptions import build_error_response | |
from app.startup import (autoload, add_routes) | |
wsgi_app = falcon.API(after=[db_session.remove_session]) | |
autoload("{0}/{1}".format(os.path.dirname(__file__), "handlers")) |
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
import os | |
import pkgutil | |
class route(object): | |
""" Decorates RequestHandlers and builds a list of routes """ | |
_routes = [] | |
def __init__(self, uri): |
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
""" | |
Demonstration of ways to implement this API: | |
sanitize(user_input, stop_words) | |
Related discussions: | |
- Modifying a list while looping over it: | |
- http://stackoverflow.com/questions/1207406/remove-items-from-a-list-while-iterating-in-python | |
- Remove all occurences of a value in a list: | |
- http://stackoverflow.com/questions/1157106/remove-all-occurences-of-a-value-from-a-python-list |
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
// Simple script that exports a users "Saved For Later" list out of Feedly | |
// as a JSON string. | |
// | |
// This was intended for use in the Google Chrome's "Inspector" tool so your | |
// mileage may vary if used in other contexts. | |
// | |
// Format of JSON is as follows: | |
// [ | |
// { | |
// title: "Title", |
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
#List unique values in a DataFrame column | |
pd.unique(df.column_name.ravel()) | |
#Convert Series datatype to numeric, getting rid of any non-numeric values | |
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True) | |
#Grab DataFrame rows where column has certain values | |
valuelist = ['value1', 'value2', 'value3'] | |
df = df[df.column.isin(value_list)] |