Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import importlib.metadata
import importlib.util
import pathlib
import site
import sys
if len(sys.argv) != 2:
print("Usage: python find_distribution.py <module>")
exit()
#!/usr/bin/env node
import { chromium } from "playwright";
import { readFileSync } from "node:fs";
import { once } from "node:events";
async function main() {
const browser = await chromium.launch({ headless: false });
try {
const cookies = await readCookies("cookies.json");
const { Session } = require('inspector');
/**
* @param task {() => Promise<void>}
* @returns {import('inspector').Profiler.Profile}
*/
async function runProfile(task) {
const session = new Session();
session.connect();
try {
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 p = (2.0*fragCoord.xy-iResolution.xy)/iResolution.y;
// width
float wi = 0.5 + 0.3*cos( iTime + 2.0 );
vec2 g = abs(p - wi * round(p/wi));
float d = min(g.x, g.y);
// append at end of ember-cli-build.js
(() => {
const Instrumentation = require("ember-cli/lib/models/instrumentation");
let count = 0;
const start = Instrumentation.prototype.start;
Instrumentation.prototype.start = function hookedStart(...args) {
count++;
console.profile(args[0] + count);
return Reflect.apply(start, this, args);
/* eslint-env node */
const Project = require('ember-cli/lib/models/project');
const CLI = require('ember-cli/lib/cli/cli');
const UI = require('console-ui');
const ui = new UI();
const cli = new CLI({ ui });
const project = Project.closestSync(__dirname, ui, cli);
const tree = require(`${project.root}/ember-cli-build`)({ project });
module.exports = tree;
@krisselden
krisselden / main.rs
Created May 5, 2021 18:40
Chrome Devtools Protocol with Rust
use libc;
use serde_json::{json, Value};
use std::error;
use std::ffi::OsString;
use std::fs::File;
use std::io;
use std::io::prelude::*;
use std::io::{BufReader, BufWriter};
use std::os::unix::io::RawFd;
use std::os::unix::prelude::*;
const log = (() => {
const start = Date.now();
return (msg, ...args) => {
const elasped = Date.now() - start;
console.log(`%os ${msg}`, elasped / 1000, ...args);
};
})();
async function doAsyncTask(name) {
log("started %o", name);
@krisselden
krisselden / webpack.config.js
Last active March 31, 2021 03:14
Embroider App Webpack Dev Server Config
/* eslint-env node */
const { Webpack } = require("@embroider/webpack");
const variant = {
name: "dev",
runtime: "browser",
optimizeForProduction: false,
};
const webpack = new Webpack(
__dirname,
__dirname + "/dist",
@krisselden
krisselden / profile.js
Created February 19, 2021 01:09
Profile node with child processes
/* eslint-env node */
const { Session } = require('inspector');
const fs = require('fs');
const captureExit = require('capture-exit');
captureExit.captureExit();
/** @param exitPromise {Promise<void>} */
async function runProfile(exitPromise) {