Skip to content

Instantly share code, notes, and snippets.

View KristofferK's full-sized avatar

Kristoffer KristofferK

View GitHub Profile
@KristofferK
KristofferK / ndcg.py
Created February 16, 2021 21:31
Calculate normalized Discounted Cumulative Gain (nDCG)
import math
user1 = [1,1,1,0,0,1,0]
user2 = [1,1,0,0,0,0,0]
user3 = [0,0,1,1,0,1,0]
def calcNdcg(user):
idcg = getIdcg(len(user))
dcg = getDcg(user)
ndcg = dcg / idcg
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
namespace WowDownloaderOmegalul
{
class Program
@KristofferK
KristofferK / Program.cs
Created September 11, 2019 12:56
Mazebois
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MazeBois
{
class Program
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace LFLVRenamer
{
using System;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace DougRenamer
{
class Program
{
private const string DIRECTORY = @"D:\Deluge\Doug\";
@KristofferK
KristofferK / Badoo-auto-like-multidimensional-searchspace.js
Last active July 6, 2021 00:36
Badoo auto liker depending on multiple features.
const stats = {};
stats.likes = [];
stats.dislikes = [];
stats.likeReasons = {};
stats.dislikeReasons = {};
(() => {
let liked = 0;
let disliked = 0;
@KristofferK
KristofferK / Badoo-auto-like-mutual-interests.js
Last active May 8, 2018 13:19
Auto like person on Badoo depending on amount of mutual interests. Will also print description and mutual interests to console. https://github.com/KristofferK/thirstyboy-badoo-bot/
(() => {
let liked = 0;
let disliked = 0;
const likeNextPersonAfterALike = (likedName, likedAge, iteration) => {
const age = parseInt(document.querySelector('.profile-header__age').innerText.substring(2))
const name = document.querySelector('.profile-header__name').innerText;
console.log('Just liked', name, age);
if (iteration > 10) {
console.warn('10th iteration reached. We might be stuck here. Let\'s just continue as usual.');
@KristofferK
KristofferK / fruits.html
Last active March 5, 2018 16:31
Example for friend
<!doctype html>
<html>
<head>
<title>Frugt</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<div class="container">
@KristofferK
KristofferK / euclidean-distance.ts
Last active October 23, 2023 19:00
Calculate the euclidean distance using TypeScript. Supports N dimensions.
const calculateDistance = (p: number[], q: number[]) => {
if (p.length != q.length) return -1;
const subtracted = q.map((i, n) => i - p[n]);
const powered = subtracted.map(e => Math.pow(e, 2));
const sum = powered.reduce((total, current) => total + current, 0)
return Math.sqrt(sum);
}
// Three dimension
const p = [2.15, 16.5, 5.6];
@KristofferK
KristofferK / program.cs
Last active February 11, 2018 23:56
Checks if a given array contains the specified item using divide & conquer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{