Skip to content

Instantly share code, notes, and snippets.

View JanneSalokoski's full-sized avatar

Janne Salokoski JanneSalokoski

View GitHub Profile
@JanneSalokoski
JanneSalokoski / dhondt.js
Created November 24, 2020 21:17
D'Hondt method
const nanoid = require('nanoid');
function readable_id() {
const id = nanoid.customAlphabet('1234567890abcdef', 8)();
const readable_id = `${id.slice(0, 4)}-${id.slice(4)}`
return readable_id;
}
const candidates = [
{ id: readable_id(), name: 'Janne Salokoski', list: 'Osakuntalaiset' },
@JanneSalokoski
JanneSalokoski / print16colours.sh
Last active December 12, 2019 11:46 — forked from HaleTom/print256colours.sh
Print a 256-colour test pattern in the terminal
#!/bin/bash
# Tom Hale, 2016. MIT Licence.
# Print out 256 colours, with each number printed in its corresponding colour
# See http://askubuntu.com/questions/821157/print-a-256-color-test-pattern-in-the-terminal/821163#821163
set -eu # Fail on errors or undeclared variables
printable_colours=256
#
# Luo tähän tiedostoon yksinkertainen komentoriviohjelma, joka toimii laskimena.
# Laskimen tarvitsee vähintään pystyä laskemaan x+y -laskuja.
# Yritä tehdä laskimesta helppokäyttöinen ja lisätä peruslaskimen ominaisuudet.
# Käytä haluamaasi ohjelmointikieltä.
#
# Koodin ei tarvitse olla täydellinen, eikä sen tarvitse päästä buildaamisesta
# läpi. Harjoituksen tarkoituksena on kartoittaa ohjelmointiosaamista.
#
@JanneSalokoski
JanneSalokoski / Player Initialization Statements
Last active December 11, 2017 07:36
VBS3 Respawn All -script
nul = [] execVM "init.sqf";
var URL = "http://localhost:8080/";
var Socket = function(url)
{
// Global properties
this.url = url;
this.connection = new WebSocket(URL);
// Global functions
this.send = function(msg)
var Point = function(x, y)
{
this.x = Number(x);
this.y = Number(y);
this.toString = function()
{
return "(" + this.x + ", " + this.y + ")"
}
}
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
path
{
fill: none;
stroke: red;
@JanneSalokoski
JanneSalokoski / README.md
Last active December 28, 2016 07:27
Utilities.js is a 'library' of generally useful functions not included in JavaScript standard libraries.

Utilities.js

Description...

Utilities.get_random_integer()

The Utilities.get_random_integer() function returns a pseudo-random integer number in the range [min, max] or [min, max), depending on its arguments.

Syntax

var Game = function (return_function)
{
this.play = function (bet, callback)
{
var return_amount = return_function(bet)
if (callback !== undefined)
{
callback(return_sum);
}
let express = require("express");
let server = express()
let bodyParser = require('body-parser');
let multer = require('multer'); // v1.0.5
let upload = multer(); // for parsing multipart/form-data
// $npm install express body-parser multer --save