Skip to content

Instantly share code, notes, and snippets.

View misterhat's full-sized avatar
💭
🐸 🐸

zorian misterhat

💭
🐸 🐸
  • winnipeg, mb
  • 03:33 (UTC -05:00)
View GitHub Profile
#!/usr/bin/env python3
# https://codegolf.stackexchange.com/questions/57891/curly-numbers
import re
import math
CURLIES = [
"{;;}", # 8
"{{;};};", # 21
"{};;;", # 3
#!/usr/bin/env python3
# tiler.py - print a tile matrix based on two images and a tile size
# Copyright (C) 2015 Zorian M
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
set hintchars=hjklasdfgyuiopqwertnmzxcvb
set gui=noaddons,nobookmarks,nomenu,nonavigation,notabs
" Use DuckDuckGo by default as it has useful ! shortcuts.
set defsearch=duckduckgo
" Don't use completions (they're slow).
set complete=
" Mapping conveniences.
#include <stdio.h>
#include <stdbool.h>
#include <math.h>
const int sizes[] = { 9, 99, 999, 9999, 99999, 999999, 9999999 };
int get_places(int number) {
for (int i = 0; i < 6; i++) {
if (number <= sizes[i]) {
return i + 1;
use std::num;
fn is_prime(number: int) -> bool {
for i in range(2, ((number as f64).sqrt() as int) + 1) {
if number % i == 0 {
return false
}
}
true
use std::io;
static MEM_SIZE: uint = 30_000;
fn main() {
// Initialize the memory with 30 000 0 bytes.
let mut memory = [0 as u8, ..MEM_SIZE];
// The current "cell" we're in, in memory.
let mut pointer = 0;
use std::io::{TcpListener, TcpStream};
use std::io::net::ip::{Ipv4Addr, SocketAddr};
use std::io::{Acceptor, Listener};
fn decode_packet<T: Reader>(stream: &mut T) -> (u8, Vec<u8>) {
let mut length = stream.read_byte().unwrap() as uint;
if length >= 160 {
length = (length - 160) * 256;
length += stream.read_byte().unwrap() as uint;
fn encode_username(username: &str) -> u64 {
let mut encoded = 0;
for character in username.chars() {
let rune = character.to_lowercase() as u64;
encoded *= 37;
encoded += rune - match rune {
97..122 => 96,