This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; weasel | |
| (def TARGET "ME THINKS IT IS LIKE A WEASEL") | |
| (def ALPHABET "ABCDEFGHIJKLMNOPQRSTUVWXYZ ") | |
| (def RATE 0.05) | |
| (def rand-seed | |
| "Generate a random seed as long as the target." | |
| (take (count TARGET) (repeatedly #(rand-nth ALPHABET)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mport re | |
| import os | |
| import random | |
| from irctk import Bot | |
| _DEFAULT_CHAIN_LEN = 2 | |
| _DEFAULT_WORD_RANGE = 26 | |
| PUNCTUATION = '.\?|.!|.\.' | |
| TALKATIVE = 0.3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <string.h> | |
| #include <stdlib.h> | |
| char* add_cell(char* tape, size_t *tape_size) { | |
| char* tmp = (char*)realloc(tape, (++*tape_size) * sizeof(char)); | |
| if (tmp == NULL) { | |
| printf("FATAL: Could not reallocate tape memory!"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <string.h> | |
| #include <stdlib.h> | |
| // initialize the tape with 30,000 zeroes | |
| unsigned char tape[30000] = {0}; | |
| // set the pointer to point at the left-most cell of the tape | |
| unsigned char* ptr = tape; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| terminal | |
| -------- | |
| A simple checkout simulator. | |
| ''' | |
| class Terminal(object): | |
| '''A "point of sale" terminal object.''' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdlib.h> | |
| #include <stdio.h> | |
| #include <string.h> | |
| #include <time.h> | |
| char* ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ "; | |
| char* TARGET = "ME THINKS IT IS LIKE A WEASEL"; | |
| float RATE = 0.05; | |
| int GENERATIONS = 250; | |
| int ALPHABET_LEN = 27; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # radioreddit stuff | |
| @bot.command | |
| def status(stream): | |
| streams = [ | |
| 'rock', | |
| 'electronic', | |
| 'hiphop', | |
| 'random', | |
| 'talk', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class RingBuffer(object): | |
| '''This data structure provides a circular "ring" queue, limited by | |
| n-number of positions as `length`. Once the ring is full, i.e. the length | |
| is exceed, the head of the queue is deleted. In this way we acheive a | |
| first in, first out circular buffer.''' | |
| def __init__(self, length): | |
| self.queue = [] | |
| self.keys = [] | |
| self.length = length |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import thread | |
| from time import sleep | |
| items = [2, 4, 5, 2, 1, 7] | |
| def sleep_sort(i): | |
| sleep(i) | |
| print i | |
| [thread.start_new_thread(sleep_sort, (i,)) for i in items] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add = lambda x, y : add((x & y) << 1, x ^ y) if x != 0 else y; add(13,29) | |
| def add_again(x, y): | |
| if x == 0: | |
| return y | |
| else: | |
| return add_again((x & y) << 1, x ^ y) |