Skip to content

Instantly share code, notes, and snippets.

View davidhq's full-sized avatar
🎯
Focusing

davidhq

🎯
Focusing
View GitHub Profile
@davidhq
davidhq / gist:3556485
Created August 31, 2012 17:51
Unpermute (reverse Burrows-Wheeler transform)
# calculates BW(T)
def bw(t):
m = sorted(t[-i:] + t[:-i] for i in range(len(t)))
return "".join(m[i][len(t)-1] for i in range(len(t)))
# for a given string return index with nth occurence of char
def n_occurence_index(string, char, n):
vector = [string[:index+1].count(char) for index in range(0, len(string))]
return vector.index(n)
@davidhq
davidhq / youtube_blacklist.js
Last active February 17, 2024 22:00
YouTube Blacklist
const DISABLE_CHANNELS = ['JMMates', 'Kotte Animation', 'Oddly Viral', 'Mr. Chaliche', 'Like Nastya', 'Like Nastya Show', 'Pear Vlogs', 'Smile Family', 'HowToBasic', 'MrBeast', 'Decija Zona', 'Ha Hack', 'Vlad un Niki', 'Little Panda', 'ReactingToGaming', 'Teen-Z', 'Troom Troom PT', 'Master Thunder', 'LankyBox', 'AnythingAlexia', 'Omco'];
const FORBIDDEN_WORDS = [
'!!!',
'\?\?\?',
'$',
'€',
'ë',
'ö',
'r\.i\.p',
@davidhq
davidhq / excel_magic.js
Last active October 8, 2023 02:03
Execute excel workbooks through node.js
const FormulaParser = require('hot-formula-parser').Parser;
const parser = new FormulaParser();
const Excel = require('exceljs');
const workbook = new Excel.Workbook();
function getCellResult(worksheet, cellLabel) {
if (worksheet.getCell(cellLabel).formula) {
return parser.parse(worksheet.getCell(cellLabel).formula).result;
} else {
@davidhq
davidhq / kids_censor_youtube.md
Last active January 14, 2023 18:16
For kids — How to remove YouTube shorts, all live videos, videos based on keywords and censor specific channels 😈 🤘

Improve YouTube

Scripts that is injected into YouTube website on the frontend via Chrome extension and does the following ↴

  1. Remove YouTube Shorts
  2. Remove all Live videos
  3. Disable any channel which matches a given list
  4. Remove all videos where title or channel name includes any of listed forbidden words
  5. Carpet-ban all videos which include specific 'foreign' characters (because filtering on english words is not possible)
@davidhq
davidhq / mpv_install.md
Last active August 16, 2022 03:22
mpv ◈ Media Player binary -- Install macOS / linux / windows
// SPDX-License-Identifier: MIT
pragma solidity 0.8.12;
contract StringConcater {
// only in 0.8.12 and above
function concatStringsNewWay() public pure returns(string memory) {
string memory hiMom = "Hi Mom, ";
string memory missYou = "miss you.";
return string.concat(hiMom, missYou);
# Setup private variables (only callable from within the contract)
struct Funder :
sender: address
value: uint256
funders: HashMap[int128, Funder]
nextFunderIndex: int128
beneficiary: address
deadline: public(uint256)
from vyper.interfaces import ERC20
totalEthQty: public(uint256)
totalTokenQty: public(uint256)
# Constant set in `initiate` that's used to calculate
# the amount of ether/tokens that are exchanged
invariant: public(uint256)
token_address: ERC20
owner: public(address)
# Window toggling (switch back and forth between last two focused windows) for Sublime
# Add to Key Bindings - User:
# {
# "keys": ["f3"],
# "command": "toggle_windows"
# },
# then put toggle_windows.py (this file) into ~/Library/Application Support/Sublime Text 3/Packages/User
import os
import sublime
@davidhq
davidhq / seedprotect.js
Last active September 26, 2020 00:02
seedprotect.js
const crypto = require('crypto');
function lpad(str, padString, length) {
while (str.length < length) str = padString + str;
return str;
}
// converts string '1100' to integer 12
function binaryToByte(bin) {
return parseInt(bin, 2);