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
/* | |
* MediathekView | |
* Copyright (C) 2008 W. Xaver | |
* W.Xaver[at]googlemail.com | |
* http://zdfmediathk.sourceforge.net/ | |
* | |
* This program is free software: you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation, either version 3 of the License, or | |
* any later version. |
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
# An example to get the remaining rate limit using the Github GraphQL API. | |
import requests | |
headers = {"Authorization": "Bearer YOUR API KEY"} | |
def run_query(query): # A simple function to use requests.post to make the API call. Note the json= section. | |
request = requests.post('https://api.github.com/graphql', json={'query': query}, headers=headers) | |
if request.status_code == 200: |
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 Solution: | |
def findMaxConsecutiveOnes(self, nums: List[int]) -> int: | |
def NextStripLen(nums, i): | |
if not i< len(nums): | |
return 0 | |
j=i+1 | |
c=1 | |
while j<len(nums) and nums[j]==nums[i]: | |
c+=1 | |
j+=1 |
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 findMaxLength(self, nums: List[int]) -> int: | |
#visualize nums as a grpah. if found 0 goes up, if 1 goes down | |
g=0 #initial position in the graph is zero, g points toward position | |
longest = 0 #keeps track of longest distance between same points in graph | |
hm={0:-1} #position 0 at graph is first found at index -1/ before start | |
for i,n in enumerate(nums): | |
if n==0: | |
g+=1 | |
else: |
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 tower: | |
def __init__(self, position, n): | |
#initial position as 0,1, or 2 | |
self.position=position | |
# sanity check | |
if position > 2: | |
raise ValueError('tower position not valid. must be between 0 and 2') | |
if n < 1: | |
raise ValueError('disk number not valid. must be between 0 and 2') | |
#initialize an empty stack to hold the disks |
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 os | |
import openpyxl | |
''' let's assume there is an excel sheet | |
where two column holds ratings from two raters, | |
this script measures the agreement rate between them''' | |
#In this sample, the ratings are for sentiment | |
#possible ratings are: positive, negative, neutral |