Skip to content

Instantly share code, notes, and snippets.

View danman113's full-sized avatar
🍞

Daniel Berezin danman113

🍞
View GitHub Profile
@danman113
danman113 / KeyRemapComponent.tsx
Created May 16, 2023 04:12
Key Rebind Component
export type KeySet = Set<string>
const KeyListener = ({
defaultText = 'Click Here',
keys,
setKeys
}: { defaultText?: string, keys: KeySet, setKeys: (args: KeySet) => void }) => {
const [prevKeys, setPrevKeys] = useState<KeySet>(new Set())
const [currentKeys, setCurrentKeys] = useState<KeySet>(new Set())
const [listening, setListening] = useState(false)
const prevKeysStr = prevKeys.size <= 0 ? 'Enter Key Combination' : [...prevKeys].join(', ')
@danman113
danman113 / probabilityMap.js
Created November 3, 2020 01:39
Probability Map
class ProbabilityMap {
constructor (map) { // map = {foo: 32, bar: 21}
this.calculateSize = () => {
let count = 0
for (let [,value] of this.set) {
count += value
}
return count
}
this.set = map ? new Map(Object.entries(map)) : new Map()
@danman113
danman113 / echo-cookie.js
Last active June 18, 2020 00:59
echo cookies cross domain
@danman113
danman113 / ie11checker.js
Last active February 28, 2020 01:15
Checks if input javascript files will instantly crash on IE11
#!/usr/bin/env node
const fs = require('fs')
const acorn = require("acorn")
const glob = require('glob')
const getNextCharPosition = (idx, str, offset = 1, matchChar = ' ') => {
let i = idx
while (str[i] !== matchChar) {
i += offset
}
@danman113
danman113 / texturepacker.js
Created January 2, 2020 23:39
~50 Line Texture Packer
const path = require('path')
const fs = require('fs')
const sharp = require('sharp')
const ShelfPack = require('@mapbox/shelf-pack')
const debug = process.env.DEBUG || false
const padding = +process.env.PADDING || 0
const output = process.env.OUTPUT || 'out'
const dir = process.env.DIR || 'images'
const images = fs.readdirSync(dir).map(img => path.join(dir, img))
@danman113
danman113 / markov.js
Last active September 16, 2019 23:00
Markov Chains Done Quick
// @TODO: Read this to improve model http://www.roguebasin.com/index.php?title=Names_from_a_high_order_Markov_Process_and_a_simplified_Katz_back-off_scheme
const rand = (min, max) => ((Math.random() * max) + min) | 0
class ProbabilityMap {
constructor (map) { // map = {foo: 32, bar: 21}
this.calculateSize = () => {
let count = 0
for (let [,value] of this.set) {
count += value
@danman113
danman113 / config.js
Created July 12, 2019 22:33
JWT Example
module.exports = {
secret: 'hellowthisismyskret',
port: process.env.PORT || 9001,
users: [['test', 'tester'], ['daniel', 'wordpass']]
}
let path = require('path')
let HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
entry: './src/index.ts',
output: {
filename: 'out.js',
path: __dirname + '/dist'
},
18:37:01.628 INFO - Launching a Selenium Grid node
18:37:03.266 WARN - error getting the parameters from the hub. The node may end up with wrong timeouts.Connect to 172.17.0.2:4444 [/172.17.0.2] failed: Connection refused
Setting system property webdriver.chrome.driver to /usr/bin/chromedriver
Setting system property jna.debug_load to true
18:37:03.307 INFO - Java: Oracle Corporation 25.03-b03
18:37:03.307 INFO - OS: Linux 4.4.12-boot2docker amd64
18:37:03.322 INFO - v2.53.0, with Core v2.53.0. Built from revision 35ae25b
18:37:03.616 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform LINUX
18:37:03.624 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped: