Skip to content

Instantly share code, notes, and snippets.

@jwalton
jwalton / fluent-bit.conf
Created January 12, 2022 18:10
Fluent-bit playground
[SERVICE]
flush 5
log_level info
daemon off
parsers_file parsers.conf
[INPUT]
Name tail
Path /test.log
read_from_head true
@jwalton
jwalton / pdf2jpg2pdf.sh
Created May 24, 2021 17:37
Convert a PDF of JPGs to JPGs, recompress them, and then back to PDF.
# Launch a fresh VM
docker run --rm -it -v `pwd`:/mount ubuntu
# Extract PDF to JPGs
cd /mount
apt-get update
apt-get install poppler-utils
pdfimages -j file.pdf fileprefix
mkdir extract
mv *.jpg extract
@jwalton
jwalton / main_benchmark_test.go
Last active November 8, 2023 14:04
Gawk Benchmark
package main
import (
"testing"
"github.com/fatih/color"
"github.com/jwalton/gchalk"
"github.com/logrusorgru/aurora"
"github.com/mgutz/ansi"
"github.com/muesli/termenv"
@jwalton
jwalton / prefixFormat.ts
Created June 24, 2020 20:23
Winston Formatters
import * as path from 'path';
export interface PrefixFormatOptions {
basepath?: string;
}
/**
* This is a debug format, used to prefix the message with tags and filenames.
*
* This copies values to `message`, and strips values out of the `info` so
@jwalton
jwalton / useWhyRender.tsx
Created June 18, 2020 16:00
A react hook to figure out why a component is rendering
/* tslint:disable:no-console */
import ld from 'lodash';
import React from 'react';
/**
* Use this hook to figure out why a React component is re-rendering.
* It will log if any properties in `props` have changed. You should
* also pass any state variables into `props` as well.
*
import * as http from 'http';
import onFinished from 'on-finished';
/**
* Create a middleware that logs all requests.
*
* @param log - Logger to log to.
* @param [options] - Options.
* @param [options.excludeUrls] - An array of endpoints which should not be
@jwalton
jwalton / index.ts
Created March 29, 2019 13:52
webpackMiddleware
import * as express from 'express';
import { createRouter } from './routes';
import translations from './translations';
const WEBPACK_AVAILABLE = (() => {
try {
require('webpack');
return true;
} catch (err) {
return false;
#!/usr/bin/env bash
# Adapted from http://scottwb.com/blog/2012/07/14/merge-git-repositories-and-preseve-commit-history/
#
# This is a script for archiving old private repos into an `attic` repo. To use, fill in the `ACCOUNT`
# variable below, then add this script to your "attic" repo, then just `./archive.sh [reponame]` from
# your cloned attic repo. This will take the contents of "reponame" and copy them into a subdirectory in
# attic named "reponame", preserving history. Note that the original repo is not modified in any way
# (we clone it to /tmp/reponame and don't push anything) and this script doesn't auto-push your attic
# repo, so if it all goes horribly wrong, it's very easy to recover.

A Dashing widget which shows an image.

To use, in your dashboard.erb file:

<li data-row="1" data-col="1" data-sizex="3" data-sizey="2">
  <div data-id="picture" data-view="BigImage" data-image="http://i.imgur.com/JycUgrg.jpg"
    style="background-color:transparent;"
    data-max="true"
  ></div>
@jwalton
jwalton / FlyingWidgets.md
Last active October 13, 2022 07:03
CSS3 Transitions for Dashing Dashboards

Flying Widgets adds CSS3 transitions to your dashboard, allowing you to cycle through multiple widget sets on a single TV without page reloads, using stylish CSS3 transitions. You can even still re-order your widgets and save their locations!

Note that sinatra-cyclist is a potential alternative if the machine you use to display your dashboards is lacking in graphics horsepower.

To use, put this file in assets/javascripts/cycleDashboard.coffee. Then find this line in application.coffee:

    $('.gridster ul:first').gridster