Skip to content

Instantly share code, notes, and snippets.

@jcable
jcable / gist:8ee152e3f5a05a47b286029e9e654984
Last active September 10, 2023 17:39
Functions to discover the dependencies from a hoisted lock file for use in an npm pack context
async function filesFromTarball(pkg, logger, omitDependencies) {
const all = await decompress(`${pkg.name.replace('/', '-').replace(/^@/, '')}-${pkg.version}.tgz`);
logger.log(`Extracted compiled package from ${pkg.name}-${pkg.version}.tgz`);
let wanted = all;
if (omitDependencies) {
wanted = all.filter((f) => !f.path.startsWith('package/node_modules'));
}
const files = wanted.map(({ data, path }) => ({ data, path: path.replace(/^package\//, '') }));
logger.log(`Got ${files.length} local files`);
return files;
@jcable
jcable / password.js
Last active May 8, 2020 08:21
Drupal 7 password.inc translation to javascript
const crypto = require('crypto');
var md5 = require('md5');
/**
* @file
* Secure password hashing functions for user authentication.
*
* Based on the Portable PHP password hashing framework.
* @see http://www.openwall.com/phpass/
*
* An alternative or custom version of this password hashing API may be
@jcable
jcable / getquestions.sh
Last active February 9, 2020 12:02
Jotform update fields
#!/bin/sh
# get the current set of questions
curl 'https://eu-api.jotform.com/form/200321541644039/questions?apiKey='$JOT_API_KEY|jq . > new_boat.json
<!DOCTYPE html>
<html>
<head>
<style>
div.b {
clip-path: inset(50px 20px 300px 30px);
}
div.a {
font-family: Sans-Serif;
@jcable
jcable / index.html
Created January 7, 2018 10:22
Sample Google Cast CAF Receiver demonstrating cloud queues
<html>
<head>
<script type="text/javascript"
src="//www.gstatic.com/cast/sdk/libs/caf_receiver/v3/cast_receiver_framework.js">
</script>
</head>
<body>
<cast-media-player id="player"></cast-media-player>
<script>
const context = cast.framework.CastReceiverContext.getInstance();
@jcable
jcable / gist:31afe705542532b5dcfdfe4eeeaaf198
Created February 24, 2017 14:51
Gstreamer showing caps
export GST_DEBUG=GST_CAPS:5
gst-launch-1.0 filesrc location=src/test/resources/test.wav ! wavparse ! wavenc ! filesink location=test.wav
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:00.004597758
Setting pipeline to PAUSED ...
@jcable
jcable / test.php
Created December 15, 2015 18:00
submit a form with a blob
<html>
<head>
<meta charset="UTF-8">
<script>
function init() {
var form = document.getElementById('f');
if(form) {
form.addEventListener('submit', function(event) {
if(form.ajax.checked) {
var formData = new FormData();
@jcable
jcable / monitordir.tcl
Created February 14, 2015 16:53
Monitor a directory and complain if there are any entries older than a specified number of seconds
# Monitor a directory for files older than a specified number of seconds
# Usage example: tclsh monitordir.tcl \\fgbsamfvcs1n42\N42_Ex18_PremBulltoFM\bbc_minute 120
proc monitordir {path max_age} {
if {![file isdirectory $path]} {
puts stderr "$path not found or is not a directory"
exit 1
}
set files [glob -nocomplain -directory $path *]
# if the folder is empty all is OK