Skip to content

Instantly share code, notes, and snippets.

View kebman's full-sized avatar
Playing Ponkatris

kebman kebman

Playing Ponkatris
View GitHub Profile
@kebman
kebman / EURNOKslider.html
Created September 16, 2018 22:00
EUR/NOK Currency Slider in HTML5
<!DOCTYPE html>
<html>
<head>
<title>EUR/NOK Slider</title>
<meta charset="utf-8">
<style type="text/css">
.slidecontainer {
width: 20em; /* Width of the outside container */
}
/* Slider */
@kebman
kebman / mousePos2.html
Created August 9, 2018 13:13
Short HTML5 + JavaScript that tracks mouse position only while the mouse button is clicked down
<!DOCTYPE html>
<html>
<head>
<title>Track Mouse Position II</title>
<meta charset="utf-8">
<style type="text/css"></style>
</head>
<body>
<header>
<h1>Track Mouse Position II</h1>
@kebman
kebman / mousePos1.html
Created August 9, 2018 13:11
Short HTML5 + JavaScript that tracks mouse position
<!DOCTYPE html>
<html>
<head>
<title>Track Mouse Position I</title>
<meta charset="utf-8">
<style type="text/css"></style>
</head>
<body>
<header>
<h1>Track Mouse Position I</h1>
@kebman
kebman / coinbaseData.html
Last active August 2, 2018 09:59
Visualisation of Coinbase Pro market data using JavaScript Canvas
<!DOCTYPE html>
<html>
<head>
<title>Coinbase Pro Market Data</title>
<meta charset="utf-8">
<style type="text/css"></style>
</head>
<body>
<header>
<h1>Coinbase Pro Market Data</h1>
@kebman
kebman / median.js
Created July 22, 2018 20:10
Find the median of an array of numbers using JavaScript
function median(arr) {
let middle = Math.floor((arr.length-1)/2);
if (arr.length % 2) {
return arr[middle]; // odd
} else {
return (arr[middle]+arr[middle+1])/2; // even
}
}
@kebman
kebman / slowServer.js
Last active July 18, 2018 01:15
A minimal ‘slow’ server to test API calls with callbacks and promises
'use strict';
/*
* Before you start, make sure you've done the following:
* mkdir slowServer
* cd slowServer
* $ npm init
* $ npm install express --save
* Then copy this file to the slowServer directory
*/
@kebman
kebman / dynamicUpdate.js
Created July 8, 2018 18:15
Short and simple example on how to build a dynamic update query in SQL using JavaScript
// data from database (illustration):
const selected = {
nick: "bob",
name: "Richard",
surname: "Bach",
address: "Somewhere"
};
// new input from client
let newInput = {
@kebman
kebman / openssltutorial.md
Last active November 25, 2022 12:35
How To Encrypt a File – And Securely Send It – using OpenSSL

Here is a tutorial – or simulation, rather – on symmetric file encryption, and public key encryption to securely send your keys and files to a friend using OpenSSL with the Terminal. The tutorial is made for UX systems (e.g. OS X and Linux), and you may have to install OpenSSL if you don't have it (OS X should have it pre-installed).

Note: The use of the dollar sign ($) in front of the terminal lines is just a convention. Ignore it, and focus on what comes after it.

Simulation

@kebman
kebman / AnimationTut.html
Created May 27, 2018 04:00
Small Animation Logic Tutorial for JavaScript Canvas
<!DOCTYPE html>
<html>
<head>
<title>Animation Logic Tutorial for Canvas</title>
<meta charset="utf-8">
<style type="text/css">
canvas {
background-color: #ddd;
/* so the canvas can be seen... */
}
@kebman
kebman / standard_deviation.py
Last active May 17, 2018 14:18
Example of how to calculate the Standard Deviation of a dataset using Python 2.7
#!/usr/bin/env python2
import math
# An imaginary dataset of 50 respondents graded from 1-9, so we have an example to play with:
dataset = [1,1,1,2,3,1,1,4,4,5,6,1,4,9,9,7,7,6,7,5,4,3,6,8,9,5,5,6,6,6,5,5,5,5,4,4,4,6,6,4,7,3,7,3,7,4,4,4,4,9]
# Amounts of each: 1*6,2*1,3*4,4*12,5*8,6*8,7*6,8*1,9*4
# Control: 6+1+4+12+8+8+6+1+4=50
# the mean average (the arithmetic mean) is the sum of all the grades added together, divided by the amount of grades given
mean = sum(dataset)/len(dataset)