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 / nordics_lightning_alert.py
Last active July 7, 2023 07:07
A small script that alerts the user of lightning if it strikes within 16 km (10 miles) of your home in the Nordics, based on observations from The Norwegian Meteorological Institute.
#!/usr/bin/python3
from sseclient import SSEClient
import json
from math import sqrt
import winsound # NOTE: Windows only
from datetime import datetime, timezone, timedelta
'''
Version 2.1 (2023-07-07): A small script that alerts the user of lightning if it strikes within 16 km (10 miles) of your home position in the Nordics.
Based on lightning observations broadcast as SSE from The Norwegian Meteorological Institute, https://www.met.no/.
@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 / UnicodeMath.sublime-settings
Last active November 23, 2022 02:08
User settings for Unicode Math for em dash, en dash and special quotation marks used in English, Norwegian, French and Swedish.
{
"symbols": {
"emdash": "\u2014", // —
"endash": "\u2013", // –
"laquo": "\u00AB", // «
"raquo": "\u00BB", // »
"ldquo": "\u201C", // “
"rdquo":"\u201D", // ”
"lsquo": "\u2018", // ‘
"rsquo": "\u2019", // ’
@kebman
kebman / checkFileDupes.js
Created October 2, 2015 02:12
Check for duplicate files with Node.js
// find duplicate files with Node.js, cuz, you know, it's useful
var Promise = require('bluebird');
var fs = Promise.promisifyAll(require('fs'));
var crypto = require('crypto');
var path = require('path');
var pathA = "."; // folder you're in, wherever that might be
var pathB = "/path/to/the/directory/you/want/to/compare/it/to"; // yes, yes, argv, etc, but I haven't bothered yet, ok!
@kebman
kebman / lyn_met_no_SSE_client.py
Last active July 27, 2021 11:18
Get SSE lightning strikes from the Norwegian Meteorological Institute at https://lyn.met.no/events
#!/usr/bin/python3
from sseclient import SSEClient
import json
# get the stream
thundercloud = SSEClient('https://lyn.met.no/events')
# keep checking for new lighning strikes
for lightning in thundercloud:
@kebman
kebman / orderFormatter.html
Created May 7, 2021 19:57
Coinbase Pro Order Formatting Tool in HTML5
<!DOCTYPE html>
<html class="no-js" lang="eng">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="Order Formatting App">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- <link rel="stylesheet" href="css/main.css"> -->
<style type="text/css">
@kebman
kebman / tarkovModules.cypher
Last active May 16, 2020 00:08
Escape from Tarkov: Dealer to Module relations in Cypher for the graph database Neo4j
CREATE (h:Module {
name: "Air Filtering Unit I",
requirements: [
'$10,000',
'Generator III',
'Vents III',
'Skier III'
],
functions: [
"Group of skills levelling boost: Physical, +40%"
@kebman
kebman / COVID-19_data_from_Norway.json
Last active April 23, 2020 05:17
COVID-19 data from Norway: Tested, Infected, Hospitalized, Dead.
"source":"https://www.vg.no/spesial/2020/corona/",
"events":[
{"2020-03-13":"Change of test criteria"},
{"2020-03-26":"NIPH (FHI) uses MSIS data"},
{"2020-04-20":"Partial reopening of kindergartens and hair dressers"}
],
"majorReCheckOfDataset":["2020-04-03"],
"lastUpdated":["2020-04-03", "2020-04-08", "2020-04-17", "2020-04-21"],
"coronaTestDataForNorway": [
{
@kebman
kebman / compounding1.py
Created August 2, 2019 03:05
Calculate compounding interest with this short Python script.
#!/usr/local/bin/python3.7
principal = 10000.0
interest_rate = 5.0
time_units = 10
def get_percentage(inputf, percentage):
return inputf * percentage / 100.0
def get_compounding(principalf, n):