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
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, |
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
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; |
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
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; |
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
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 |
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 <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; |
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
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. |
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
#!/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. | |
# |
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
#!/usr/bin/env python3 | |
# https://codegolf.stackexchange.com/questions/57891/curly-numbers | |
import re | |
import math | |
CURLIES = [ | |
"{;;}", # 8 | |
"{{;};};", # 21 | |
"{};;;", # 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
var GridPaint = require('gridpaint'); | |
var painter = new GridPaint({ width: 26, height: 15, cellWidth: 16 }), | |
d, actions; | |
document.body.appendChild(painter.dom); | |
d = document.createElement('div'); | |
d.style.marginBottom = '6px'; | |
painter.palette.forEach(function (colour, i) { |
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
(function () { | |
var module = {}; | |
// maps | |
var LOBBY = [ | |
[ 1, 1, 1, 1, 1, 1, 1, 1 ], | |
[ 1, 0, 0, 0, 1, 0, 0, 1 ], | |
[ 1, 0, 0, 0, 1, 0, 0, 1 ], | |
[ 1, 0, 0, 0, 1, 0, 0, 1 ], | |
[ 1, 0, 0, 0, 1, 1, 0, 1 ], |
OlderNewer