Skip to content

Instantly share code, notes, and snippets.

View dotmh's full-sized avatar

Martin Haynes dotmh

View GitHub Profile
@dotmh
dotmh / dkim-spliter.js
Created January 8, 2024 11:44
DKIM Spliter
const maxWidth = 250
const string = "<DKIM KEY HERE>"
const chunks = Math.ceil(string.length / maxWidth);
let stringChunked = [];
for (let i = 0; i < chunks; i++) {
stringChunked.push(string.slice(i*maxWidth, (i+1)*maxWidth))
}
@dotmh
dotmh / main.js
Created July 8, 2022 14:05
Gen Art
let angle = 0;
let radiusNoise
let angleNoise
let centerNoise;
function setup() {
createCanvas(1024, 768);
background(220);
radiusNoise = random(10);
angleNoise = random(10)
@dotmh
dotmh / README.md
Created June 30, 2020 15:50
A really simple Which port function for MacOS

Which Port

Which port is designed to tell you which app is using a specified port ether with UTP or TCP. This is designed to work on MacOS only.

Installation

Add the above function to your startup script i.e. ~/.profile or your ~/.zshrc. Consult the documentation for your shell if you aren't using bash or zsh.

@dotmh
dotmh / CalculatePi.js
Created June 18, 2020 13:57
Calculate PI using Random Numbers
const mjs = require("mathjs");
const upper = 10000000;
const sampleSize = 1000;
const attempts = 1000;
const calculatePi = () => {
const a = Array(sampleSize)
.fill(0)
.map(() => [mjs.ceil(mjs.random(1, upper)), mjs.ceil(mjs.random(1, upper))])
@dotmh
dotmh / index.js
Created November 19, 2018 15:22 — forked from JonathanMH/index.js
JSON Web Token Tutorial: Express
// file: index.js
var _ = require("lodash");
var express = require("express");
var bodyParser = require("body-parser");
var jwt = require('jsonwebtoken');
var passport = require("passport");
var passportJWT = require("passport-jwt");
@dotmh
dotmh / build.js
Last active February 7, 2018 14:41
Metalsmith
var Metalsmith = require('metalsmith');
var Layouts = require('metalsmith-layouts');
var Sass = require('metalsmith-sass');
var Copy = require("metalsmith-copy");
var Watch = require("metalsmith-watch");
var DiscoverPartials = require('metalsmith-discover-partials');
var SRC = "./src";
var VIEWS = SRC+'/_views';
var OUT = "build";
@dotmh
dotmh / electronDrag.css
Created August 16, 2017 08:40
Make an Frameless electron app Dragable, create a dragging region i.e. div and apply the follow CSS
.region {
position: absolute;
width: 125px;
height: 81px;
left: 0;
top: 0;
-webkit-app-region: drag;
}
@dotmh
dotmh / google_twunter_lol
Created May 3, 2017 15:14 — forked from jamiew/google_twunter_lol
All the dirty words from Google's "what do you love" project: http://www.wdyl.com/
easterEgg.BadWorder.list={
"4r5e":1,
"5h1t":1,
"5hit":1,
a55:1,
anal:1,
anus:1,
ar5e:1,
arrse:1,
arse:1,

Keybase proof

I hereby claim:

  • I am dotmh on github.
  • I am dotmh (https://keybase.io/dotmh) on keybase.
  • I have a public key whose fingerprint is 689F 08A1 2626 DF87 EEEA 2893 823D B5B6 EE1A AB67

To claim this, I am signing this object:

@dotmh
dotmh / design_document.js
Last active August 29, 2015 14:13
design documents issue in pouchdb
function(doc) {
if ( doc.collection === "foobar") {
for(var i = 0; i < doc.belongsTo.length; ++i) {
var belongTo = doc.belongsTo[i];
if ( !!belongTo.length) {
emit(belongTo);
}
}
}
}