Skip to content

Instantly share code, notes, and snippets.

View whitehat101's full-sized avatar

Jeremy whitehat101

View GitHub Profile
@whitehat101
whitehat101 / set_yarn_version.sh
Created March 1, 2022 21:28
Set Yarn Version 1/2
# Yarn 1.x
yarn policies set-version <version number>
# Yarn 2.x
yarn set version <version number>
@whitehat101
whitehat101 / iconv-streams.patch.js
Created October 16, 2018 23:04
quick and dirty fix for Webpack and iconv-lite streams
"use strict";
var Buffer = require("buffer").Buffer,
Transform = require("stream").Transform,
iconv = require('iconv-lite');
// == Exports ==================================================================
// module.exports = function(iconv) {
// Additional Public API.
@whitehat101
whitehat101 / refCounter.coffee
Last active October 15, 2018 10:35
JavaScript reference counting (for Blobs w/ URL.createObjectURL / URL.revokeObjectURL)
export default (
create = URL.createObjectURL
free = URL.revokeObjectURL
) ->
map = new Map
retain: (key) ->
if map.has key
data = map.get key
data.count++
@whitehat101
whitehat101 / index.coffee
Last active October 8, 2018 11:14
Web Worker Queue for Uint32s
worker = new Worker 'queued_worker.js'
worker.onmessage = (msg) -> console.log 'Message received from worker', msg.data
worker.onerror = (error) -> console.log 'Error received from worker', error
# arr = new Uint32Array([1,2,3])
# worker.postMessage(arr, [arr.buffer])
# worker.postMessage({ticket: 123})
# worker.postMessage({ticket: 123, head: true})
# uint = new Uint32Array(0xffffff); // 67.1 MB
# uint.forEach((v,i)=>uint[i]=Math.floor(0xffffffff*Math.random()));
@whitehat101
whitehat101 / point_to_line.rb
Created June 16, 2017 10:18
point_to_line / point_to_line_points
# point_to_line
# point: (x0, y0)
# line: ax+by+c=0
def point_to_line x0,y0, a,b,c
(a*x0+b*y0+c).abs / Math.sqrt(a**2+b**2)
end
# point: (x0, y0)
# line: between (x1, y1), (x2, y2)
def point_to_line_points x0,y0, x1,y1, x2,y2
@whitehat101
whitehat101 / .htaccess
Created May 23, 2017 05:14
Let's Encrypt htaccess 301
RedirectMatch 301 ^(?!/\.well-known/acme-challenge/).* https://mydomain.example$0
Alias /.well-known/acme-challenge /var/www/letsencrypt/.well-known/acme-challenge
Alias /.well-known/acme-challenge /var/www/letsencrypt
@whitehat101
whitehat101 / update.sh
Created May 23, 2017 05:12
Capistrano inspired Factorio deploy
VER=0.13.10
cd
god stop factorio-0.13
mkdir factorio-$VER
(
cd factorio-$VER
curl -sL https://www.factorio.com/get-download/$VER/headless/linux64 | tar xz --strip-components=1
ln -s ~/saves saves
)
rm ~/factorio
@whitehat101
whitehat101 / update.sh
Created May 23, 2017 05:11
Capistrano inspired Minecraft deploy
cd ~/releases/v1.31
ln -fs ~/shared/banned-ips.json .
ln -fs ~/shared/banned-ips.json .
ln -fs ~/shared/banned-players.json .
ln -fs ~/shared/ops.json .
ln -fs ~/shared/server.properties .
ln -fs ~/shared/usercache.json .
ln -fs ~/shared/usernamecache.json .
ln -fs ~/shared/whitelist.json .
ln -fs ~/shared/world .
@whitehat101
whitehat101 / README.md
Last active May 12, 2017 11:57
Amatrure Radio (HAM) Extra License Question Pool Analysis

HAM Extra

Extra class (Element 4) Question Pool is effective July 1, 2016 and is valid until June 30, 2020.

notice that:

  • 45% of questions are the longist answer
  • 29% of questions are the shortist answer
@whitehat101
whitehat101 / webRequest.coffee
Created April 24, 2017 01:36
Debugging WebExtension's webRequest
# https://developer.chrome.com/extensions/webRequest
listener = (label) -> (details) -> console.log label, details
[
'onBeforeRequest' # requestBody, blocking
'onBeforeSendHeaders' # requestHeaders, blocking
'onSendHeaders' # requestHeaders
'onHeadersReceived' # responseHeaders, blocking
'onAuthRequired' # responseHeaders, blocking, asyncBlocking
'onResponseStarted' # responseHeaders
'onBeforeRedirect' # responseHeaders