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 binascii | |
HEXSTRING = ( | |
'546869732069732066696e652e2049276d206f6b61792077697468207468' | |
'65206576656e747320746861742061726520756e666f6c64696e67206375' | |
'7272656e746c792e20546861742773206f6b61792c207468696e67732061' | |
'726520676f696e6720746f206265206f6b61792e0a' | |
) | |
print(binascii.unhexlify(HEXSTRING)) |
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 requests | |
URL = 'https://www.google.com' | |
HEADERS = { | |
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:61.0) Gecko/20100101 Firefox/70.0' | |
} | |
response = requests.get(URL, headers=HEADERS) |
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 selenium import webdriver | |
def main(): | |
# Setup options to run Firefox in headless mode. | |
firefox_options = webdriver.FirefoxOptions() | |
firefox_options.headless = True | |
# Open a Firefox browser and check the Python official site. | |
driver = webdriver.Firefox(options=firefox_options) |
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 requests | |
class HTTPRequestError(Exception): | |
pass | |
def fetch(url, params=None, **kwargs): | |
try: | |
response = requests.get(url, params, **kwargs) |
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 logging | |
import discord | |
logger = logging.getLogger('DiscordBot') | |
class Bot(discord.Client): |
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
SRC="/store/group/lpchbb/VHbbAnalysisNtuples/RESUBMIT_June9_2016V4" | |
DST="/store/group/lpchbb/VHbbAnalysisNtuples/CMSConnect_June9_2016V4/ggZH125_ZLL_powheg" | |
FILES=( | |
output_ggZH125_ZLL_powheg_177part0.root | |
output_ggZH125_ZLL_powheg_177part1.root | |
output_ggZH125_ZLL_powheg_177part10.root | |
output_ggZH125_ZLL_powheg_177part11.root | |
output_ggZH125_ZLL_powheg_177part12.root |
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 sys | |
# The only command line argument should be the path to a file | |
# where each line is a set of arguments for resubmission. | |
with open(sys.argv[1]) as f: | |
lines = f.read().splitlines() | |
for line in lines: | |
start, stop = line.split()[-3:-1] | |
start = float(start) |
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 glob | |
import os | |
SEARCH_PATTERN = '/path/to/your/output/dir/{0}/*.root' | |
SAMPLES = [ | |
'DYToLL_madgraph', | |
'ZH125_ZNuNu_powheg', | |
] |
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 glob | |
import ROOT | |
import concurrent.futures | |
def check_file(path): | |
f = ROOT.TFile.Open(path) | |
# The file is somehow unreadable. | |
if not f: |
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
#!/usr/bin/env python | |
import glob | |
import sys | |
import varial.tools | |
from varial_ext.treeprojector import TreeProjectorFileBased | |
# The following all caps variables are module level constants that I would tweak by hand. | |
# Most of them are parameters are passed to the treeprojection_mr_impl.map_projection | |
# function, so check its docstring for more information. |
NewerOlder