This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import monotonic | |
import praw | |
reddit = praw.Reddit(...) # authenticate | |
print(f'Authenticated as {reddit.user.me()}') | |
start_time = monotonic() | |
used_at_start = reddit._core._rate_limiter.used |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bottles | |
def song | |
verses 99, 0 | |
end | |
def verses(start, stop) | |
start.downto(stop).map {|v| self.verse v}.join("\n") | |
end | |
def verse(num) | |
"#{self.bottle_text(num).capitalize} of beer on the wall, #{self.bottle_text num} of beer. | |
#{self.next_action num} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import praw | |
SUB_NAME = "###" | |
# ^ This name should be a subreddit that only allows link posts and not | |
# self posts. Preferably you should mod it (but not with the account | |
# that you run this script as), because it is going to get spammed. | |
reddit = praw.Reddit() # fill in | |
subreddit = reddit.subreddit(SUB_NAME) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from betamax import Betamax | |
from requests import Session | |
def before(cassette): print('cassette created.') | |
def after(cassette): print('cassette destroyed') | |
session = Session() | |
recorder = Betamax(session, cassette_library_dir='test cassettes') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Get Kishi Bashi's shows and build a nice markdown table.""" | |
from datetime import datetime | |
from urllib.parse import urlparse | |
import requests | |
def main(): | |
shows = requests.get('https://rest.bandsintown.com/artists/Kishi Bashi/events', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import praw | |
from json import dumps, JSONEncoder | |
reddit = praw.Reddit(username='', | |
password='', | |
client_id='', | |
client_secret='', | |
user_agent='') | |
comment = reddit.comment('em3rygg') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define DIGITS "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
void my_itoa(int num, char* str, int base) { | |
if (num < 0) { | |
num *= -1; | |
str[0] = '-'; | |
str++; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(int argc, char* argv[]) { | |
for (int i = 0; i < argc; i++) | |
printf("%s\n", argv[i]); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import random | |
def contains_point(polygon, point): | |
"""Determine whether point is contained within polygon. | |
:param polygon: An ordered sequence of length-2 tuples that represent the (x, y) coordinates of points that, | |
when connected, form a polygon that does not intersect itself. The last point will connect with the first | |
one. | |
:param point: A length-2 tuple that represents the (x, y) coordinates of a point. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Use regex to parse HTML and make a Bandcamp embed.""" | |
import re | |
import requests | |
TEMPLATE = """ | |
<iframe style="border: 0; width: 276px; height: 390px;" | |
src="https://bandcamp.com/EmbeddedPlayer/track={track_number}/size=large/bgcol=ffffff/linkcol=17a2b8/tracklist=false/" | |
seamless> |
NewerOlder