.. automodule:: app_name.views :members:
This file contains hidden or 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
class ICalFeed(Feed): | |
# comments | |
feed_type = feedgenerator.DefaultFeed | |
def __call__(self, request, *args, **kwargs): | |
""" | |
Copied from django.contrib.syndication.views.Feed | |
Supports file_name as a dynamic attr. | |
""" |
This file contains hidden or 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
# views.py | |
class EventFeed(ICalFeed): | |
""" | |
A simple event calender | |
""" | |
product_id = '-//example.com//Example//EN' | |
timezone = 'UTC' | |
file_name = "event.ics" |
This file contains hidden or 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 django | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings") | |
django.setup() |
This file contains hidden or 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
def find_match_for_dataframes(df1, df2, cols_to_compare=[], name_of_new_row="found_in_row"): | |
copy_df2 = df2 | |
df1[name_of_new_row] = "" | |
for idx, item in df1.iterrows(): | |
for idx_comp, comp_item in copy_df2.iterrows(): | |
# check if all conditions are successful | |
# returns True if the list is empty |
This file contains hidden or 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
componentWillReceiveProps(newProps){ | |
this.setState({ | |
editorState: createEditorState(newProps.current_content), | |
}) | |
} |
This file contains hidden or 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
from wsgiref.simple_server import make_server | |
from cgi import parse_qs, escape | |
def show_get_params(environ, start_response): | |
subject = parse_qs(environ.get('QUERY_STRING', '')) | |
start_response('200 OK', [('Content-Type', 'text/html')]) | |
return ['''%(subject)s''' % {'subject': subject}] | |
srv = make_server('localhost', 3000, show_get_params) | |
srv.serve_forever() |
This file contains hidden or 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
python -m IPython notebook |
This file contains hidden or 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
AttributeError: 'Unicode' object has no attribute 'tag' |
This file contains hidden or 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
from multiprocessing import Pool, cpu_count | |
def run_parallel_selenium_processes(datalist, selenium_func): | |
pool = Pool() | |
# max number of parallel process | |
ITERATION_COUNT = cpu_count()-1 | |
count_per_iteration = len(datalist) / float(ITERATION_COUNT) |