Skip to content

Instantly share code, notes, and snippets.

View nasifimtiazohi's full-sized avatar
🇧🇩

Nasif Imtiaz nasifimtiazohi

🇧🇩
View GitHub Profile
/*
* 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.
@nasifimtiazohi
nasifimtiazohi / graphql_example.py
Created May 14, 2020 19:11 — forked from gbaman/graphql_example.py
An example on using the Github GraphQL API with Python 3
# 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:
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
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:
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
@nasifimtiazohi
nasifimtiazohi / weighted_Kappa.py
Created April 18, 2019 18:25
Measure (weighted) Kohen's Kappa agreement rate between two raters' ratings
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