This file contains 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
/* This functions takes a path to a directory (C:/blah) and a file name (foobar.txt) then returns the full path of the file (C:/blah/foobar.txt) */ | |
size_t sn_make_path(char *buffer, size_t bsize, const char *dir_path, const char *file_name, char dir_sep) { | |
size_t dir_len = strlen(dir_path); | |
size_t file_len = strlen(file_name); | |
int add_slash = dir_len > 0 && dir_path[dir_len - 1] != dir_sep; | |
size_t file_path_len = dir_len + file_len + add_slash; | |
if (bsize > 0) { |
This file contains 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 | |
dryrun=false | |
verbose=false | |
root=/ | |
[[ "--help" = "$1"* && $1 = --h* || "$*" = -h ]] && { cat <<EndOfHelp ; exit 0 ; } | |
${0##*/} [-v|-q] [-n|-N] [-r /PATH] [PATH ...] | |
EndOfHelp |
This file contains 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
#define BUfSIZ*pick a number | |
, add #includes, and ADD ERROR HANDLING */ | |
int main(){ | |
char b[N]="/tmp/.spongeXXXXXX"; | |
char*t=mktemp(b); | |
int f=open(t,O_RDWR|O_CREAT|O_EXCL,0); | |
unlink(t); | |
ssize_t n; | |
while((n=read(0,b,N))>0) |
This file contains 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 | |
shopt -s globstar | |
sdir=$HOME/Documents/website | |
tdir=$HOME/tmp/transcoded-website | |
scode=WINDOWS-1252 | |
tcode=UTF-8 | |
mkdir -vp "$tdir" |
This file contains 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 | |
use 5.008; | |
use strict; | |
use warnings; | |
use Getopt::Long qw(:config bundling); | |
use POSIX qw( floor ); | |
use utf8; |
This file contains 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 | |
use utf8; | |
binmode STDOUT, ":utf8"; | |
while (<>) { | |
s/ / /g; | |
s/\t/\t\t/g; | |
s/[!-~]/chr(ord($&)+0xff00-0x20)/xge; | |
print $_; |
This file contains 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 | |
pid=${1:-$PPID} | |
signals="$(trap -l)" | |
declare -A SIG | |
for s in ${signals//') '/=} | |
do | |
i=${s%%=*} |
This file contains 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
readkey() { | |
local char | |
IFS= \ | |
read -rs -d '' -N1 key || return $? # use -n1 on older versions | |
while | |
case "$key" in | |
('') key=$'\n' ; break ;; # compensate for bug | |
( $'\e[M'??? ) break ;; # mouse report | |
( $'\e' | $'\e[' | $'\e['[?O] | $'\e['*[\;0-9] | $'\e[M'* | $'\eO' ) ;; | |
( [$'\xc0'-\$'xfe'] \ |
This file contains 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 | |
# Update /etc/resolv.conf but keep it unwritable, even by root-owned processes. | |
# Useful to stop WiFi and/or DHCP from messing with it, and quite essential when | |
# there are multiple managers for different interface types. | |
# | |
# Because symlinks don't work, instead we bind-mount an appropriate file onto | |
# /etc/resolv.conf, chosen from those in ~/.resolvconf.d/. | |
# | |
# Since BIND is running locally, almost all the time that will work, so it's the |
This file contains 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
#!/path/to/your/bash | |
dox=( [1]='a partridge in a pair tree' | |
'2 turtle doves, and' | |
'3 french hens' | |
'4 calling birds' | |
$'5 gold rings\n ...' | |
'6 geese a-laying' | |
'7 swans a-swimming' | |
'8 maids a-milking' |