Skip to content

Instantly share code, notes, and snippets.

View FOLLGAD's full-sized avatar
🌍
meandering

Emil Ahlbäck FOLLGAD

🌍
meandering
View GitHub Profile
### Keybase proof
I hereby claim:
* I am follgad on github.
* I am emilahlback (https://keybase.io/emilahlback) on keybase.
* I have a public key ASBxx4TSjZozItRhSyOD_ceH8PGPmQOG2g7GDDEUg8qVkgo
To claim this, I am signing this object:
@FOLLGAD
FOLLGAD / getHash.js
Created March 3, 2018 16:50
Node.js thesubdb.com hash implementation
const fs = require('fs'),
crypto = require('crypto')
function getHash(pathToFile) {
let readSize = 64 * 1024 // 64kb
return new Promise((resolve, reject) => {
let fd = fs.openSync(pathToFile, 'r')
let buffer = new Buffer(readSize * 2)
@FOLLGAD
FOLLGAD / 10-modulmetoden.js
Last active October 18, 2022 09:08
10-modulmetoden i Javascript för att validera svenska personnummer
function getCheckSum(ch) {
let ps = ch.slice(0, -1).split('').reverse()
let sums = ps.map((s, i) => {
let m = (i % 2 == 0) ? 2 : 1;
let rem = (parseInt(s) * m).toString().split('')
return rem.reduce((d,a) => Number(d) + Number(a), 0)
})
let res = sums.reduce((d,a) => Number(d) + Number(a), 0)
@FOLLGAD
FOLLGAD / planetmcScraper.js
Last active May 10, 2021 06:33
Scrape planetminecraft total player count to get an overview of when most people are active to time server updates
// get the stat count from planetminecraft.com
const cheerio = require("cheerio")
const fetch = require("node-fetch")
const fs = require("fs")
const getTheStat = () => {
fetch("https://www.planetminecraft.com/resources/servers/")
.then(res => res.text())
.then(html => {
let planet = cheerio.load(html),

Keybase proof

I hereby claim:

  • I am follgad on github.
  • I am emilahlback (https://keybase.io/emilahlback) on keybase.
  • I have a public key ASDC9Qg9zzarwY7QWmaAohK6AI4IC_hOBdyk_cKM9BgtPAo

To claim this, I am signing this object:

@FOLLGAD
FOLLGAD / convert-png.js
Last active January 21, 2021 18:39
Use node to make a png into an array of 1s and 0s (black and white)
let fs = require('fs'),
PNG = require('pngjs').PNG;
fs.createReadStream('./dino_design20by20.png')
.pipe(new PNG({
filterType: 4
}))
.on('parsed', function () {
let arr = []
for (let y = 0; y < this.height; y++) {
@FOLLGAD
FOLLGAD / youtube-discord.md
Last active May 15, 2022 10:38
Connecting Youtube to Discord with webhooks using IFTTT

Step 1: Register on IFTTT

Make an account on https://ifttt.com if you don't have one already

Step 2: Make a Discord webhook

  1. In your Discord server, click "Server Settings", then go to "Webhooks"
  2. Click "Create Webhook"
  3. Choose a name for your Webhook, and choose in which channel you want the messages to show up in
  4. Copy the "Webhook URL" in the bottom. This url is important, and should NOT be given away. If anyone gets a hold of it, they can post messages to this channel, so keep it secret!
@FOLLGAD
FOLLGAD / wakatime-parser.ts
Last active January 21, 2021 18:41
Wakatime data compiler
// This is written for Deno, not node.js
import { readJson } from "https://deno.land/std@0.63.0/fs/read_json.ts"
/*
A script I wrote to parse the data you can download from WakaTime, to display how many hours you spent working on specific
projects.
*/
interface Duration {
@FOLLGAD
FOLLGAD / package.json
Last active August 29, 2023 14:56
Convert PureWriter backup to Markdown files
{
"name": "pw-conv",
"version": "1.0.0",
"description": "",
"main": "purewriter-to-md.js",
"type": "module",
"scripts": {},
"author": "FOLLGAD",
"license": "ISC",
"dependencies": {
@FOLLGAD
FOLLGAD / setup.sh
Last active December 9, 2021 15:12
sudo apt update && sudo apt upgrade
sudo apt -y install mpv
sudo apt -y install git
sudo apt -y install syncthing
sudo apt -y install transmission-daemon
sudo apt -y install firefox
sudo add-apt-repository ppa:neovim-ppa/unstable
sudo apt -y install neovim
sudo apt -y install fd-find