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 / ff.sh
Created February 12, 2017 22:43
Examples on how to manipulate Files and Folders with Bash
#!/bin/bash
# ff.sh ver 1.0
# Manipulate Files and Folders with Bash…
# minimal check of correct amount of input arguments
if [[ $# -eq 0 ]] ; then
echo "Use a file with a valid file extension, then do:"
echo "bash ff.sh [testfile.ext]"
exit 0
fi
@kebman
kebman / primitiveRootModulo.js
Created August 10, 2017 02:26
Find All Primitive Root Modulo of a Prime Number
/*
* Equation for finding the Primitive Root Modulo n:
* cn^n mod p
* for n = 1 to n = p-1
* This program is a little heavy on the counting, though it seems to work with the current set of Prime Numbers...
*/
// a few prime numbers for testing:
const primeNumbers = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281];
// console.log(primeNumbers.length); // check size
@kebman
kebman / getBtcUsd.js
Last active October 25, 2017 05:32
Get Bitcoin BTC/USD quotes from Bitstamp.net using Node.js
/*
* Small Node.js script that gets BTC/USD quotes from www.bitstamp.net
* from https://www.bitstamp.net/api/v2/ticker/BTCUSD/
*/
const https = require('https'); // because the URL is https
const quoteOptions = {
host: 'www.bitstamp.net',
port: 443, // because https default
@kebman
kebman / hashfiles.py
Last active February 15, 2018 22:30
A small Python script meant to find file duplicates by listing hashes, file (birth) creation times and file sizes. Copy and edit as you wish.
#!/usr/bin/env python2
import os
import hashlib
import datetime
# Warning: Recursive program. If ran or set from root, it will list ALL THE FILES on the drive. Hit Ctrl+C if you get bored.
path = "."
# UX (and OS X) spesific path names
homedir = os.path.expanduser('~')
@kebman
kebman / gpsConverter.html
Created March 31, 2018 20:48
Converts Google Maps coordinates for use with Adobe Bridge image metadata
<!DOCTYPE html>
<html>
<head>
<title>Google Maps GPS Coordinate to Adobe Bridge - kebman.com</title>
<meta charset="utf-8">
<style type="text/css">
#form {
background-color: MistyRose;
padding: 0.5em;
}
@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)
@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 / 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 / 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 / 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
*/