Skip to content

Instantly share code, notes, and snippets.

View xjcl's full-sized avatar
👋
Say hi to me!

Jan-Frederik Konopka xjcl

👋
Say hi to me!
  • Düsseldorf, Germany
View GitHub Profile
@xjcl
xjcl / local_reddit.py
Created May 1, 2014 12:45
A python script that screencaps reddit comment threads. BECAUSE WHY READ A BOOK WHEN YOU'RE OFFLINE??
"""
USAGE:
You need xvfb, python(2), praw and CutyCapt (see below). Simply run this as
a normal python script: `python local_reddit.py`
CUSTOMIZATION:
* change number of screencaps in main() (10 by deafault)
* change queried subreddits in main()
(query multiple reddits: "askreddit+writingprompts")
* get_top() submissions from day/week instead of hot ones (get_hot())
TIME:
@xjcl
xjcl / generate_cleansed.py
Last active August 29, 2015 14:05
Takes a short text quote and turns it into an inspirational image (text2quote). This gist includes a reddit bot (quotebot). License is GPL v3. Example: http://i.imgur.com/wEg3JsK.png
# WHAT?
# this is a modified version of tst's generate bot for
# text2quote (i.e. text on a fancy background) generation.
# it is stripped in that the imgur/reddit references are
# removed and it is called in the same way as my own text2quote
# module (so it is interchangable).
# UNTESTED AND HACKY, USE AT YOUR OWN RISK.
import os
import textwrap
@xjcl
xjcl / shitty_pong.py
Last active June 8, 2021 12:50
A simple pong game written in python and pyglet.
"""
Play a simple game of pong in a window.
Player 0 controls: (W, S) Player 1 controls: (O, L). Quit: (Q)
The ball bounces differently if you move while hitting it.
This also includes a slight factor of randomness.
Requires: pyglet, 10x10 image in directory: "white_square.png"
"""
unit ujff2;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
ExtCtrls, Menus, Buttons, StdCtrls, IniFiles;
@xjcl
xjcl / versus.py
Last active December 30, 2015 17:16
Program to find occurrences of one audio clip inside another audio clip.
# 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 *
# 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],
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]
@xjcl
xjcl / pizza.py
Last active March 1, 2018 13:05
Solution to the Google Hash Code Pizza practice problem, trying all shapes greedily along the antidiagonals. Score: 944730 = 12+38+48846+895834
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)
@xjcl
xjcl / flairstats.py
Last active July 16, 2018 22:10 — forked from rasher/flairstats.py
Subreddit flair stats
#!/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>',
@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!')