Skip to content

Instantly share code, notes, and snippets.

View nsmaciej's full-sized avatar
🙂
o awen pona

Maciej Goszczycki nsmaciej

🙂
o awen pona
View GitHub Profile
@nsmaciej
nsmaciej / Cargo.toml
Last active February 26, 2017 13:57
Panic while getting remote
[package]
authors = ["mgoszcz2"]
name = "reactor"
version = "0.1.0"
[dependencies]
futures = "0.1.10"
tokio-core = "0.1.4"
@nsmaciej
nsmaciej / huffy.rs
Last active February 17, 2017 05:57
Huffman encoding assignment
use std::io;
use std::cmp::max;
use std::cmp::{Ordering, PartialOrd};
use std::cmp::Ordering::*;
use std::collections::HashMap;
use std::collections::BinaryHeap;
#[derive(Debug)]
enum Node { Leaf(char), Branch(Box<Node>, Box<Node>) }
import Control.Monad.Trans.State
import Data.List (intercalate)
import Control.Monad.IO.Class (liftIO)
type TodoState a = StateT [Todo] IO a
type Category = String
data Todo = Todo { text :: String
, categories :: [Category]
} deriving (Show)
@nsmaciej
nsmaciej / robots.py
Last active March 27, 2016 16:22
Robots.py - Python clone of BSD Robots
#!/usr/bin/env python3
# Robots.py - Python clone of BSD Robots
# Copyright (C) 2016 Maciej Goszczycki
# Thanks to Harvey Brezina Conniffe for initial idea
#
# 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.
@nsmaciej
nsmaciej / README.md
Last active January 27, 2016 14:35
Conway's game of life in Kona

Conway's game of life

Get Kona from http://kona.github.io and run with ./k cs

  • c.k - Neat version (192 characters)
  • cs.k - Tweet sized version (112 characters)
@nsmaciej
nsmaciej / index.html
Last active December 2, 2015 20:25
Code in the Dark
<!doctype html>
<html>
<head>
<style>
.nav {
font-size: %50;
}
.heading {
font-size: 40px;
@nsmaciej
nsmaciej / Maciej.hs
Created May 15, 2015 19:06
Finding Maciej numbers
module Main where
fastlog :: Int -> Int -> Int
fastlog b n
| n < 1 = -1
| otherwise = 1 + fastlog b (n `div` b)
roundt :: Int -> Int
roundt n = m * (n `div` m)
where m = 10 ^ (fastlog 10 n)
@nsmaciej
nsmaciej / datetime.py
Last active August 29, 2015 14:18
Python module shadowing
# Call this file "datetime.py" (or any other stdlib name)
# and import it. It will behave just as if it was the
# library itself, but contain a 'fake' attribute
# $ ls
# datetime.py
# $ python
# >>> import datetime
# >>> datetime.fake
# True
Outcomes: Hit, Miss, Sunk
(find) 10D: m
import random
import string
def pboard():
for i in board:
print(''.join(i))
def countf(what):
cnt = 0
for i in board: