Skip to content

Instantly share code, notes, and snippets.

View dotproto's full-sized avatar

Simeon Vincent dotproto

View GitHub Profile
@dotproto
dotproto / background.js
Last active April 9, 2024 23:21
CORS Test (Chrome, Firefox) - This extension will begin performing HTTP requests against a bespoke test server immediately after installation. To view the results, open a devtools session for the extension's background context and look through the console output.
globalThis.browser ??= globalThis.chrome;
let testCounter = 0;
let corsTest = async (
{
client: {
forcePreflight = false,
mode = undefined,
},
server: {
@dotproto
dotproto / scratchpad.js
Last active February 17, 2024 15:31
Simple in-browser scratch pad with bookmark-based "saving." To use, copy and paste the this gist into your URL bar. Once loaded, you can save by dragging the link in the top left corner onto your bookmarks bar.
data:text/html,
<!-- See https://gist.github.com/svincent/699c0a9027bb6bc8298b076e638718f1/edit -->
<a id="link" title="Drag this link onto your bookmark bar to save!">save scratchpad</a>
<div id="editor" contenteditable>Type something here!<div>To save, drag the link in the top right onto your bookmark bar.</div></div>
<style>
:root {
--line-height: 1.5em;
}
* {

Introducing Gloggy

Gloggy is a super simple (albiet terribly named) blogging system that runs on top of GitHub's Pages and Gists features.

@dotproto
dotproto / gloggy_fork.md
Last active February 14, 2024 01:55 — forked from dotproto/introducing_gloggy.md
POST: This is a test of a multi-line gist description. This is totally a hack. I'm sorry GitHub.

Introducing Gloggy

Gloggy is a super simple (albiet terribly named) blogging system that runs on top of GitHub's Pages and Gists features.

@dotproto
dotproto / include.js
Last active February 14, 2024 01:55
Module-root relative file includes for Node.js
var fs = require('fs');
var path = require('path');
var parentModulePath = path.dirname(module.parent.filename);
// Recursively traverse up a given path tree checking for a file's existence.
function rstat(dir, filename, endPath) {
// End the search at endPath if provided, otherwise default to root
endPath = endPath || path.resolve('/');
var target = path.join(dir, filename);
@dotproto
dotproto / block-1.js
Created July 28, 2014 23:40
This is only a test
(function() {
console.log("You're the best around");
console.log("Nothing's ever gonna keep you down");
})()
@dotproto
dotproto / apply.js
Last active February 14, 2024 01:55
Function application as a service
function buildApply() {
var args = Array.prototype.slice.call(arguments, 0);
var fn = args.shift();
// proxy function
return function bindProxy() {
var proxyArgs = Array.prototype.slice.call(arguments, 0);
return fn.apply(null, args.concat(proxyArgs));
}
}
@dotproto
dotproto / getPushIdTimestamp.js
Last active February 14, 2024 01:54
Convert a Firebase Push ID into Unix time (https://gist.github.com/mikelehen/3596a30bd69384624c11/)
var getPushIdTimestamp = (function getPushIdTimestamp() {
var PUSH_CHARS = '-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
return function getTimestampFromId(id) {
var time = 0;
var data = id.substr(0, 8);
for (var i = 0; i < 8; i++) {
time = time * 64 + PUSH_CHARS.indexOf(data[i]);
}
@dotproto
dotproto / example.js
Last active February 14, 2024 01:54
Retrieve a list of custom for your Angular module
var deps = require('./getModuleDeps');
console.table(deps('myModule'));
/* Example output (ASCII-fied)
--------------------------------------------------------------
| (index) | provider | type | name |
|---------|--------------------|-------------|---------------|
| 0 | "$compileProvider" | "directive" | "myDirective" |
@dotproto
dotproto / List.js
Last active February 14, 2024 01:54
An extension of Array with some additional helper methods I wanted.
function List () {}
List.prototype = []
List.prototype.constructor = List
List.prototype._return = function _return (val) {
if (val.length <= 1)
val = val[0]
return val
}