Skip to content

Instantly share code, notes, and snippets.

View nikolak's full-sized avatar

Nikola Kovacevic nikolak

View GitHub Profile
@nikolak
nikolak / threading_design.ui
Created August 5, 2015 20:44
Qt Designer files for http://nikolak.com/ tutorial [insert tutorial link here]
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>526</width>
<height>373</height>
def check_for_airpods(timeout=60):
import time;import os;import requests;import arrow
while True:
status = requests.get("https://www.apple.com/de/shop/retail/pickup-message?parts.0=MMEF2ZM%2FA&location=81925").json()['body']['stores'][0]['partsAvailability']['MMEF2ZM/A']['storePickupQuote']
available = 'Aug im' not in status
if available:
os.system(""" osascript -e 'display notification "{}" with title "Apple Store AirPods"'""".format(status))
else:
print(f"Last checked at {arrow.now().format('YYYY-MM-DD HH:mm')}, status= {status}", end="\r")
time.sleep(timeout)
@nikolak
nikolak / trakt_to_sickrage.py
Last active October 1, 2016 22:46
Get all shows from your trakt.tv library and add them to sickrage database
import requests
import sqlite3
import os
# API key available at: http://trakt.tv/api-docs/authentication
API_KEY = "25665d450ed0c00907f32be617cd2a37"
TRAKT_USER = "nikolak" # trakt username
TRAKT_URL = "http://api.trakt.tv/user/library/shows/all.json/{key}/{user}".format(
key=API_KEY,
user=TRAKT_USER)
def letter_count(s):
counter, max_index = 1, len(s) - 1
out = []
for index, letter in enumerate(s):
if index < max_index:
if letter == s[index + 1]:
counter += 1
continue
from plugin import CommandPlugin
class test(CommandPlugin):
self.add_commands({"test":self.test()})
def test(self, user, channel, parameters):
print "executing test command"
self.bot.msg(channel, "Test")
@nikolak
nikolak / gist:8403499
Last active January 3, 2016 03:39
Gets all items possible from entered reddit pages following the &after= param
#!/usr/bin/env python
import sys
import json
import time
import urllib
import httplib2
from urllib import urlencode
from urlparse import urlparse, urlunparse, parse_qs
import sys
import sqlite3
import datetime
#TO-DO:
#Fix a few user options...I think like 1-3 or something.
#
conn = sqlite3.connect('moviedb.db')
c = conn.cursor()
class Movie(object):
from time import time, sleep
import requests
import logging
import json
# submission dict layout initial idea
# {"id": {
# time:{ #unix timestamp, str
removed_counter=0
for x in range(0,len(to_update),100):
items=to_update[x:x+100]
items_url=api_by_id.format(",".join(items))
request_time=time()
print "[FILTERING] Starting request...",request_time
# print "Request url", items_url
try:
r=requests.get(items_url, headers=headers, timeout=20)
except:
import sqlite3
import time
import json
import urllib2
def get_submissions():
url="http://www.reddit.com/r/all/new/.json" #URL of the page that we want to fetch
headers = { 'User-Agent' : 'fetching new submissions script' } # our script "identifier"
req = urllib2.Request(url, None, headers) # We create new request here to open the url with above set headers
data = urllib2.urlopen(req).read() # Open url and make data variable equal whatever we get