Skip to content

Instantly share code, notes, and snippets.

@Rapptz
Rapptz / xclip.cpp
Last active Jan 7, 2022
Windows port of xclip
View xclip.cpp
// The MIT License (MIT)
// Copyright (c) 2014 Rapptz
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
View gist:a4f2c24dcd9507be2404e1f9a943f02e
2016-11-02 17:31:20 #python_discord-py @luke#7172: uhhh
2016-11-02 17:31:36 #python_discord-py @Fuyukai desu#0588: what
2016-11-02 17:31:46 #python_discord-py @luke#7172: :/
2016-11-02 17:31:50 #python_discord-py @luke#7172: I don't know how to do this
2016-11-02 17:32:27 #python_discord-py @luke#7172: I need to get info of another shard
2016-11-02 17:33:03 #python_discord-py @luke#7172: like server amount, etc
2016-11-02 17:33:07 #python_discord-py @luke#7172: whats the best method to do this
2016-11-02 17:34:07 #python_discord-py @Fuyukai desu#0588: ipc
2016-11-02 17:34:37 #python_discord-py @luke#7172: Indian Penal Code?
2016-11-02 17:34:41 #python_discord-py @Recchan#4305: who shards
@Rapptz
Rapptz / custom_commands.py
Last active Oct 3, 2021
Showing off custom commands using discord.ext
View custom_commands.py
import discord
from discord.ext import commands
import json, inspect
import functools
import re
# some JSON set up for our storage because >lazy<
class CustomCommandEntry:
__slots__ = ['name', 'content', 'guild_id']
View docs.md

Overview

messages can be sent with the components key to add buttons and other components (when discord brings them out), you can edit and add new buttons via editing the message, this is useful for the disabled key to stop people from clicking it.

Example Payload

{
    "content": "this is an example message for components",
    "components": [
        {"type": 1, "components": [
            {"type": 2, "style": 2, "label": "Button 1", "custom_id": "1"},
@Rapptz
Rapptz / hscards.json
Last active Feb 27, 2021
Hearthstone Cards
View hscards.json
[
{
"id": 7,
"name": "Garrosh Hellscream",
"description": "",
"image": "http:\/\/wow.zamimg.com\/images\/hearthstone\/cards\/enus\/medium\/HERO_01.png",
"class": "warrior",
"type": "hero",
"quality": "free",
"race": "none",
View vector.lua
local vector = {}
vector.__index = vector
local function is_vector(t)
return getmetatable(t) == vector
end
function vector.new(x, y)
return setmetatable({ x = x or 0, y = y or 0 }, vector)
end
@Rapptz
Rapptz / tiebreaker.md
Created Dec 14, 2014
Median-Buchholz
View tiebreaker.md

How Median-Buchholz tie breaker works.

Assumptions:

  1. We are talking about 2 different players, P1 and P2.
  2. They each played 6 rounds.
  3. They each won 4 of them and lost two of them (i.e. they're tied).

After all 6 rounds, the opponents for P1 ended up with the following track record:

View discord_qol.md

I restricted these to client-only QoL features that I thought were small.

  • Reverse sorting search
  • Group by Guild in Emoji panel so you can see what guild an emoji is in
  • Disabling "GIF" or "Gift" buttons in the message box
  • Hover over for complete timestamp on messages
    • Maybe the same for embed timestamps?
  • More time information in call messages (e.g. how long it lasted for) (I know it's provided in the message since I have it in d.py)
  • Lock channels so you don't accidentally move them by dragging (this one might be less trivial iunno)
  • Character count indicator for knowing if you're reaching 2000 characters. too hard apparently
@Rapptz
Rapptz / stats.md
Last active Oct 29, 2018
Statistics for /r/smashbros
View stats.md

/r/smashbros Statistics

  • Statistics processed at 2015-05-26T23:02:47.304000
  • Total number of posts processed: 100
  • Average score: 112.40 (± 252.79)

Overview

Stat Video Self Video Self Giflike Self Image Tweet Self Tweet Misc Self Misc
@Rapptz
Rapptz / strawpoll_bot.py
Created Apr 27, 2015
A strawpoll bot for /u/-anti
View strawpoll_bot.py
#!/usr/bin/env python
import praw
import requests
### configuration
username = '...'
password = '...'
subreddit = '...'
# use {url} to get the strawpoll url