Skip to content

Instantly share code, notes, and snippets.

"""Provide the EMOJI class."""
from ...const import API_PATH
from .base import RedditBase
class Emoji(RedditBase):
"""An individual Emoji object."""
__hash__ = RedditBase.__hash__
STR_FIELD = 'name'

So I want to return an array in C of length determined at runtime.

This is what I tried at first:

#include <stdio.h>

void printArray(int array[], int length) {
    for (int i = 0; i < length; i++)
        printf("%d", *(array + i));
#include <stdio.h>
#include <stdlib.h>
int * merge(int* array, int length) {
if (length < 2)
return array;
int midpoint = length / 2;
int* front = merge(array, midpoint);
int* back = merge(array + midpoint, length - midpoint);
#include <stdio.h>
void printArray(int array[], int length) {
printf("{");
for (int i = 0; i < length; i++)
printf("%d, ", *(array + i));
printf("\b\b}\n");
}
int main() {return 0;)
@jarhill0
jarhill0 / bandcamp.py
Created May 31, 2018 03:23
Use regex to parse HTML and make a Bandcamp embed.
"""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>
@jarhill0
jarhill0 / poly_contains.py
Created June 28, 2018 20:15
Determine whether a point lies within a polygon. I think the edge and corner cases work properly.
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.
@jarhill0
jarhill0 / print_argv.c
Created February 18, 2019 00:31
C code sample for printing all argument variables
#include <stdio.h>
int main(int argc, char* argv[]) {
for (int i = 0; i < argc; i++)
printf("%s\n", argv[i]);
return 0;
}
#include <stdio.h>
#define DIGITS "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
void my_itoa(int num, char* str, int base) {
if (num < 0) {
num *= -1;
str[0] = '-';
str++;
}
@jarhill0
jarhill0 / prawbject_to_json.py
Created April 30, 2019 03:55
Sample code for converting a PRAW Comment to JSON
import praw
from json import dumps, JSONEncoder
reddit = praw.Reddit(username='',
password='',
client_id='',
client_secret='',
user_agent='')
comment = reddit.comment('em3rygg')
@jarhill0
jarhill0 / kishi_bashi_shows.py
Created June 14, 2019 19:18
Get Kishi Bashi's shows and build a nice markdown table.
"""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',