Skip to content

Instantly share code, notes, and snippets.

@Sohamsk
Sohamsk / graph_colouring_backtracking.py
Last active May 4, 2024 16:23
Solving backtracking problem
def is_safe(graph, colours, colour, current):
neighbours = graph[current]
for neighbour in neighbours:
if colour == colours[neighbour - 1]:
return False
return True
def graph_traversal(graph, colours, vertices, current):
if current == vertices + 1:
return True
@Sohamsk
Sohamsk / djikstra.py
Last active May 4, 2024 16:23
This gist is meant to store code related to greedy algorithms
import heapq
from typing import List
def djikstra(graph_inner, starting, vertices) -> List:
pq = []
dist = [float('inf') for i in range(vertices)]
dist[starting] = 0
print(dist)
heapq.heappush(pq, [0, starting])
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Sohamsk
Sohamsk / Astar.py
Last active May 4, 2024 16:22
Solving 8 puzzle problem using A star algorithm.
class Node:
def __init__(self, data: list, level, f_val):
self.data = data
self.level = level
self.f_val = f_val
def generate_children(self):
children = []
values = [[0, 1], [1, 0], [-1, 0], [0, -1]]
row, col = self.find()
@noseratio
noseratio / TaskSchedulerAwaiter.cs
Created September 16, 2020 11:29
Continue on the specified task scheduler, which becomes the current one
// by @noseratio
#nullable enable
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
namespace Noseratio.Experimental
@gokulkrishh
gokulkrishh / media-query.css
Last active May 4, 2024 16:17
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
/* CSS */
@astamicu
astamicu / Remove videos from Youtube Watch Later playlist.md
Last active May 4, 2024 16:14
Script to remove all videos from Youtube Watch Later playlist

UPDATED 22.11.2022

It's been two years since the last update, so here's the updated working script as per the comments below.

Thanks to BryanHaley for this.

setInterval(function () {
    video = document.getElementsByTagName('ytd-playlist-video-renderer')[0];

 video.querySelector('#primary button[aria-label="Action menu"]').click();
@nikolovlazar
nikolovlazar / keybindings.json
Last active May 4, 2024 16:14
VSCode key bindings to navigate like Neovim
[
// Navigation
{
"key": "ctrl-h",
"command": "workbench.action.navigateLeft"
},
{
"key": "ctrl-l",
"command": "workbench.action.navigateRight"
},
@jmarhee
jmarhee / harvester-boot.sh
Created May 1, 2024 17:24
Boots a two-node Harvester cluster.
#!/bin/bash
CLUSTER_TAG=harvester-$(openssl rand -hex 6)
ISO=/var/lib/libvirt/images/harvester-v1.3.0-amd64.iso
for i in {1..2}; do \
VM_NAME=$(openssl rand -hex 4); \
sudo qemu-img create /var/lib/libvirt/images/${CLUSTER_TAG}-${VM_NAME}-ROOT_VOL.img 180G; \
sudo qemu-img create /var/lib/libvirt/images/${CLUSTER_TAG}-${VM_NAME}-DATA_VOL.img 250G; \
sudo virt-install \

Install Elemental with virt-install on KVM

Using virt-install to install SUSE Elemental on KVM.

Prerequisites

When creating your Machine Registration Endpoint in the Rancher UI, ensure that registration.emulated-tpm-seed is set to -1, if you plan to add more than a single machine using the ISO you will be building.

For example: