Skip to content

Instantly share code, notes, and snippets.

alias shouldstrip { if ($nick == Nick && $chan == #channel) return $true }
on ^:TEXT:*:#:if ($shouldstrip) { echo -mbflirt # #+(<,$nick(#,$nick).pnick,>) $strip($1-) | haltdef }
on ^:ACTION:*:#:if ($shouldstrip) { echo $color(action) -mbflirt # * $nick(#,$nick).pnick $strip($1-) | haltdef }
@RangerDane
RangerDane / stupify.rb
Created January 31, 2017 06:41
aadd sone authnticity to qny sent3nce
# _____ __ _ ____
# / ___// /___ ______ (_) __/_ __
# \__ \/ __/ / / / __ \/ / /_/ / / /
# ___/ / /_/ /_/ / /_/ / / __/ /_/ /
# /____/\__/\__,_/ .___/_/_/ \__, /
# /_/ /____/
# type like you're trying really hard
# give it a sentence, an intelligence score from 0 to 1
@RangerDane
RangerDane / Nonsense.rb
Last active September 13, 2018 20:43
markov chain of varying depth (character level)
# nonsense.rb
# a markov chain of varying depth
# USAGE: make a new nonsense tree, add lines, then chain!
# > non = Nonsense.new 2
# > non.add_line "What is happening"
# > non.add_line "The world is on fire"
# > non.chain
# => "What won hat woren ire worenis hape"
class Nonsense
@RangerDane
RangerDane / connect_four.js
Created November 9, 2016 07:46
connect four - built in 1 hour for an interview
var GameView = require('./console_view.js');
function ConnectFour() {
this.buildBoard();
this.player = 1;
this.playerWon = false;
}
ConnectFour.prototype.buildBoard = function() {
var board = [], row;
@RangerDane
RangerDane / Sieve.rb
Last active November 2, 2016 04:33
Sieve of Eratosthenes in Ruby
# Sieve of Eratosthenes. Use it for all of your prime number shenanigans.
# Built this for solving Project Euler problems.
# Hash map chosen over array after careful arbitrary consideration.
### O(1) amortized lookup of any prime with dynamic resizing.
### O(n) memory where n = size of cache, but RAM is cheap these days.
class Sieve
def initialize()
@size = 64
@next = 1
import itertools
array = [1,2,3,4,5,6,7,8]
combs = itertools.combinations( array, 2 )
largest = 0
for x in combs:
largest = max( sum( x ), largest )
print largest
class PrefixTree
attr_reader :longest
def initialize
@tree = {}
@longest = 0
end
def insert( str )
node = @tree