Skip to content

Instantly share code, notes, and snippets.

@chandlerprall
chandlerprall / gist:c040d997c1fa1b74a6718a126a41526c
Created April 2, 2023 01:43
I asked ChatGPT for a Greek tragedy about a cyber security threat hunter setting up a honeypot
ACT I, SCENE I
[A dark and shadowy room. A lone figure, ALEX, sits at a computer screen, typing frantically. A soft blue glow illuminates their face.]
ALEX:
[typing] "And now, my honey pot is set, a trap to catch the cyber thief. Their malware will be snared and caught, their infiltration brief."
[Enter KIM, a fellow cyber security expert, looking concerned.]
KIM:
@chandlerprall
chandlerprall / gist:b0f9c94917775f4691c1504d988d7984
Created March 25, 2023 04:32
I asked chatgpt for a business case of console.log
Prompt:
Given this JavaScript code, write a business case, mission statement, and path to profitability:
export const log = arg => console.log(arg)
Response:
Business Case:
The logging function in JavaScript is a critical component in software development. It helps developers to debug and monitor their code by providing visibility into how the program is running. The exportable log function is a simple, yet powerful way to log messages to the console in JavaScript. There is a market for this type of utility, and developers are willing to pay for a reliable logging tool.
@chandlerprall
chandlerprall / gist:0667ec5bbbdc0d3a615ffe50f8a10ab1
Last active February 11, 2021 22:16
writing a remark 13 variable plugin
// reference plugin:
// https://github.com/remarkjs/remark-gfm/blob/main/index.js
// which wraps:
// https://github.com/micromark/micromark-extension-gfm-strikethrough/blob/56aef3a974c1b9baee72279e93f9c1fe7205a9af/index.js#L23
const remark = require('remark');
const Compiler = (tree) => {
return tree;
};
import Propagate from './propagate';
describe('Propagate', () => {
describe('value storage & looking', () => {
it('stores a single value for lookup', () => {
const propagate = new Propagate();
propagate.set('mykey', 'myvalue');
expect(propagate.get('mykey')).toBe('myvalue');
});
function doSomething(config) {
var result = {};
if (config.enableA) {
... 10 lines of code ...
result.A = {};
}
if (config.enableB) {
... 15 lines of code ...
result.B = {};
// myFunc will be executed asynchronously after the initial promise resolved
somePromise.then(myFunc)
// event if the originating promise doesn't do anything asynchronously
function quickPromise() {
// this function returns a promise that immediately resolves with "hello world"
return new Promise(resolve => {
resolve('hello world');
});
}
{
"name": "pkg-a",
"version": "1.0.0"
}
var Immutable = require('immutable');
Immutable.Map.Empty = new Immutable.Map();
var map = new Immutable.Map({test: 'ing'});
var start = Date.now();
for (var i = 0; i < 10000000; i++) {
var thing = map.get('test');
}
var end = Date.now();
console.log('baseline', end - start);
var foo = new THREE.Object3D();
foo.quaternion.set( 0, 1, 0, 1 ).normalize();
var direction = new THREE.Vector3( 1, 0, 0 );
direction.applyQuaternion( foo.quaternion );
console.log( direction.x + ',' + direction.x + ',' + direction.z ); //0,0,-0.9999999999999998
wm = new WeakMap();
gc(); // Mark-sweep 2.6 (40.3) -> 2.2 (40.3) MB
// Starting memory usage is 40.3 MB
keys = [];
for ( i = 0; i < 1000000; i++ ) {
var key = {};
keys.push( key );
wm.set( key, true );