This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function shorten($input) { | |
// (1) original regexp: | |
// if the path has an extension, the directory separator will be captured as part of the extension | |
// "path.foo/somefile" will become "path.foo/s" | |
// this fails here -----------. | |
// v | |
// return preg_replace('@(\.[^.]{0,5}+)[^./\\\]*[^/\\\]{1,1}?$@', '$1', $input); | |
// (2) don't match path extensions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; emacs-stdin-stdout.el -- duplicate every line from stdin to stdout | |
;;; Commentary: | |
;; run this script with: | |
;; `emacs -batch -l emacs-stdin-stdout.el -f start` | |
;; | |
;; see https://joelmccracken.github.io/entries/reading-writing-data-in-emacs-batch-via-stdin-stdout/ | |
;;; Code: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
COUNT=0 | |
SECONDS=0 | |
for MFLAG1 in '' 'OMIT_GET_LONGOPT=1'; do | |
for MFLAG2 in '' 'ENABLE_BTRFS=1'; do | |
for MFLAG3 in '' 'LOW_MEMORY=1'; do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# see https://github.com/oetiker/rrdtool-1.x/pull/757 | |
FILE=log10.rrd | |
IMAGE=log10.png | |
TIME=1480787200 | |
COUNT=15 | |
./rrdtool create $FILE \ | |
--start $TIME --step 1 \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
BASEURL=http://us.battle.net/wow/en/game/lore/ | |
TEMPFILE=$(mktemp) | |
# download public World of Warcraft lore (short stories) from Blizzard website | |
# | |
# needs standard shell utils plus Perl LWP (or rewrite to use wget/curl/whatever instead of GET) | |
GET $BASEURL \ | |
| grep -A2 lore-info \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# download public Starcraft lore (short stories) from Blizzard website | |
# | |
# needs standard shell utils plus Perl LWP (or rewrite to use wget/curl/whatever instead of GET) | |
BASEURL=http://us.battle.net/sc2/en/game/lore/ | |
TEMPFILE=$(mktemp) | |
GET $BASEURL \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
use POSIX ":sys_wait_h"; | |
# check for Process::Table on startup | |
our $have_process_table; | |
BEGIN { | |
eval { require Proc::ProcessTable; }; | |
$have_process_table = not $@; | |
} |