Skip to content

Instantly share code, notes, and snippets.

import multiprocessing
import time
def execute(code):
if code == 'S':
time.sleep(15)
print('Finished executing "{}".'.format(code))
@jarhill0
jarhill0 / bf.py
Created November 6, 2017 07:42
IT WORKS
import multiprocessing
import time
class Cell:
def __init__(self):
self.left = None
self.right = None
self.value = 0
@jarhill0
jarhill0 / telepot_error.py
Created November 12, 2017 21:46
Telepot not playing nice with multiprocessing
import multiprocessing
import random
import time
import telepot
from telepot.loop import MessageLoop
import config
bot = telepot.Bot(config.token)
@jarhill0
jarhill0 / Cheater.java
Created November 24, 2017 05:30
Cheat for the Telegram game Lumberjack. You'll have to adapt the pixel coordinates if you want it to work.
import java.awt.*;
import java.awt.event.InputEvent;
public class Cheater {
private static final int SKY_MIN_BLUE = 250;
private static final int default_x1 = 790;
private static final int default_x2 = 950;
private static final int default_y = 292;
@jarhill0
jarhill0 / z_table.py
Created November 28, 2017 05:19
my z-table in python
from math import sqrt, erf, erfc
from scipy.special import erfinv, erfcinv
class Table:
def __init__(self, precision=4):
self.precision = precision
def below(self, z_score):
import praw
import time
from datetime import datetime, timedelta
def hours_posted(submission):
"""Gets the time that passed (in hours) from when the post was made. (All time is converted to UTC)"""
time_created = submission.created_utc
current_time = datetime.utcnow()
time_posted = datetime.utcfromtimestamp(time_created)
time_difference_in_hours = (current_time - time_posted)/timedelta(hours=1)
$ python3 setup.py test
running test
running egg_info
writing pycaching.egg-info/PKG-INFO
writing dependency_links to pycaching.egg-info/dependency_links.txt
writing requirements to pycaching.egg-info/requires.txt
writing top-level names to pycaching.egg-info/top_level.txt
reading manifest file 'pycaching.egg-info/SOURCES.txt'
writing manifest file 'pycaching.egg-info/SOURCES.txt'
running build_ext
$ python3 setup.py test
running test
running egg_info
creating pycaching.egg-info
writing pycaching.egg-info/PKG-INFO
writing dependency_links to pycaching.egg-info/dependency_links.txt
writing requirements to pycaching.egg-info/requires.txt
writing top-level names to pycaching.egg-info/top_level.txt
writing manifest file 'pycaching.egg-info/SOURCES.txt'
reading manifest file 'pycaching.egg-info/SOURCES.txt'
@jarhill0
jarhill0 / Telegram Bot API.html
Created February 1, 2018 06:32
parsing the Telegram API docs to get some info for preliminary code genereation.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Telegram Bot API</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta property="description" content="The Bot API is an HTTP-based interface created for developers keen on building bots for Telegram.
To learn how to create…">
<meta property="og:title" content="Telegram Bot API">
<meta property="og:image" content="">
@jarhill0
jarhill0 / gen_queryresult_code.py
Created February 1, 2018 07:06
Generating code (part 2)
import json
import os
with open('inline_query_results.json', 'r') as f:
types = json.load(f)
FORM = """
from .inline_query_result import InlineQueryResult