sed [options] sed-command [input-file]
Option | Description | Example |
---|
// International Chemical Identifier Regex, by lo sauer - lsauer.com | |
// Morphine InchI: | |
var x="InChI=1S/C17H19NO3/c1-18-7-6-17-10-3-5-13(20)16(17)21-15-12(19)4-2-9(14(15)17)8-11(10)18/h2-5,10-11,13,16,19-20H,6-8H2,1H3/t10-,11+,13-,16-,17-/m0/s1" | |
// applying an organic character-subset | |
// we could check for the length property, but in case of 0 matches 'null' is returned -> hence !!.. \ generally equal to Boolean(..) | |
!!x.trim().match(/^((InChI=)?[^J][0-9BCOHNSOPrIFla+\-\(\)\\\/,pqbtmsih]{6,})$/ig) | |
>true | |
//generic: | |
x.trim().match(/^((InChI=)?[^J][0-9a-z+\-\(\)\\\/,]+)$/ig) |
// Support routines for automatically reporting user timing for common analytics platforms | |
// Currently supports Google Analytics, Boomerang and SOASTA mPulse | |
// In the case of boomerang, you will need to map the event names you want reported | |
// to timer names (for mPulse these need to be custom0, custom1, etc) using a global variable: | |
// rumMapping = {'aft': 'custom0'}; | |
(function() { | |
var wtt = function(n, t, b) { | |
t = Math.round(t); | |
if (t >= 0 && t < 3600000) { | |
// Google Analytics |
FILE SPACING: | |
# double space a file | |
sed G | |
# double space a file which already has blank lines in it. Output file | |
# should contain no more than one blank line between lines of text. | |
sed '/^$/d;G' |
package main | |
import ( | |
"bufio" | |
"encoding/csv" | |
"encoding/json" | |
"fmt" | |
"io" | |
"os" | |
"path/filepath" |
xhost + ${hostname}
to allow connections to the macOS host *export HOSTNAME=`hostname`
* environment:
#!/bin/bash | |
# https://code.luasoftware.com/tutorials/linux/command-line-optimize-image/ | |
find . -type f -iname '*.png' -exec pngquant --skip-if-larger --ext .png --force 256 {} \; | |
find . -type f -iname "*.png" | xargs optipng -o2 -strip all | |
find . -name '*.png' -print0 | xargs -0 -n1 -I{} sh -c 'zopflipng {} output.png; [ -f output.png ] && mv output.png {};' | |
# Using -print0 to deal with spaces | |
find . -print0 -type f -name "*.jpg" -o -name "*.JPG" | xargs -0 jpegoptim |
package main | |
import ( | |
"bytes" | |
"encoding/json" | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
"strings" | |
) |
// A simple helper to test functions not-exported but with _ prefix | |
const privateCases = async function (flpath: string, cases: Function) { | |
const decoder = new TextDecoder("utf-8"); | |
let body = decoder.decode(await Deno.readFile(flpath)); | |
body = body.replace(/\nfunction _/g, "\nexport function _"); | |
const tmppath = flpath.replace(/([^\/]+)$/, "~$1"), | |
encoder = new TextEncoder(); | |
await Deno.writeFile(tmppath, encoder.encode(body)); | |
cases(await import(tmppath)); |