Skip to content

Instantly share code, notes, and snippets.

View anna-is-cute's full-sized avatar

Anna anna-is-cute

View GitHub Profile
// Kotlin + HttpURLConnection
val connection = URL("https://api.github.com/user").openConnection() as HttpURLConnection
val auth = Base64.getEncoder().encode("user:pass".toByteArray()).toString(Charsets.UTF_8)
connection.addRequestProperty("Authorization", "Basic $auth")
connection.connect()
println(connection.responseCode)
println(connection.getHeaderField("Content-Type"))
val text = connection.inputStream.use { it.reader().use { reader -> reader.readText() } }
println(text)

requests

from requests import get
print(get("https://httpbin.org/get").json()["origin"])
# 46.21.154.83

khttp

import me.kyleclemens.khttp.get
# -*- coding: utf-8 -*-
from irc3 import plugin, IrcBot
from bottle import route, run, request, response
from threading import Thread
bot = None
@route("/<INSERT UNIQUE SHIT HERE>", method="POST")
def index():
if bot is None:
@Nullable
public final BaseCommand getCommand(@NotNull final String name) {
Intrinsics.checkParameterIsNotNull(name, "name");
BaseCommand commandByAlias;
if ((commandByAlias = this.commands.get(name)) == null) {
commandByAlias = this.getCommandByAlias(name);
}
return commandByAlias;
}
from soundcloud import Client
from requests import get
from os.path import join as path_join
from mutagen.mp3 import MP3
from mutagen import File
from mutagen.id3 import ID3, ID3NoHeaderError, TIT2, TPE1, TPE2, TALB, TRCK, APIC
class Downloader:
def __init__(self, client_id):
self.client = Client(client_id=client_id)

List of stories that might be interesting for Snake to read. Separated into two categories: SPOOK and NOT SPOOK. Also then separated into subcategories at random.

The idea is that these are short. Hoping that I can find a good majority of ones out of copyright (public domain).

NOT SPOOK

Classics

This is a story that I (jkcclemens) remember from my childhood. I don't know if it's well known.

There was a girl who lived alone with her parents and dog. They were a well-to-do family, and, as a result, they lived in a nice house with a high-end security system. The girl never felt afraid.

One day, the girl's parents told her that they were going out of town and that she would be alone for a day. They figured she was old enough to handle it herself. So, time came for her parents to leave, and they said their goodbyes.

The girl had a normal day. As night came around, she flipped on the TV and watched some shows. She fell asleep on the couch. As it got later, the news came on. She woke up to a story about how a serial killer had escaped and was at large. The newscasters were telling the audience to check that their doors and windows were locked.

The girl went around her house and made sure everything was safe. She checked all the locks and the security system. Everything seemed fine. She lived in a nice n

We can make this file beautiful and searchable if this error is corrected: Any value after quoted field isn't allowed in line 2.
title ,author
The Hitchhiker's Guide to the Galaxy ,"Adams, Douglas"
Foundation ,"Asimov, Isaac"
Foundation and Empire ,"Asimov, Isaac"
Forward the Foundation ,"Asimov, Isaac"
Prelude to Foundation ,"Asimov, Isaac"
Foundation and Earth ,"Asimov, Isaac"
Second Foundation
{% extends 'layouts/master.twig' %}
{# Without this set line, master.twig is rendered, but the blocks do nothing. With this line, an NPE is thrown #}
{% set nick = (humanity.getBot.getNick is null) ? "TheHumanity" : humanity.getBot.getNick %}
{% block title %}{{ nick }}{% endblock %}
{% block content %}
<h1>{{ nick }}</h1>
{% if (humanity.getGames is not empty) %}
<h2>Games</h2>
<table class="table table-striped">