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
"""Backport of importlib.import_module from 3.x.""" | |
# While not critical (and in no way guaranteed!), it would be nice to keep this | |
# code compatible with Python 2.3. | |
import sys | |
def _resolve_name(name, package, level): | |
"""Return the absolute name of the module to be imported.""" | |
if not hasattr(package, 'rindex'): | |
raise ValueError("'package' not set to a string") | |
dot = len(package) |
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
with open("log.txt", "r") as f: | |
for line in f: | |
if re.match(r"^\d{2}-\w{3}", line): | |
date = line[:6] | |
continue | |
if date == "02-Jan": | |
if re.search("Error", line): | |
# something's wrong, better to call my creator! |
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 urllib2 | |
import html5lib | |
import cssselect | |
url = "http://ahr13.mapyourshow.com/5_0/exhibitor_results.cfm?alpha=%40&type=alpha&page=1" | |
html = urllib2.urlopen(url).read() | |
root = html5lib.parse(html, treebuilder="lxml", namespaceHTMLElements=False) | |
xpath = cssselect.HTMLTranslator().css_to_xpath(".mys-elastic.mys-left a") | |
for element in root.xpath(xpath): | |
print element.get("href") |
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 F(object): | |
pass | |
place_data_items = {} | |
place_data_items["state"] = [F(), F(), F()] | |
for pt, items in place_data_items.iteritems(): | |
if pt == 'state': | |
for i in items: | |
print "update loop: %s" % i |
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 F(object): | |
def __init__(self): | |
self._x = None | |
@property | |
def x(self): | |
return self._x | |
@x.setter |
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
#include <algorithm> | |
#include <chrono> | |
#include <cstdio> | |
#include <cstdlib> | |
#include <cstring> | |
#include <iostream> | |
#include <pthread.h> | |
#include <random> | |
const int DATA_LENGTH = 1000000000; |
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
# -*- coding: utf-8 -*- | |
BOOTSTRAP = r""" | |
html,body{margin:0;padding:0;} | |
h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,cite,code,del,dfn,em,img,q,s,samp,small,strike,strong,sub,sup,tt,var,dd,dl,dt,li,ol,ul,fieldset,form,label,legend,button,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;font-weight:normal;font-style:normal;font-size:100%;line-height:1;font-family:inherit;} | |
table{border-collapse:collapse;border-spacing:0;} | |
ol,ul{list-style:none;} | |
q:before,q:after,blockquote:before,blockquote:after{content:"";} | |
html{overflow-y:scroll;font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;} | |
a:focus{outline:thin dotted;} | |
a:hover,a:active{outline:0;} |
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
var v = []; | |
var text = '<table>'; | |
var months = [ | |
{name: 'Jan', index: '01'}, | |
{name: 'Feb', index: '02'}, | |
{name: 'Mar', index: '03'}, | |
{name: 'Apr', index: '04'}, | |
{name: 'May', index: '05'}, | |
{name: 'Jun', index: '06'}, | |
{name: 'Jul', index: '07'}, |
NewerOlder