Skip to content

Instantly share code, notes, and snippets.

View burdiuz's full-sized avatar
💭
isotope muffin

Oleg Galaburda burdiuz

💭
isotope muffin
View GitHub Profile
@burdiuz
burdiuz / SteamFineDiscounts.js
Last active August 21, 2023 09:06
user-scripts for Steam Store
/* Filters items on Steam Store search page to display only fine discounted.
Steam Sale fine discounts
1. Open [Steam Search page](http://store.steampowered.com/search/?sort_by=Price_ASC&specials=1)
2. Check to be logged in, script will hide owned games
3. Open Browser console with Ctrl+Shift+I for Chrome(Console tab), Ctrl+Shift+K for Firefox, F12 for IE.
4. Paste code from [search-userscript.js](https://raw.githubusercontent.com/burdiuz/js-steam-fine-discounts/master/search-userscript.js) into console and press Enter
5. Wait for fine discounts to be found and displayed
*/
(function() {
var categories = '998,994,21,996,997'; // 998 - games
@burdiuz
burdiuz / metro.config.js
Created December 5, 2019 19:50
Metro bundler config as replacement for rn-nodeify, substitutes nodejs modules for dependencies
/**
* Metro configuration for React Native
* https://github.com/facebook/react-native
*
* @format
*/
const path = require('path');
module.exports = {
import { forwardRef } from "react";
import { HorizontalAlignment, VerticalAlignment } from "./alignments";
import { getAlignmentClassNames } from "./useAlignmentClassNames";
const PopoverAlignment = (
{
children = () => null,
horizontal = HorizontalAlignment.LEFT,
vertical = VerticalAlignment.BOTTOM,
},
@burdiuz
burdiuz / ByteArray.js
Last active May 29, 2022 13:08
Simple wrapper over Uint8Array with a playhead
class ByteArray {
constructor(buffer, initPosition = 0) {
this.buffer = typeof buffer === "number" ? new Uint8Array(buffer) : buffer;
this.position = initPosition;
}
get bytesAvailable() {
return this.buffer.length - this.position;
}
@burdiuz
burdiuz / .npmignore
Last active January 12, 2022 11:17
@actualwave/promised-timeout - Function that returns a Promise which will be resolved on timeout
source.js
@burdiuz
burdiuz / LRUCache.js
Last active November 28, 2021 07:29
Simple Least Recently Used Cache implementation
const getNextIndex = (() => {
let index = 1;
const lastSafe = ((1 << 31) >>> 0) - 1;
return () => {
index += 1;
if (index >= lastSafe) {
index = 1;
}
@burdiuz
burdiuz / queue.js
Last active November 28, 2021 07:23
Simple Queue implementation via bi-directional linked list
class QueueNode {
constructor(value, prev = null, next = null) {
this.value = value;
this.insert(prev, next);
}
insert(prev, next) {
this.prev = prev;
this.next = next;
@burdiuz
burdiuz / README.md
Last active November 21, 2021 16:00
Breadth-first search algorithm to find shortest path

BFS applied to a grid to find shortest path

Queue implementation used here is published as separate gist queue.js.

When loaded it draws path from top left to bottom right corner. White cells are empty and black -- walls. Clicking on any cell inverts it(empty > wall and wall > empty) and forces path redraw. For now or recreates Adjacency List every time. Sometimes it cannot find path from start to the end, in this case just refresh page.

@burdiuz
burdiuz / bit-ajacency-matrix.js
Last active November 21, 2021 09:42
Adjacency matrix implemented using UInt8Array -- every bit represents an edge
const getPosition = (rowLength) => (col, row) => row * rowLength + col;
const getSlotIndex = (rowLength) => {
const pos = getPosition(rowLength);
return (col, row) => pos(col, row) >> 3;
};
const getInSlotPosition = (rowLength) => {
const pos = getPosition(rowLength);
return (col, row) => pos(col, row) % 8;
@burdiuz
burdiuz / karatsuba.js
Created November 13, 2021 17:25
Karatsuba multiplication in JS
const karatsuba = (x, y, l) => {
if (l <= 2) {
return x * y;
}
const l_2 = l / 2n;
const half = 10n ** l_2;
const a = x / half;
const b = x % half;