Skip to content

Instantly share code, notes, and snippets.

View olafurw's full-sized avatar

Ólafur Waage olafurw

View GitHub Profile
@olafurw
olafurw / remove_old_videos.js
Created February 7, 2020 18:20
Tampermonkey thing that will remove old recommended videos from youtube frontpage
// ==UserScript==
// @name YouTube Recommended Remove Old Videos
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Removes old videos from YouTube's recommended page
// @author @OlafurW
// @include https://www.youtube.com/*
// @grant none
// @require https://code.jquery.com/jquery-3.4.1.min.js
// ==/UserScript==
@olafurw
olafurw / derangements.cpp
Last active July 31, 2017 19:23
Derangements - Monte Carlo - Multi Card Match
#include <random>
#include <map>
#include <vector>
#include <iostream>
#include <iomanip>
unsigned int
Disarrange(
const unsigned int aMax,
std::mt19937& aGenerator,
bool
Meow::Foo(
const int aBar,
const std::string& aCrazy,
float& aOutGrr)
{
}
class Meow
{
public:
Meow();
int myWhateverValue;
const public: // const to the public, could also be "public const:" for parsing reasons
int myDelicateState;
int main()
{
int x = 4; // vanilla variable
int& y = x; // reference to the one above
int* z = &x; // pointer, without having to teach them about malloc or new, that can come later, just complicates things at first
return 0;
}
#include <iostream>
int main()
{
int height = 4;
int width = 5;
std::cout << height << " " << width << std::endl;
return 0;
double Foo(
const double aBar,
const double aBaz)
{
return aBar + aBaz;
}
int main()
{
const auto result = Foo(1.2, 2.3);
# Create 3 files, A.txt, B.txt, C.txt with your dice rolls, you can use https://www.random.org/integers/
# Make Magic(a,b,c) do the formula you think works.
# It will return how often each dice value was rolled
# A fair formula would result in equal results in each bracket for each dice
def FileToArray(aFilename):
with open(aFilename, 'r') as myFile:
return myFile.read().splitlines()
return []
@olafurw
olafurw / standuphash.py
Last active January 12, 2016 08:49
The A4 Paper Puzzle
# This is regarding https://www.youtube.com/watch?v=SOgn6J12NWE
import math
def FiveSquareRoot(aNumber):
return math.sqrt(math.sqrt(math.sqrt(math.sqrt(math.sqrt(aNumber)))))
def FirstSix(aString):
decimalStr = aString.split(".")[1]
return decimalStr[:6]
@olafurw
olafurw / gist:c2d33fb5336f15fa0745
Created March 14, 2015 21:28
Repetitive hashing collision
import hashlib
iteration_length = 10
hash_length = 5
set_length = pow(16, hash_length)
fs = set()
for i in range(0, set_length):
x = format(i, 'x').zfill(hash_length)
fs.add(x)