Skip to content

Instantly share code, notes, and snippets.

Avatar
👋
Say hi to me!

Jan-Frederik Konopka xjcl

👋
Say hi to me!
  • IKB Deutsche Industriebank AG
  • Düsseldorf, Germany
View GitHub Profile
@xjcl
xjcl / codejam_2020_r1b_b.py
Last active Apr 26, 2021
Google Code Jam -- Blindfolded Bullseye -- Solution in Python
View codejam_2020_r1b_b.py
# usage: (python3 a.py < a.in) > a.out
import time, sys, inspect, platform
print = lambda *a, **k: __builtins__.print(str(inspect.currentframe().f_back.f_lineno)+':',
*a, file=sys.stderr, **k) if platform.node() in ['surfux', 'ssd'] else ...
class EndTestCase(Exception): pass
#---------------------------------------------
@xjcl
xjcl / codejam_2018_r1b_a.py
Created Apr 26, 2021
Google Code Jam -- Rounding Error -- Solution in Python
View codejam_2018_r1b_a.py
# usage: (python3 a.py < a.in) > a.out
import time, sys, inspect, platform
print = lambda *a, **k: __builtins__.print(str(inspect.currentframe().f_back.f_lineno)+':',
*a, file=sys.stderr, **k) if platform.node() in ['surfux', 'ssd'] else ...
#---------------------------------------------
'''
i know this is 'sort-by-goodness'
View asyncio_test_http.py
import requests
import asyncio
import aiohttp
import aiofiles
get_img_url = lambda i: 'https://cdn.discordapp.com/embed/avatars/' + str(i) + '.png'
def download_all_sync():
View async_example_tasks.py
import asyncio
import time
async def say_after(delay, what):
await asyncio.sleep(delay)
print(what)
async def use_await():
await say_after(3, 'world')
await say_after(2, 'hello')
View async_example_discord_bot.py
@client.event
async def on_ready():
while True:
await asyncio.sleep(24*60*60)
print('Another day has passed!')
@client.event
async def on_message(message):
if message.author == client.user: return # Do not reply to self
await message.channel.send('I can still respond to your messages!')
@xjcl
xjcl / flairstats.py
Last active Jul 16, 2018 — forked from rasher/flairstats.py
Subreddit flair stats
View flairstats.py
#!/usr/bin/env python
# modified from https://gist.github.com/rasher/4208507 (python 2)
import sys
from datetime import datetime
from praw import Reddit
from collections import defaultdict
r = Reddit(user_agent='flairstats/0.1 by <YOUR USERNAME>',
client_id='<GET THESE AS DESCRIBED HERE:', client_secret='https://praw.readthedocs.io/en/latest/getting_started/quick_start.html>',
@xjcl
xjcl / pizza.py
Last active Mar 1, 2018
Solution to the Google Hash Code Pizza practice problem, trying all shapes greedily along the antidiagonals. Score: 944730 = 12+38+48846+895834
View pizza.py
import sys
import numpy as np
num_rows, num_cols, min_ingr, max_size = [int(x) for x in input().split(' ')]
pizza = np.array([[int(x == 'T') for x in input()] for i in range(num_rows)])
output = []
dead = np.zeros_like(pizza).astype(int)
View sethmeyers_chart.py
import numpy as np
import matplotlib.pyplot as plt
data = [
['not Trump', 128-91],
['Trump', 91],
]
data_x = [d[0] for d in data][::-1]
data_y = [d[1] for d in data]
View gcj_country_performance_chart.py
# import matplotlib.pyplot as plt; plt.rcdefaults()
import numpy as np
import matplotlib.pyplot as plt
data = [
['India', 16],
['United States', 56],
['Bangladesh', 57],
['France', 71],
@xjcl
xjcl / versus.py
Last active Dec 30, 2015
Program to find occurrences of one audio clip inside another audio clip.
View versus.py
# Program to find occurrences of one audio clip inside another audio clip.
# you need to youtube-dl the video with id mPdcedZ9GxE for the example
# WARNING! example requires 3GB of free RAM
from moviepy.editor import *
from numpy import *
from scipy.signal import *