Skip to content

Instantly share code, notes, and snippets.

View haze's full-sized avatar
💭
If it's not a challenge I’m not interested

haze

💭
If it's not a challenge I’m not interested
View GitHub Profile
fun capture(base: String, left: String, right: String = left): String = base.substringAfterLast(left).substringBeforeLast(right)
fun unspacify(base: String): String = base.filter { c -> Character.isLetterOrDigit(c) }
class AZLyricsQuery() {
data class Artist(val representation: String, val slug: String)
data class Song(val slug: String, val artist: Artist, val title: String)
data class Album(val artist: Artist, var title: String, var songs: Array<Song>)
data class LyricsEntry(val song: Song, var lyrics: Array<String>)
fun getAlbumsFor(artist: Artist): Array<Album> {
@haze
haze / Genius.kt
Last active January 8, 2017 20:17
1 class API for Genius ( needs Jsoup and Apache HTTP components )
package pw.haze.lyribot
import com.github.salomonbrys.kotson.fromJson
import com.google.gson.Gson
import com.google.gson.annotations.SerializedName
import org.apache.http.client.methods.HttpGet
import org.apache.http.client.methods.HttpUriRequest
import org.apache.http.impl.client.HttpClientBuilder
import org.jsoup.Jsoup
import java.io.BufferedReader
@haze
haze / ill.sh
Created February 4, 2017 23:27
ill.sh os x upload script
#1/bin/sh
# written by haze (feb 4, 2017)
FILE=$1
ILL_FOLDER=$HOME/.ill
KEY_FILE=$ILL_FOLDER/upload.key
if [ ! -f $KEY_FILE ]; then
echo "ill.fi upload key not found. creating file (~/.ill/upload.key), please pbpaste key into file."
if [ ! -d $ILL_FOLDER ]; then
mkdir $ILL_FOLDER
@haze
haze / change.hs
Created September 24, 2017 06:17
replaceNth :: (Eq t1, Num t1) => t1 -> t -> [t] -> [t]
replaceNth n b (x:xs)
| n == 0 = b:xs
| otherwise = x:replaceNth (n - 1) b xs
giveChange :: (Ord a, Num a, Num t) => a -> [a] -> [t] -> (a, [(Double, t)])
giveChange a c u
| null c = (a, zip coins u)
| last c <= a = giveChange (a - last c) c (replaceNth l ((u !! l) + 1) u)
| otherwise = giveChange a (init c) u

Keybase proof

I hereby claim:

  • I am hvze on github.
  • I am x86 (https://keybase.io/x86) on keybase.
  • I have a public key ASAjtOoXQI8XI1eK0o3ca03ZH1xLWsda9ZP0iKcBJgoajwo

To claim this, I am signing this object:

@haze
haze / Problem11.hs
Last active October 1, 2020 08:42
Solution to Problem 11 of Project Euler in Haskell.
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Maybe as M
import qualified Data.Text as T
import qualified Data.Text.Read as R
import qualified Text.Printf as F
data Direction = DiagUpRight | DiagUpLeft | DiagDownRight | DiagDownLeft | Up | Down | Left | Right deriving (Enum, Show)
getGrid :: IO [[ T.Text ]]
@haze
haze / euler1.ill
Created November 22, 2017 18:49
Solution to Euler 1 in Pill.
+counter;
$nop() { }
$inc_counter() {
add x counter;
}
$mod5() {
mov 0 res;
mod x 5 a;
@haze
haze / fb.py
Created March 22, 2018 02:01
stupid fizzbuzz
import base64, codecs
magic = 'aW1wb3J0IGJhc2U2NCwgY29kZWNzCQkKbWFnaWMgPSAnYVcxd2IzSjBJR0poYzJVMk5Dd2dZMjlrWldOekNRa0tiV0ZuYVdNZ1BTQW5ZVmN4ZDJJelNqQkpSMHBvWXpKVk1rNURkMmRaTWpscldsZE9la05SYTB0aVYwWnVZVmROWjFCVFFXNVpWbU40WkRKSmVsTnFRa3BTTUhCdldYcEtWazFyTlVSa01tUmFUV3BzY2xkc1pFOWxhMDVTWVRCMGFWWXdXblZaVm1ST1dqRkNWRkZYTlZwV2JVNDBXa1JLU21Wc1RuRlJhM0JUVFVoQ2RsZFljRXRXYXpGeVRsVlNhMDF0VW1GVVYzQnpZMnhrYzFwRk9XeGhNRFZUV1ZSQ01HRldXWGRYYmxaYVZtMVNUMWRxUmtOV1JrWllUbFp3VjJKVk5EQlhhMUpMVTIxV2MxUnVSbEpoTTBKVVZGVm9RMlJzWkZsalJYUlhZWHBHZVZSc1ZsTmhNREYwVlcxR1ZWWXpRbnBaTW5ocll6RndSazlYZUdoTlJGWlVWMVpTUTAxSFJsZFhXR1JZWW14YVlWWnRNVk5VTVdSeFVtdE9WMUpyV2xsVWJGcDNWakpLVms1RVFsaGhNVXBNVlRJeFYyTXhVblZTYkVwb1RUQktWVlpHVm05Uk1sSnpXa1pzYWxKWVVsaFpXSEJIWlZaU2MxWnNUbWhOUkVZd1ZsY3hSMVpXV1hwUmJuQmFUVzVvY2xsNlJuZFNhemxZWlVkb1RsSkdXbFZXTVZwVFVUQXhTRkpzWkZoWFIxSlpXVzE0WVZsV1duUk5WazVWVFZkU2VGVnRkRTlXTVVweVYyeHNWV0pHY0ROV2FrcExWbXMxUlZGc2FHaE5WWEJOVmxSSmVGWXlUWGhWYmxaVFlrVndiMVJVUWt0V1ZscEhWbTA1VWsxc1NucFhhMXB6WVd4S1dWVnNhRnBYU0VKSVdsWmFVMk14V25
@haze
haze / keybase.md
Created October 20, 2018 14:06
Keybase Proof

Keybase proof

I hereby claim:

  • I am hvze on github.
  • I am x86 (https://keybase.io/x86) on keybase.
  • I have a public key ASCkcYqd4M7UR5M_cyED56dznS1zTeU6BAq6YjlUjowOJQo

To claim this, I am signing this object:

{"description":"Our first update has arrived! 🎉","color":9688585,"timestamp":"2019-03-07T15:38:40.011Z","author":{"name":"Blast — Announcement","icon_url":"https://images-ext-1.discordapp.net/external/QVB95mBD1daN7C6-w7OfLawdWillAa5haHBnVoElhhY/https/cdn.discordapp.com/icons/506219319030448128/342d618bf1cb75d7ce71c44a0904b437.webp"},"footer":{"text":"PS: spamming in channels won't give you XP any faster."},"fields":[{"name":"About","value":"As some of you may have noticed, we have made some changes to the Discord and cleaned it up a bit. We have been preparing for an update, which are **levels**. \n\nNow, you may be asking; what are these levels you're talking about?\nOne can obtain levels by chatting in our channels. The levels each have a role associated with them, these roles give you access to private channels.\n\nOur private channels will also be used for special events. \n\nOne can also become a **Blast** beta-tester, you can read about the requirements below."},{"name":"Requirements","value":"*These ar