Skip to content

Instantly share code, notes, and snippets.

View bobbzorzen's full-sized avatar

Leopold Olsson bobbzorzen

View GitHub Profile
@bobbzorzen
bobbzorzen / dev-tmux.sh
Last active December 2, 2022 19:18
Basic script for starting a tmux session with specific windows and execute code in them
#!/bin/sh
tmux new-session -n "Name of window 1" -s "dev" -c "/home/<User>/workspace" -d '<command to run e.g. nano file.txt>'
tmux new-window -n "Name of Window 2" -c "/home/<User>/workspace" '<command to run e.g. nano file.txt>'
tmux next-window # Selects the next window, since we're currently selecting the last window, the next window is the first window
tmux -2 a # now we attach to the newly created session using 256 color mode
#ifndef BINARYSEARCHTREE_H
#define BINARYSEARCHTREE_H
#include <iostream>
using namespace std;
template<typename AnyType>
class BinarySearchTree
{
private:
class Node
{
@bobbzorzen
bobbzorzen / word permutations.js
Created April 30, 2020 16:25
Word permutations
const originalWords = "makes my dick hard";
const wordArray = originalWords.split(" ");
function perm(xs) {
let ret = [];
for (let i = 0; i < xs.length; i = i + 1) {
let rest = perm(xs.slice(0, i).concat(xs.slice(i + 1)));
if (!rest.length) {
ret.push([xs[i]])
} else {
@bobbzorzen
bobbzorzen / calculateRotatedPositions.js
Last active May 13, 2019 12:51
Find the corner position of a rotade rectangle in javascript
// rotation variable is the rotation of the rect in radians
// rectWidth is the width of the rectangle in question
// rectX is the x position of the top left most corner of the rectangle
// rectY is the y position of the top left most corner of the rectangle
const rotatedXDelta = rectWidth * Math.cos(rotation);
const rotatedYDelta = rectWidth * Math.sin(rotation);
const rotatedX = rectX + rotatedXDelta;
const rotatedY = rectY + rotatedYDelta;

Basic RegExp lecture

  • What is RegExp
  • Simple example vs advanced example
  • Character groups
  • Quantifiers
  • Capture groups
  • Re-visit simple example and break it down
  • Re-visit advanced example and break it down
  • How you can use it in your everyday life (Show how vsc can do regex searches to match all etc)
@bobbzorzen
bobbzorzen / RosterAnalysis.md
Last active January 28, 2019 12:30
Roster analysis for the team Klondike Express in Heroes Lounge Div 7 Season 8

Roster Analysis

Players and their main chars

Poerves [Support] (Captain) Twitch: https://www.twitch.tv/poerves

Played during previous matches:

  • Alexstraza (P:5 | W:2 | L:3)
  • Whitemane (P:5 | W:2 | L:3)
  • Deckard (P:1 | W:1 | L:0)
  • Malfurion (P:1 | W:0 | L:1)
@bobbzorzen
bobbzorzen / busHome.js
Created January 24, 2019 14:49
JS bookmarklet for searching jlt for travel home
javascript:(function() {
let d = new Date();
let ch = d.getHours();
let cm = d.getMinutes();
let cY = d.getFullYear();
let cM = d.getMonth();
let cD = d.getDate();
let cd = cY+"-"+cM+"-"+cD;
@bobbzorzen
bobbzorzen / find_point_on_line.js
Created September 10, 2018 12:33
Find a point on a line given a distance from a known point on the line
public findDistanceBetweenPoints(pointA, pointB) {
var a = pointA["x"] - pointB["x"]
var b = pointA["y"] - pointB["y"]
var length = Math.sqrt(a*a + b*b)
return length
}
public findSlope(pointA, pointB) {
var a = pointB["y"] - pointA["y"]
def find_diagonal_match(matrix, y, x, searchLeft=False):
negator = -1 if searchLeft else 1
match = True
if len(matrix) < y+5 or (len(matrix[y]) < x+5 and x-5 > 0):
match = False
for i in range(1, 5):
if not match:
break
newX = x + (negator*i)
match = matrix[y+i][newX] == matrix[y][x]
tArgs = {...}
local rows = tonumber(tArgs[1])
local columns = tonumber(tArgs[2])
local enderchest_index = tonumber(tArgs[3] or -1)
y = 0
print(string.format("Filling %s by %s area with refill chest on index %s", rows, columns, enderchest_index))
function refillFromEnderchest()
turtle.select(enderchest_index)