Skip to content

Instantly share code, notes, and snippets.

class CrazyShufflingList<T> : IList<T>
{
private List<T> _internal = new List<T>();
private Random _random = new Random();
public T this[int index]
{
get
{
return _internal[index];
@PetrChudoba
PetrChudoba / HashSetWithRandom.cs
Last active March 21, 2018 02:57
Hashset with efficient GetRandom method
class HashsetWithRandomSampling<T>
{
Dictionary<T, int> _indices = new Dictionary<T, int>();
List<T> _items = new List<T>();
Random _random = new Random();
public void Add(T item)
{
if (_indices.ContainsKey(item))
@PetrChudoba
PetrChudoba / CodeRunner_Settings_WSL.md
Last active August 25, 2022 23:39
Visual Studio Code - CodeRunner - Run shellscripts with WSL.

Executor for shellscript

We need to convert Windows path to WSL path: C:\Users\user\Documents\script.sh -> /mnt/c/Users/user/Documents/script.sh

 "shellscript": "bash $('/mnt/' + $fullFileName.Substring(0,1).ToLower() + $fullFileName.Substring(2).Replace('\\','/') )",

Full settings.json

// Place your settings in this file to overwrite the default settings
@PetrChudoba
PetrChudoba / reboot_to_kodi.sh
Last active January 18, 2017 16:53
Reboot the raspberry to the LibreELEC- Kodi, by modifying the NOOBS configuration file.
#!/bin/bash
# Reboot the raspberry to the LibreELEC- Kodi, by modifying the NOOBS configuration file.
# TODO: Check if already mounted
# Mount NOOBS partition (partition 5)
mount -t auto /dev/mmcblk0p5 /mnt/NOOBS/
# Change the partition in the confing file (kodi: partition=6, raspbian : partition=8)
sed -i '/^default_partition_to_boot/s/=.*/=6/' /mnt/NOOBS/noobs.conf