Last active
December 12, 2016 20:19
-
-
Save ethanholda/119f50ee636088b71546 to your computer and use it in GitHub Desktop.
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 base64 | |
import hashlib | |
import os | |
import re | |
import readline | |
import requests | |
import simplejson as json | |
import sys | |
from bs4 import BeautifulSoup as bs | |
from copy import deepcopy | |
from datetime import datetime | |
from operator import itemgetter | |
from pprint import pprint | |
#don't really need this anymore | |
json_headers = {'content-type':'application/json'} | |
headers=json_headers | |
if (sys.version_info[0] == 3): from urllib.parse import urlencode | |
else: from urllib import urlencode | |
# separate | |
def gethist(n=None,search=None): | |
""" | |
Print last n lines of python commandline history. If n==None, print | |
entire history. | |
""" | |
l = readline.get_current_history_length() | |
n0 = (l - n) if n else 0 | |
for i in range(n0, l): | |
line = readline.get_history_item(i) | |
if (search and line): | |
if (search in line): | |
print(line) | |
else: | |
print(line) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment