Skip to content

Instantly share code, notes, and snippets.

#Description

It's 2015 and we've all moved on from IRC, right? Wrong! Freenode (the largest FOSS focused IRC network) has over 80,000 users, and gains around 5000 new users every year. /r/DailyProgrammer, as awesome as it is, happens to have its very own IRC channel on freenode (#reddit-dailyprogrammer), but it's missing one thing: Bots.

The goal of this channel is to create an interactive IRC bot capable of performing one or more basic bot-like things.

import random
ID_AIR = 0
ID_DIRT = 1
ID_SAND = 2
ID_LAVA = 3
ID_DIAMOND = 4
ID_HERO = 5
DEBUG = True
Macbeth := FileOpen("macbeth.txt", "r`r`n").Read() ; `r`n in the read options to normalize line endings to just "`n"
; Find which Act, scene, and dialog contains our phrase
; ---
; Replace multiple newlines with `r, which is not actually being used for anything.
; Makes it idea for a temporary separator. Then, split it based on `r (you can only
; split based on character, not based on string of characters)
Sections := StrSplit(RegExReplace(Macbeth, "\n{2,}", "`r"), "`r")
for each, Section in Sections
{
#NoEnv ; Don't try to pull variables from the environment (speeds things up)
SetBatchLines, -1 ; Don't pause between lines (also speeds things up)
Macbeth := Shakespeare.Writeth("Macbeth")
MsgBox, % Shakespeare.ReadethPassage(Macbeth.PassageThatContaineth("Eye of newt"))
class Shakespeare
{
static Phrases := StrSplit("Bated breath,Cold comfort,Devil incarnate,"
. "Elbow room,Faint hearted,Fancy-free,Flaming youth,Foregone conclusion,"
#NoEnv
SetBatchLines, -1
Input := "13 743"
Start := A_TickCount
for each, Link in FindChain([2, 1], StrSplit(Input, " ")*)
Out .= ", " Link
Elapsed := A_TickCount - Start
MsgBox, % SubStr(Out, 3) "`n" Elapsed "ms"
@G33kDude
G33kDude / BinClock.ahk
Created March 13, 2015 02:22
Binary clock
On := "●"
Off := "○"
Blank := " "
Gui, Color, Black
Gui, font, s12 cRed, Courier New
Gui, Add, Text, vDisplay, % MakeDisplay(On, Off, Blank)
Gui, +ToolWindow +E0x40000 +AlwaysOnTop
Gui, Show,, BinClock
SetTimer, UpdateDisplay, 1000
Input =
(LTrim0 C
60 30
'"^+$
linear 30 30 0 0
)
Gui, Font,, Courier New
Gui, Add, Edit, w640 h480, % GenerateGradient(Input)
Gui, Show
#SingleInstance, Force
#NoEnv
SetBatchLines, -1
SetMouseDelay, 2
CoordMode, Mouse, Screen
; Start gdi+
If !pToken := Gdip_Startup()
{
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
Input =
(
$.O...O...
...O......
..........
O..O..O...
..........
O..O..O...
..........
......OO..
#Persistent
Small := 32
Medium := 48
Large := 96
IconSize := Small
hDesktop := GetDesktop()
HalfW := A_ScreenWidth/2