Skip to content

Instantly share code, notes, and snippets.

@N0taN3rd
N0taN3rd / typescript-snippets.ts
Created June 10, 2021 18:01
Just some typescript snippets I have come up with that I would like to use elsewhere
/**
* Extracts the type of the items in type T which is an array/set of type U - we want the type U.
* Aka un-boxes the type U in typescripts generic array T = Array<U>.
* If the supplied type is not an array then that type is returned as is
* See the example for more details
*
* @example
* type ArrayItemType = Unboxed<string[]>
* // ArrayItemType = string
*
@N0taN3rd
N0taN3rd / index.html
Created October 23, 2018 00:13
something
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Still Drinking Gin And Juice</title>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
border: 0;
var url = `${location.protocol}/${wbinfo.proxy_magic}/proxy-fetch/https://www.google.com`
var res = await fetch(url)
console.log(await res.text())
@N0taN3rd
N0taN3rd / gevent-import.txt
Created July 9, 2018 22:49
PYTHONPATH=<path to pywb dir>pywb/ python -v -u pywb/apps/cli.py --live &> out.txt
# /home/john/PycharmProjects/pywb/.venv/lib/python3.6/site-packages/gevent/__pycache__/__init__.cpython-36.pyc matches /home/john/PycharmProjects/pywb/.venv/lib/python3.6/site-packages/gevent/__init__.py
# code object from '/home/john/PycharmProjects/pywb/.venv/lib/python3.6/site-packages/gevent/__pycache__/__init__.cpython-36.pyc'
# /home/john/PycharmProjects/pywb/.venv/lib/python3.6/site-packages/gevent/__pycache__/_config.cpython-36.pyc matches /home/john/PycharmProjects/pywb/.venv/lib/python3.6/site-packages/gevent/_config.py
# code object from '/home/john/PycharmProjects/pywb/.venv/lib/python3.6/site-packages/gevent/__pycache__/_config.cpython-36.pyc'
# /home/john/PycharmProjects/pywb/.venv/lib/python3.6/site-packages/gevent/__pycache__/_compat.cpython-36.pyc matches /home/john/PycharmProjects/pywb/.venv/lib/python3.6/site-packages/gevent/_compat.py
# code object from '/home/john/PycharmProjects/pywb/.venv/lib/python3.6/site-packages/gevent/__pycache__/_compat.cpython-36.pyc'
import 'gevent._compat' # <_
@N0taN3rd
N0taN3rd / dumpWarc.js
Created June 18, 2018 18:00
Dump warc
const Parser = require('node-warc')
const filenamifyURL = require('filenamify-url')
const fs = require('fs-extra')
const path = require('path')
const parser = new Parser('<path-to-warcfile>')
class WARCMap {
constructor () {
this._requests = new Map()
from pywb.warcserver.index.cdxobject import CDXObject
def read_cdxj(path):
with open(path, 'rb') as cdxjin:
for line in cdxjin:
cdx = CDXObject(line)
if 'html' in cdx.get('mime') and "200" == cdx.get('status'):
print(cdx.get('url'))
@N0taN3rd
N0taN3rd / README.md
Last active June 6, 2018 15:13
WADL Presentation
@N0taN3rd
N0taN3rd / nukeBloggerClickTrap.js
Created April 27, 2018 20:29
Remove the annoying blogger preview click trap element.
// what substring in the URL indicates to us that we are editing the blog post
let isPostPreview = 'post-preview'
// the query selector to use for referencing the click trap element
let querySelectorForClickTrap = '.blogger-clickTrap'
// how long should the delay be before we attempt to remove the click trap element
let wait = 3000
if (window.location.href.indexOf(isPostPreview) !== -1) {
setTimeout(() => {
console.log('nukeClickTrap')
let it = document.querySelector(querySelectorForClickTrap)
@N0taN3rd
N0taN3rd / check_margins.sh
Created April 27, 2018 08:16
Appease the margin police at all costs
#!/usr/bin/env bash
####
# Original version of this file was created by Dr. Chuck Cartledge
# as a make file and can be found in his WS-DL blog post:
# https://ws-dl.blogspot.com/2014/07/2014-0-7-2-ode-to-margin-police-or-how.html
####
#### Set these variables to match your setup
CHECK="msThesis"
@N0taN3rd
N0taN3rd / README.md
Created April 26, 2018 01:35
Lets build a site using gatsbyjs